use of org.olat.modules.lecture.model.ParticipantAndLectureSummary in project openolat by klemens.
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 klemens.
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 LectureParticipantSummaryDAOTest method getLectureParticipantSummaries_lectureBlock.
@Test
public void getLectureParticipantSummaries_lectureBlock() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock block = createMinimalLectureBlock(entry);
dbInstance.commitAndCloseSession();
List<ParticipantAndLectureSummary> summaries = lectureParticipantSummaryDao.getLectureParticipantSummaries(block);
Assert.assertNotNull(summaries);
}
use of org.olat.modules.lecture.model.ParticipantAndLectureSummary in project openolat by klemens.
the class LectureParticipantSummaryDAOTest method getLectureParticipantSummaries_lectureBlock.
@Test
public void getLectureParticipantSummaries_lectureBlock() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock block = createMinimalLectureBlock(entry);
dbInstance.commitAndCloseSession();
List<ParticipantAndLectureSummary> summaries = lectureParticipantSummaryDao.getLectureParticipantSummaries(block);
Assert.assertNotNull(summaries);
}
use of org.olat.modules.lecture.model.ParticipantAndLectureSummary in project openolat by klemens.
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);
}
Aggregations