use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.
the class LectureServiceImpl method copyLectureBlock.
@Override
public LectureBlock copyLectureBlock(String newTitle, LectureBlock block) {
LectureBlock copy = lectureBlockDao.createLectureBlock(block.getEntry());
copy.setTitle(newTitle);
copy.setDescription(block.getDescription());
copy.setPreparation(block.getPreparation());
copy.setLocation(block.getLocation());
copy.setRollCallStatus(LectureRollCallStatus.open);
copy.setEffectiveLecturesNumber(block.getEffectiveLecturesNumber());
copy.setPlannedLecturesNumber(block.getPlannedLecturesNumber());
copy.setStartDate(block.getStartDate());
copy.setEndDate(block.getEndDate());
copy = lectureBlockDao.update(copy);
return copy;
}
use of org.olat.modules.lecture.LectureBlock 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.LectureBlock in project openolat by klemens.
the class ParticipantLectureBlocksController method doAppeal.
private void doAppeal(UserRequest ureq, LectureBlockAndRollCall row) {
if (appealCtrl != null)
return;
LectureBlock block = lectureService.getLectureBlock(row.getLectureBlockRef());
List<Identity> teachers = lectureService.getTeachers(block);
List<Identity> onwers = repositoryService.getMembers(entry, GroupRoles.owner.name());
ContactList contactList = new ContactList(translate("appeal.contact.list"));
contactList.addAllIdentites(teachers);
contactList.addAllIdentites(onwers);
StringBuilder teacherNames = new StringBuilder();
for (Identity teacher : teachers) {
if (teacherNames.length() > 0)
teacherNames.append(", ");
teacherNames.append(teacher.getUser().getFirstName()).append(" ").append(teacher.getUser().getLastName());
}
String date = Formatter.getInstance(getLocale()).formatDate(block.getStartDate());
String[] args = new String[] { row.getLectureBlockTitle(), teacherNames.toString(), date };
ContactMessage cmsg = new ContactMessage(getIdentity());
cmsg.addEmailTo(contactList);
cmsg.setSubject(translate("appeal.subject", args));
cmsg.setBodyText(translate("appeal.body", args));
appealCtrl = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
appealCtrl.setUserObject(row);
appealCtrl.setContactFormTitle(translate("new.appeal.title"));
listenTo(appealCtrl);
String title = translate("appeal.title", new String[] { row.getLectureBlockTitle() });
cmc = new CloseableModalController(getWindowControl(), "close", appealCtrl.getInitialComponent(), true, title);
listenTo(cmc);
cmc.activate();
}
use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.
the class LectureListRepositoryController method doEditLectureBlock.
private void doEditLectureBlock(UserRequest ureq, LectureBlockRow row) {
if (editLectureCtrl != null)
return;
LectureBlock block = lectureService.getLectureBlock(row);
editLectureCtrl = new EditLectureBlockController(ureq, getWindowControl(), entry, block);
listenTo(editLectureCtrl);
cmc = new CloseableModalController(getWindowControl(), "close", editLectureCtrl.getInitialComponent(), true, translate("add.lecture"));
listenTo(cmc);
cmc.activate();
}
use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.
the class LectureListRepositoryController method doDelete.
private void doDelete(List<LectureBlock> blocks) {
for (LectureBlock block : blocks) {
lectureService.deleteLectureBlock(block);
logAudit("Lecture block deleted: " + block, null);
ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LECTURE_BLOCK_DELETED, getClass(), CoreLoggingResourceable.wrap(block, OlatResourceableType.lectureBlock, block.getTitle()));
}
showInfo("lecture.deleted");
}
Aggregations