use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAOTest method removeLectures.
@Test
public void removeLectures() {
LectureBlock lectureBlock = createMinimalLectureBlock(4);
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
dbInstance.commitAndCloseSession();
List<Integer> absences = Arrays.asList(0, 1, 2, 3);
LectureBlockRollCall rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, id, null, null, null, absences);
dbInstance.commitAndCloseSession();
LectureBlockRollCall reloadRollCall = lectureBlockRollCallDao.loadByKey(rollCall.getKey());
Assert.assertNotNull(reloadRollCall);
Assert.assertEquals(4, reloadRollCall.getLecturesAbsentNumber());
List<Integer> removedAbsences = Arrays.asList(1, 2);
lectureBlockRollCallDao.removeLecture(lectureBlock, reloadRollCall, removedAbsences);
dbInstance.commitAndCloseSession();
// check absence
Assert.assertEquals(2, reloadRollCall.getLecturesAbsentNumber());
List<Integer> absenceList = reloadRollCall.getLecturesAbsentList();
Assert.assertNotNull(absenceList);
Assert.assertEquals(2, absenceList.size());
Assert.assertEquals(0, absenceList.get(0).intValue());
Assert.assertEquals(3, absenceList.get(1).intValue());
// check attendee
Assert.assertEquals(2, reloadRollCall.getLecturesAttendedNumber());
List<Integer> attendeeList = reloadRollCall.getLecturesAttendedList();
Assert.assertNotNull(attendeeList);
Assert.assertEquals(2, attendeeList.size());
Assert.assertEquals(1, attendeeList.get(0).intValue());
Assert.assertEquals(2, attendeeList.get(1).intValue());
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAOTest method createRollCall_absences.
@Test
public void createRollCall_absences() {
LectureBlock lectureBlock = createMinimalLectureBlock(3);
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
dbInstance.commitAndCloseSession();
List<Integer> absences = Collections.singletonList(2);
LectureBlockRollCall rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, id, null, null, null, absences);
dbInstance.commitAndCloseSession();
LectureBlockRollCall reloadRollCall = lectureBlockRollCallDao.loadByKey(rollCall.getKey());
Assert.assertNotNull(reloadRollCall);
Assert.assertEquals(rollCall, reloadRollCall);
// check absence
Assert.assertEquals(1, reloadRollCall.getLecturesAbsentNumber());
List<Integer> absenceList = reloadRollCall.getLecturesAbsentList();
Assert.assertNotNull(absenceList);
Assert.assertEquals(1, absenceList.size());
Assert.assertEquals(2, absenceList.get(0).intValue());
// check attendee
Assert.assertEquals(2, reloadRollCall.getLecturesAttendedNumber());
List<Integer> attendeeList = reloadRollCall.getLecturesAttendedList();
Assert.assertNotNull(attendeeList);
Assert.assertEquals(2, attendeeList.size());
Assert.assertEquals(0, attendeeList.get(0).intValue());
Assert.assertEquals(1, attendeeList.get(1).intValue());
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAOTest method adaptLectures_removeMixed.
@Test
public void adaptLectures_removeMixed() {
LectureBlock lectureBlock = createMinimalLectureBlock(4);
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
dbInstance.commitAndCloseSession();
List<Integer> absences = Arrays.asList(1, 2);
LectureBlockRollCall rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, id, null, null, null, absences);
dbInstance.commitAndCloseSession();
LectureBlockRollCall reloadRollCall = lectureBlockRollCallDao.loadByKey(rollCall.getKey());
Assert.assertNotNull(reloadRollCall);
Assert.assertEquals(2, reloadRollCall.getLecturesAbsentNumber());
// adapt the number of lectures
LectureBlockRollCall adaptedCall = lectureBlockRollCallDao.adaptLecture(lectureBlock, reloadRollCall, 2, id);
dbInstance.commitAndCloseSession();
// check absence
Assert.assertEquals(1, adaptedCall.getLecturesAbsentNumber());
List<Integer> absenceList = adaptedCall.getLecturesAbsentList();
Assert.assertNotNull(absenceList);
Assert.assertEquals(1, absenceList.size());
Assert.assertEquals(1, absenceList.get(0).intValue());
// check attendee
Assert.assertEquals(1, reloadRollCall.getLecturesAttendedNumber());
List<Integer> attendeeList = reloadRollCall.getLecturesAttendedList();
Assert.assertNotNull(attendeeList);
Assert.assertEquals(1, attendeeList.size());
Assert.assertEquals(0, attendeeList.get(0).intValue());
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAOTest method getRollCalls_searchParams_True.
@Test
public void getRollCalls_searchParams_True() {
// an open lecture block
LectureBlock openLectureBlock = createMinimalLectureBlock(3);
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-2");
dbInstance.commitAndCloseSession();
// a closed lecture block
LectureBlock closedLectureBlock = createMinimalLectureBlock(3);
dbInstance.commitAndCloseSession();
closedLectureBlock.setStatus(LectureBlockStatus.done);
closedLectureBlock.setRollCallStatus(LectureRollCallStatus.closed);
lectureBlockDao.update(closedLectureBlock);
List<Integer> absences = Arrays.asList(1, 2);
LectureBlockRollCall rollCall1 = lectureBlockRollCallDao.createAndPersistRollCall(closedLectureBlock, id1, null, null, null, Collections.emptyList());
LectureBlockRollCall rollCall2 = lectureBlockRollCallDao.createAndPersistRollCall(closedLectureBlock, id2, null, null, null, absences);
LectureBlockRollCall rollCall3 = lectureBlockRollCallDao.createAndPersistRollCall(openLectureBlock, id1, null, null, null, absences);
LectureBlockRollCall rollCall4 = lectureBlockRollCallDao.createAndPersistRollCall(openLectureBlock, id2, null, null, null, Collections.emptyList());
dbInstance.commit();
rollCall2.setAbsenceSupervisorNotificationDate(new Date());
rollCall2 = lectureBlockRollCallDao.update(rollCall2);
dbInstance.commitAndCloseSession();
{
// only absences
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setHasAbsence(Boolean.TRUE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertTrue(rollCalls.contains(rollCall2));
Assert.assertTrue(rollCalls.contains(rollCall3));
Assert.assertFalse(rollCalls.contains(rollCall4));
}
{
// only with supervisor date
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setHasSupervisorNotificationDate(Boolean.TRUE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertTrue(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertFalse(rollCalls.contains(rollCall4));
}
{
// only closed
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setClosed(Boolean.TRUE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertTrue(rollCalls.contains(rollCall1));
Assert.assertTrue(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertFalse(rollCalls.contains(rollCall4));
}
{
// only with supervisor date
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setClosed(Boolean.TRUE);
searchParams.setHasAbsence(Boolean.TRUE);
searchParams.setHasSupervisorNotificationDate(Boolean.TRUE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertTrue(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertFalse(rollCalls.contains(rollCall4));
}
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAOTest method getRollCalls_searchParams_False.
@Test
public void getRollCalls_searchParams_False() {
// an open lecture block
LectureBlock openLectureBlock = createMinimalLectureBlock(3);
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-2");
dbInstance.commitAndCloseSession();
// a closed lecture block
LectureBlock closedLectureBlock = createMinimalLectureBlock(3);
dbInstance.commitAndCloseSession();
closedLectureBlock.setStatus(LectureBlockStatus.done);
closedLectureBlock.setRollCallStatus(LectureRollCallStatus.closed);
lectureBlockDao.update(closedLectureBlock);
List<Integer> absences = Arrays.asList(1, 2);
LectureBlockRollCall rollCall1 = lectureBlockRollCallDao.createAndPersistRollCall(closedLectureBlock, id1, null, null, null, Collections.emptyList());
LectureBlockRollCall rollCall2 = lectureBlockRollCallDao.createAndPersistRollCall(closedLectureBlock, id2, null, null, null, absences);
LectureBlockRollCall rollCall3 = lectureBlockRollCallDao.createAndPersistRollCall(openLectureBlock, id1, null, null, null, absences);
LectureBlockRollCall rollCall4 = lectureBlockRollCallDao.createAndPersistRollCall(openLectureBlock, id2, null, null, null, Collections.emptyList());
dbInstance.commit();
rollCall2.setAbsenceSupervisorNotificationDate(new Date());
rollCall2 = lectureBlockRollCallDao.update(rollCall2);
dbInstance.commitAndCloseSession();
{
// only not closed
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setClosed(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertTrue(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
{
// without absence
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setHasAbsence(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertTrue(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
{
// without supervisor date
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setHasSupervisorNotificationDate(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertTrue(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertTrue(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
{
// open, without supervisor date
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setClosed(Boolean.FALSE);
searchParams.setHasAbsence(Boolean.FALSE);
searchParams.setHasSupervisorNotificationDate(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
}
Aggregations