use of org.olat.modules.lecture.model.LectureBlockReminderImpl 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);
}
use of org.olat.modules.lecture.model.LectureBlockReminderImpl in project OpenOLAT by OpenOLAT.
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.model.LectureBlockReminderImpl 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.model.LectureBlockReminderImpl in project openolat by klemens.
the class LectureBlockReminderDAO method createReminder.
public LectureBlockReminderImpl createReminder(LectureBlock lectureBlock, Identity teacher, String status) {
LectureBlockReminderImpl reminder = new LectureBlockReminderImpl();
reminder.setCreationDate(new Date());
reminder.setStatus(status);
reminder.setLectureBlock(lectureBlock);
reminder.setIdentity(teacher);
dbInstance.getCurrentEntityManager().persist(reminder);
return reminder;
}
use of org.olat.modules.lecture.model.LectureBlockReminderImpl in project OpenOLAT by OpenOLAT.
the class LectureBlockReminderDAOTest method createReminder.
@Test
public void createReminder() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("reminder-1");
LectureBlock lectureBlock = createMinimalLectureBlock(2);
LectureBlockReminderImpl reminder = lectureBlockReminderDao.createReminder(lectureBlock, id, "ok");
dbInstance.commitAndCloseSession();
Assert.assertNotNull(reminder);
Assert.assertNotNull(reminder.getKey());
Assert.assertNotNull(reminder.getCreationDate());
Assert.assertEquals(id, reminder.getIdentity());
Assert.assertEquals(lectureBlock, reminder.getLectureBlock());
}
Aggregations