use of org.olat.modules.lecture.model.LectureBlockImpl in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method save.
@Override
public LectureBlock save(LectureBlock lectureBlock, List<Group> groups) {
LectureBlockImpl block = (LectureBlockImpl) lectureBlockDao.update(lectureBlock);
if (groups != null) {
List<LectureBlockToGroup> lectureToGroups = lectureBlockToGroupDao.getLectureBlockToGroups(block);
for (Group group : groups) {
boolean found = false;
for (LectureBlockToGroup lectureToGroup : lectureToGroups) {
if (lectureToGroup.getGroup().equals(group)) {
found = true;
break;
}
}
if (!found) {
LectureBlockToGroup blockToGroup = lectureBlockToGroupDao.createAndPersist(block, group);
lectureToGroups.add(blockToGroup);
}
}
for (Iterator<LectureBlockToGroup> lectureToGroupIt = lectureToGroups.iterator(); lectureToGroupIt.hasNext(); ) {
LectureBlockToGroup lectureBlockToGroup = lectureToGroupIt.next();
if (!groups.contains(lectureBlockToGroup.getGroup())) {
lectureBlockToGroupDao.remove(lectureBlockToGroup);
}
}
}
block.getTeacherGroup().getKey();
return block;
}
use of org.olat.modules.lecture.model.LectureBlockImpl in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method close.
@Override
public LectureBlock close(LectureBlock lectureBlock, Identity author) {
lectureBlock.setStatus(LectureBlockStatus.done);
lectureBlock.setRollCallStatus(LectureRollCallStatus.closed);
LectureBlockImpl block = (LectureBlockImpl) lectureBlockDao.update(lectureBlock);
int numOfLectures = block.getEffectiveLecturesNumber();
if (numOfLectures <= 0 && block.getStatus() != LectureBlockStatus.cancelled) {
numOfLectures = block.getPlannedLecturesNumber();
}
List<LectureBlockRollCall> rollCallList = lectureBlockRollCallDao.getRollCalls(lectureBlock);
for (LectureBlockRollCall rollCall : rollCallList) {
lectureBlockRollCallDao.adaptLecture(block, rollCall, numOfLectures, author);
}
dbInstance.commit();
recalculateSummary(block.getEntry());
return block;
}
use of org.olat.modules.lecture.model.LectureBlockImpl 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.LectureBlockImpl in project openolat by klemens.
the class LectureServiceImpl method close.
@Override
public LectureBlock close(LectureBlock lectureBlock, Identity author) {
lectureBlock.setStatus(LectureBlockStatus.done);
lectureBlock.setRollCallStatus(LectureRollCallStatus.closed);
LectureBlockImpl block = (LectureBlockImpl) lectureBlockDao.update(lectureBlock);
int numOfLectures = block.getEffectiveLecturesNumber();
if (numOfLectures <= 0 && block.getStatus() != LectureBlockStatus.cancelled) {
numOfLectures = block.getPlannedLecturesNumber();
}
List<LectureBlockRollCall> rollCallList = lectureBlockRollCallDao.getRollCalls(lectureBlock);
for (LectureBlockRollCall rollCall : rollCallList) {
lectureBlockRollCallDao.adaptLecture(block, rollCall, numOfLectures, author);
}
dbInstance.commit();
recalculateSummary(block.getEntry());
return block;
}
use of org.olat.modules.lecture.model.LectureBlockImpl in project openolat by klemens.
the class LectureServiceImpl method cancel.
@Override
public LectureBlock cancel(LectureBlock lectureBlock) {
lectureBlock.setStatus(LectureBlockStatus.cancelled);
lectureBlock.setRollCallStatus(LectureRollCallStatus.closed);
lectureBlock.setEffectiveLecturesNumber(0);
LectureBlockImpl block = (LectureBlockImpl) lectureBlockDao.update(lectureBlock);
dbInstance.commit();
recalculateSummary(block.getEntry());
return block;
}
Aggregations