use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAOTest method createMinimalLectureBlock.
private LectureBlock createMinimalLectureBlock(int numOfLectures) {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
lectureBlock.setStartDate(new Date());
lectureBlock.setEndDate(new Date());
lectureBlock.setTitle("Hello lecturers");
lectureBlock.setPlannedLecturesNumber(numOfLectures);
lectureBlock.setEffectiveLecturesNumber(numOfLectures);
return lectureBlockDao.update(lectureBlock);
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAOTest method createAndPersistRollCall.
@Test
public void createAndPersistRollCall() {
LectureBlock lectureBlock = createMinimalLectureBlock(2);
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
dbInstance.commitAndCloseSession();
LectureBlockRollCall rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, id, null, null, null, null);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(rollCall);
Assert.assertNotNull(rollCall.getKey());
Assert.assertNotNull(rollCall.getCreationDate());
Assert.assertNotNull(rollCall.getLastModified());
Assert.assertEquals(lectureBlock, rollCall.getLectureBlock());
Assert.assertEquals(id, rollCall.getIdentity());
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureServiceTest method addTeacher.
@Test
public void addTeacher() {
Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-1");
Identity notTeacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-2");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = createMinimalLectureBlock(entry);
dbInstance.commitAndCloseSession();
// enable lecture on this entry
RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
config.setLectureEnabled(true);
config = lectureService.updateRepositoryEntryLectureConfiguration(config);
lectureService.addTeacher(lectureBlock, teacher);
dbInstance.commitAndCloseSession();
boolean isTeacher = lectureService.hasLecturesAsTeacher(entry, teacher);
Assert.assertTrue(isTeacher);
boolean isNotTeacher = lectureService.hasLecturesAsTeacher(entry, notTeacher);
Assert.assertFalse(isNotTeacher);
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureServiceTest method getParticipantLecturesStatistics.
@Test
public void getParticipantLecturesStatistics() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-6-1");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-6-2");
// a closed lecture block in the past
LectureBlock lectureBlock1 = createClosedLectureBlockInPast(entry);
LectureBlock lectureBlock2 = createClosedLectureBlockInPast(entry);
LectureBlock lectureBlock3 = createClosedLectureBlockInPast(entry);
// create summary in the past
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -4);
lectureParticipantSummaryDao.createSummary(entry, participant1, cal.getTime());
lectureParticipantSummaryDao.createSummary(entry, participant2, cal.getTime());
// add participants to the "course"
repositoryEntryRelationDAO.addRole(participant1, entry, GroupRole.participant.name());
repositoryEntryRelationDAO.addRole(participant2, entry, GroupRole.participant.name());
dbInstance.commitAndCloseSession();
RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
config.setLectureEnabled(true);
lectureService.updateRepositoryEntryLectureConfiguration(config);
// add the course to the lectures
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureBlock1 = lectureService.save(lectureBlock1, Collections.singletonList(defGroup));
lectureBlock2 = lectureService.save(lectureBlock2, Collections.singletonList(defGroup));
lectureBlock3 = lectureService.save(lectureBlock3, Collections.singletonList(defGroup));
dbInstance.commitAndCloseSession();
lectureService.addRollCall(participant1, lectureBlock1, null, toList(1, 2));
lectureService.addRollCall(participant1, lectureBlock2, null, toList(1, 2, 3, 4));
lectureService.addRollCall(participant2, lectureBlock1, null, toList(1, 2, 3, 4));
lectureService.addRollCall(participant2, lectureBlock3, null, toList(2, 3, 4));
dbInstance.commitAndCloseSession();
// check first participant
List<LectureBlockStatistics> statistics_1 = lectureService.getParticipantLecturesStatistics(participant1);
Assert.assertNotNull(statistics_1);
Assert.assertEquals(1, statistics_1.size());
LectureBlockStatistics statistic_1 = statistics_1.get(0);
Assert.assertEquals(12, statistic_1.getTotalPersonalPlannedLectures());
Assert.assertEquals(2, statistic_1.getTotalAttendedLectures());
Assert.assertEquals(6, statistic_1.getTotalAbsentLectures());
// check second participant
List<LectureBlockStatistics> statistics_2 = lectureService.getParticipantLecturesStatistics(participant2);
Assert.assertNotNull(statistics_2);
Assert.assertEquals(1, statistics_2.size());
LectureBlockStatistics statistic_2 = statistics_2.get(0);
Assert.assertEquals(12, statistic_2.getTotalPersonalPlannedLectures());
Assert.assertEquals(1, statistic_2.getTotalAttendedLectures());
Assert.assertEquals(7, statistic_2.getTotalAbsentLectures());
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureServiceTest method createMinimalLectureBlock.
private LectureBlock createMinimalLectureBlock(RepositoryEntry entry) {
LectureBlock lectureBlock = lectureService.createLectureBlock(entry);
lectureBlock.setStartDate(new Date());
lectureBlock.setEndDate(new Date());
lectureBlock.setTitle("Hello lecturers");
lectureBlock.setPlannedLecturesNumber(4);
return lectureService.save(lectureBlock, null);
}
Aggregations