use of org.olat.modules.lecture.model.LectureBlockImpl in project openolat by klemens.
the class LectureServiceImpl method removeTeacher.
@Override
public void removeTeacher(LectureBlock lectureBlock, Identity teacher) {
LectureBlockImpl block = (LectureBlockImpl) lectureBlock;
groupDao.removeMembership(block.getTeacherGroup(), teacher);
}
use of org.olat.modules.lecture.model.LectureBlockImpl 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.LectureBlockImpl in project openolat by klemens.
the class LectureBlockDAO method update.
public LectureBlock update(LectureBlock block) {
if (block.getKey() == null) {
((LectureBlockImpl) block).setTeacherGroup(groupDao.createGroup());
dbInstance.getCurrentEntityManager().persist(block);
} else {
block.setLastModified(new Date());
block = dbInstance.getCurrentEntityManager().merge(block);
}
return block;
}
use of org.olat.modules.lecture.model.LectureBlockImpl in project openolat by klemens.
the class LectureBlockDAO method createLectureBlock.
public LectureBlock createLectureBlock(RepositoryEntry entry) {
LectureBlockImpl block = new LectureBlockImpl();
block.setCreationDate(new Date());
block.setLastModified(block.getCreationDate());
block.setStatus(LectureBlockStatus.active);
block.setRollCallStatus(LectureRollCallStatus.open);
block.setCompulsory(true);
block.setEntry(entry);
return block;
}
use of org.olat.modules.lecture.model.LectureBlockImpl in project OpenOLAT by OpenOLAT.
the class LectureBlockDAOTest method addGroup.
@Test
public void addGroup() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
lectureBlock.setStartDate(new Date());
lectureBlock.setEndDate(new Date());
lectureBlock.setTitle("Hello lecturers");
lectureBlock = lectureBlockDao.update(lectureBlock);
dbInstance.commitAndCloseSession();
Group defGroup = repositoryEntryRelationDao.getDefaultGroup(entry);
lectureBlockDao.addGroupToLectureBlock(lectureBlock, defGroup);
dbInstance.commitAndCloseSession();
LectureBlockImpl reloadedLectureBlock = (LectureBlockImpl) lectureBlockDao.loadByKey(lectureBlock.getKey());
Set<LectureBlockToGroup> blockToGroupSet = reloadedLectureBlock.getGroups();
Assert.assertNotNull(blockToGroupSet);
Assert.assertEquals(1, blockToGroupSet.size());
LectureBlockToGroupImpl defBlockToGroup = (LectureBlockToGroupImpl) blockToGroupSet.iterator().next();
Assert.assertEquals(defGroup, defBlockToGroup.getGroup());
Assert.assertEquals(lectureBlock, defBlockToGroup.getLectureBlock());
}
Aggregations