use of org.olat.modules.lecture.model.ParticipantAndLectureSummary in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method startLectureBlock.
@Override
public List<Identity> startLectureBlock(Identity teacher, LectureBlock lectureBlock) {
RepositoryEntry entry = lectureBlock.getEntry();
Date now = new Date();
List<ParticipantAndLectureSummary> participantsAndSummaries = lectureParticipantSummaryDao.getLectureParticipantSummaries(lectureBlock);
Set<Identity> participants = new HashSet<>();
for (ParticipantAndLectureSummary participantAndSummary : participantsAndSummaries) {
if (participants.contains(participantAndSummary.getIdentity())) {
continue;
}
if (participantAndSummary.getSummary() == null) {
lectureParticipantSummaryDao.createSummary(entry, participantAndSummary.getIdentity(), now);
}
participants.add(participantAndSummary.getIdentity());
}
return new ArrayList<>(participants);
}
use of org.olat.modules.lecture.model.ParticipantAndLectureSummary in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method syncParticipantSummaries.
@Override
public List<Identity> syncParticipantSummaries(LectureBlock lectureBlock) {
RepositoryEntry entry = lectureBlock.getEntry();
Date now = new Date();
List<ParticipantAndLectureSummary> participantsAndSummaries = lectureParticipantSummaryDao.getLectureParticipantSummaries(lectureBlock);
Set<Identity> participants = new HashSet<>();
for (ParticipantAndLectureSummary participantAndSummary : participantsAndSummaries) {
if (participants.contains(participantAndSummary.getIdentity())) {
continue;
}
if (participantAndSummary.getSummary() == null) {
lectureParticipantSummaryDao.createSummary(entry, participantAndSummary.getIdentity(), now);
}
participants.add(participantAndSummary.getIdentity());
}
return new ArrayList<>(participants);
}
use of org.olat.modules.lecture.model.ParticipantAndLectureSummary in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method autoClose.
private void autoClose(LectureBlockImpl lectureBlock) {
String blockBefore = auditLogDao.toXml(lectureBlock);
lectureBlock.setStatus(LectureBlockStatus.done);
lectureBlock.setRollCallStatus(LectureRollCallStatus.autoclosed);
if (lectureBlock.getEffectiveLecturesNumber() <= 0 && lectureBlock.getStatus() != LectureBlockStatus.cancelled) {
lectureBlock.setEffectiveLecturesNumber(lectureBlock.getPlannedLecturesNumber());
}
lectureBlock.setAutoClosedDate(new Date());
lectureBlock = (LectureBlockImpl) lectureBlockDao.update(lectureBlock);
dbInstance.commit();
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(lectureBlock);
Map<Identity, LectureBlockRollCall> rollCallMap = rollCalls.stream().collect(Collectors.toMap(r -> r.getIdentity(), r -> r));
List<ParticipantAndLectureSummary> participantsAndSummaries = lectureParticipantSummaryDao.getLectureParticipantSummaries(lectureBlock);
Set<Identity> participants = new HashSet<>();
for (ParticipantAndLectureSummary participantAndSummary : participantsAndSummaries) {
if (participants.contains(participantAndSummary.getIdentity())) {
continue;
}
if (participantAndSummary.getSummary() != null) {
LectureBlockRollCall rollCall = rollCallMap.get(participantAndSummary.getIdentity());
String before = auditLogDao.toXml(rollCall);
if (rollCall == null) {
rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, participantAndSummary.getIdentity(), null, null, null, new ArrayList<>());
} else if (rollCall.getLecturesAbsentList().isEmpty() && rollCall.getLecturesAttendedList().isEmpty()) {
rollCall = lectureBlockRollCallDao.addLecture(lectureBlock, rollCall, new ArrayList<>());
}
String after = auditLogDao.toXml(rollCall);
auditLogDao.auditLog(LectureBlockAuditLog.Action.autoclose, before, after, null, lectureBlock, rollCall, lectureBlock.getEntry(), participantAndSummary.getIdentity(), null);
}
}
String blockAfter = auditLogDao.toXml(lectureBlock);
auditLogDao.auditLog(LectureBlockAuditLog.Action.autoclose, blockBefore, blockAfter, null, lectureBlock, null, lectureBlock.getEntry(), null, null);
dbInstance.commit();
recalculateSummary(lectureBlock.getEntry());
}
use of org.olat.modules.lecture.model.ParticipantAndLectureSummary in project OpenOLAT by OpenOLAT.
the class LectureParticipantSummaryDAO method getLectureParticipantSummaries.
public List<ParticipantAndLectureSummary> getLectureParticipantSummaries(LectureBlock block) {
StringBuilder sb = new StringBuilder();
sb.append("select participant, summary from lectureblock block").append(" inner join block.groups blockGroup").append(" inner join blockGroup.group bGroup").append(" inner join bGroup.members membership on (membership.role='").append(GroupRoles.participant.name()).append("')").append(" inner join membership.identity participant").append(" inner join participant.user participantUser").append(" left join lectureparticipantsummary summary on (summary.identity.key=participant.key and summary.entry.key=block.entry.key)").append(" where block.key=:blockKey");
List<Object[]> rawObjects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("blockKey", block.getKey()).getResultList();
List<ParticipantAndLectureSummary> summaries = new ArrayList<>(rawObjects.size());
for (Object[] rawObject : rawObjects) {
Identity identity = (Identity) rawObject[0];
LectureParticipantSummary summary = (LectureParticipantSummary) rawObject[1];
summaries.add(new ParticipantAndLectureSummary(identity, summary));
}
return summaries;
}
use of org.olat.modules.lecture.model.ParticipantAndLectureSummary in project openolat by klemens.
the class LectureParticipantSummaryDAO method getLectureParticipantSummaries.
public List<ParticipantAndLectureSummary> getLectureParticipantSummaries(LectureBlock block) {
StringBuilder sb = new StringBuilder();
sb.append("select participant, summary from lectureblock block").append(" inner join block.groups blockGroup").append(" inner join blockGroup.group bGroup").append(" inner join bGroup.members membership on (membership.role='").append(GroupRoles.participant.name()).append("')").append(" inner join membership.identity participant").append(" inner join participant.user participantUser").append(" left join lectureparticipantsummary summary on (summary.identity.key=participant.key and summary.entry.key=block.entry.key)").append(" where block.key=:blockKey");
List<Object[]> rawObjects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("blockKey", block.getKey()).getResultList();
List<ParticipantAndLectureSummary> summaries = new ArrayList<>(rawObjects.size());
for (Object[] rawObject : rawObjects) {
Identity identity = (Identity) rawObject[0];
LectureParticipantSummary summary = (LectureParticipantSummary) rawObject[1];
summaries.add(new ParticipantAndLectureSummary(identity, summary));
}
return summaries;
}
Aggregations