use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.
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 klemens.
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 klemens.
the class LectureBlockDAOTest method getRollCallAsTeacher.
@Test
public void getRollCallAsTeacher() {
Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-1");
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();
List<LectureBlock> rollcalls = lectureBlockDao.getRollCallAsTeacher(teacher);
Assert.assertNotNull(rollcalls);
Assert.assertEquals(1, rollcalls.size());
Assert.assertEquals(lectureBlock, rollcalls.get(0));
}
use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.
the class LectureBlockReminderDAOTest method deleteReminder.
@Test
public void deleteReminder() {
// create a reminder
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("reminder-to-delete-1");
LectureBlock lectureBlock = createMinimalLectureBlock(2);
LectureBlockReminderImpl reminder = lectureBlockReminderDao.createReminder(lectureBlock, id, "Delete it");
dbInstance.commitAndCloseSession();
Assert.assertNotNull(reminder);
// delete the reminders
int deletedRows = lectureBlockReminderDao.deleteReminders(id);
Assert.assertEquals(1, deletedRows);
dbInstance.commitAndCloseSession();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -3);
List<LectureBlockToTeacher> toRemind = lectureBlockReminderDao.getLectureBlockTeachersToReminder(cal.getTime());
boolean hasId = false;
for (LectureBlockToTeacher remind : toRemind) {
if (remind.getLectureBlock().equals(lectureBlock)) {
if (remind.getTeacher().equals(id)) {
hasId = true;
}
}
}
Assert.assertFalse(hasId);
}
use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.
the class LectureBlockReminderDAOTest method loadLectureBlockToRemind_status.
@Test
public void loadLectureBlockToRemind_status() {
Identity teacher1 = JunitTestHelper.createAndPersistIdentityAsRndUser("reminder-8");
Identity teacher2 = JunitTestHelper.createAndPersistIdentityAsRndUser("reminder-9");
LectureBlock lectureBlockAutoClosed = createMinimalLectureBlock(5);
LectureBlock lectureBlockClosed = createMinimalLectureBlock(5);
LectureBlock lectureBlockCancelled = createMinimalLectureBlock(5);
LectureBlock lectureBlockReopen = createMinimalLectureBlock(5);
LectureBlock lectureBlockOpen = createMinimalLectureBlock(5);
LectureBlock lectureBlock = createMinimalLectureBlock(5);
dbInstance.commit();
// add the teachers
lectureService.addTeacher(lectureBlockAutoClosed, teacher1);
lectureService.addTeacher(lectureBlockClosed, teacher1);
lectureService.addTeacher(lectureBlockCancelled, teacher2);
lectureService.addTeacher(lectureBlockReopen, teacher1);
lectureService.addTeacher(lectureBlockReopen, teacher2);
lectureService.addTeacher(lectureBlockOpen, teacher1);
lectureService.addTeacher(lectureBlockOpen, teacher2);
lectureService.addTeacher(lectureBlock, teacher2);
dbInstance.commit();
lectureBlockAutoClosed.setRollCallStatus(LectureRollCallStatus.autoclosed);
lectureBlockAutoClosed = lectureService.save(lectureBlockAutoClosed, null);
lectureBlockClosed.setRollCallStatus(LectureRollCallStatus.closed);
lectureBlockClosed = lectureService.save(lectureBlockClosed, null);
lectureBlockCancelled.setStatus(LectureBlockStatus.cancelled);
lectureBlockCancelled = lectureService.save(lectureBlockCancelled, null);
lectureBlockReopen.setRollCallStatus(LectureRollCallStatus.reopen);
lectureBlockReopen = lectureService.save(lectureBlockReopen, null);
lectureBlockOpen.setRollCallStatus(LectureRollCallStatus.open);
lectureBlockOpen = lectureService.save(lectureBlockOpen, null);
dbInstance.commitAndCloseSession();
;
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -3);
List<LectureBlockToTeacher> toRemind = lectureBlockReminderDao.getLectureBlockTeachersToReminder(cal.getTime());
boolean hasBlock = false;
boolean hasBlockOpen = false;
boolean hasOtherBlock = false;
for (LectureBlockToTeacher remind : toRemind) {
if (remind.getLectureBlock().equals(lectureBlock)) {
hasBlock = true;
} else if (remind.getLectureBlock().equals(lectureBlockOpen)) {
hasBlockOpen = true;
} else if (remind.getLectureBlock().equals(lectureBlockAutoClosed) || remind.getLectureBlock().equals(lectureBlockClosed) || remind.getLectureBlock().equals(lectureBlockCancelled)) {
hasOtherBlock = true;
}
}
Assert.assertTrue(hasBlock);
Assert.assertTrue(hasBlockOpen);
Assert.assertFalse(hasOtherBlock);
}
Aggregations