Search in sources :

Example 1 with LectureBlockReminderImpl

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);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockToTeacher(org.olat.modules.lecture.model.LectureBlockToTeacher) Calendar(java.util.Calendar) Identity(org.olat.core.id.Identity) LectureBlockReminderImpl(org.olat.modules.lecture.model.LectureBlockReminderImpl) Test(org.junit.Test)

Example 2 with LectureBlockReminderImpl

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);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockToTeacher(org.olat.modules.lecture.model.LectureBlockToTeacher) Calendar(java.util.Calendar) Identity(org.olat.core.id.Identity) LectureBlockReminderImpl(org.olat.modules.lecture.model.LectureBlockReminderImpl) Test(org.junit.Test)

Example 3 with LectureBlockReminderImpl

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);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockToTeacher(org.olat.modules.lecture.model.LectureBlockToTeacher) Calendar(java.util.Calendar) Identity(org.olat.core.id.Identity) LectureBlockReminderImpl(org.olat.modules.lecture.model.LectureBlockReminderImpl) Test(org.junit.Test)

Example 4 with LectureBlockReminderImpl

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;
}
Also used : Date(java.util.Date) LectureBlockReminderImpl(org.olat.modules.lecture.model.LectureBlockReminderImpl)

Example 5 with LectureBlockReminderImpl

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());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Identity(org.olat.core.id.Identity) LectureBlockReminderImpl(org.olat.modules.lecture.model.LectureBlockReminderImpl) Test(org.junit.Test)

Aggregations

LectureBlockReminderImpl (org.olat.modules.lecture.model.LectureBlockReminderImpl)8 Test (org.junit.Test)6 Identity (org.olat.core.id.Identity)6 LectureBlock (org.olat.modules.lecture.LectureBlock)6 Calendar (java.util.Calendar)4 LectureBlockToTeacher (org.olat.modules.lecture.model.LectureBlockToTeacher)4 Date (java.util.Date)2