use of org.olat.modules.lecture.LectureBlock 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.LectureBlock in project OpenOLAT by OpenOLAT.
the class RollCallInterceptorController method isUserInteractionRequired.
@Override
public boolean isUserInteractionRequired(UserRequest ureq) {
if (lectureModule.isEnabled()) {
List<LectureBlock> lectureBlocks = lectureService.getRollCallAsTeacher(ureq.getIdentity());
if (lectureBlocks.size() > 0) {
Formatter format = Formatter.getInstance(getLocale());
lectureBlockToStart = lectureBlocks.get(0);
String[] args = new String[] { lectureBlockToStart.getEntry().getDisplayname(), lectureBlockToStart.getEntry().getExternalRef() == null ? "" : lectureBlockToStart.getEntry().getExternalRef(), lectureBlockToStart.getTitle(), (lectureBlockToStart.getStartDate() == null ? "" : format.formatDate(lectureBlockToStart.getStartDate())), (lectureBlockToStart.getStartDate() == null ? "" : format.formatTimeShort(lectureBlockToStart.getStartDate())), (lectureBlockToStart.getEndDate() == null ? "" : format.formatTimeShort(lectureBlockToStart.getEndDate())) };
flc.contextPut("message", translate("interceptor.start", args));
}
}
return lectureBlockToStart != null;
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class TeacherLecturesTableController method doExportAttendanceList.
private void doExportAttendanceList(UserRequest ureq, LectureBlock row) {
LectureBlock lectureBlock = lectureService.getLectureBlock(row);
List<Identity> participants = lectureService.getParticipants(lectureBlock);
List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(row);
try {
LecturesBlockPDFExport export = new LecturesBlockPDFExport(lectureBlock, authorizedAbsenceEnabled, getTranslator());
export.setTeacher(userManager.getUserDisplayName(getIdentity()));
export.create(participants, rollCalls);
ureq.getDispatchResult().setResultingMediaResource(export);
} catch (IOException | TransformerException e) {
logError("", e);
}
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class TeacherLecturesTableController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == rollCallCtrl) {
if (event instanceof ReopenLectureBlockEvent) {
LectureBlock lectureBlock = rollCallCtrl.getLectureBlock();
toolbarPanel.popController(rollCallCtrl);
doSelectLectureBlock(ureq, lectureBlock);
} else if (event == Event.DONE_EVENT || event == Event.CANCELLED_EVENT || event == Event.CHANGED_EVENT) {
fireEvent(ureq, event);
}
} else if (toolsCalloutCtrl == source) {
cleanUp();
} else if (toolsCtrl == source) {
if (event == Event.DONE_EVENT) {
toolsCalloutCtrl.deactivate();
cleanUp();
}
}
super.event(ureq, source, event);
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class TeacherLecturesTableController method doExportLectureBlock.
private void doExportLectureBlock(UserRequest ureq, LectureBlock row) {
LectureBlock lectureBlock = lectureService.getLectureBlock(row);
List<Identity> teachers = lectureService.getTeachers(lectureBlock);
LectureBlockExport export = new LectureBlockExport(lectureBlock, teachers, isAdministrativeUser, authorizedAbsenceEnabled, getTranslator());
ureq.getDispatchResult().setResultingMediaResource(export);
}
Aggregations