use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlockDAOTest method deleteLectureBlock.
@Test
public void deleteLectureBlock() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock block = createMinimalLectureBlock(entry);
dbInstance.commitAndCloseSession();
Long blockKey = block.getKey();
// delete the block
lectureBlockDao.delete(block);
dbInstance.commitAndCloseSession();
// try to relaod the block
LectureBlock deletedBlock = lectureBlockDao.loadByKey(blockKey);
Assert.assertNull(deletedBlock);
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlockDAOTest method getParticipants_repositoryEntryTeacher.
@Test
public void getParticipants_repositoryEntryTeacher() {
Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-6");
Identity coach1 = JunitTestHelper.createAndPersistIdentityAsRndUser("coach-2");
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-7");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-8");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = createMinimalLectureBlock(entry);
dbInstance.commit();
// add teacher
lectureService.addTeacher(lectureBlock, teacher);
// add a participant to the course itself as noise
repositoryEntryRelationDao.addRole(coach1, entry, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(participant1, entry, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(participant2, entry, GroupRoles.participant.name());
// add the course to the lectures
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureBlock = lectureService.save(lectureBlock, Collections.singletonList(defGroup));
dbInstance.commitAndCloseSession();
List<Identity> participants = lectureBlockDao.getParticipants(entry, teacher);
Assert.assertNotNull(participants);
Assert.assertEquals(2, participants.size());
Assert.assertTrue(participants.contains(participant1));
Assert.assertTrue(participants.contains(participant2));
Assert.assertFalse(participants.contains(coach1));
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlockDAOTest method loadByTeachers.
@Test
public void loadByTeachers() {
Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-1");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = createMinimalLectureBlock(entry);
dbInstance.commitAndCloseSession();
lectureService.addTeacher(lectureBlock, teacher);
dbInstance.commitAndCloseSession();
// search all
LecturesBlockSearchParameters searchParams = new LecturesBlockSearchParameters();
List<LectureBlock> blocks = lectureBlockDao.loadByTeacher(teacher, searchParams);
Assert.assertNotNull(blocks);
Assert.assertEquals(1, blocks.size());
Assert.assertEquals(lectureBlock, blocks.get(0));
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlockDAOTest method createMinimalLectureBlock.
private LectureBlock createMinimalLectureBlock(RepositoryEntry entry) {
LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, -15);
lectureBlock.setStartDate(cal.getTime());
cal.add(Calendar.MINUTE, 30);
lectureBlock.setEndDate(cal.getTime());
lectureBlock.setTitle("Hello lecturers");
lectureBlock.setPlannedLecturesNumber(4);
return lectureBlockDao.update(lectureBlock);
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlockReminderDAOTest method loadLectureBlockToRemind.
@Test
public void loadLectureBlockToRemind() {
Identity teacher1 = JunitTestHelper.createAndPersistIdentityAsRndUser("reminder-2");
Identity teacher2 = JunitTestHelper.createAndPersistIdentityAsRndUser("reminder-3");
LectureBlock lectureBlock = createMinimalLectureBlock(5);
dbInstance.commit();
// add the teachers
lectureService.addTeacher(lectureBlock, teacher1);
lectureService.addTeacher(lectureBlock, teacher2);
LectureBlockReminderImpl reminder = lectureBlockReminderDao.createReminder(lectureBlock, teacher1, "ok");
dbInstance.commitAndCloseSession();
Assert.assertNotNull(reminder);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -3);
List<LectureBlockToTeacher> toRemind = lectureBlockReminderDao.getLectureBlockTeachersToReminder(cal.getTime());
boolean hasTeacher1 = false;
boolean hasTeacher2 = false;
for (LectureBlockToTeacher remind : toRemind) {
if (remind.getLectureBlock().equals(lectureBlock)) {
if (remind.getTeacher().equals(teacher1)) {
hasTeacher1 = true;
} else if (remind.getTeacher().equals(teacher2)) {
hasTeacher2 = true;
}
}
}
Assert.assertTrue(hasTeacher2);
Assert.assertFalse(hasTeacher1);
}
Aggregations