Search in sources :

Example 11 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.

the class TeacherRollCallController method doCheckRow.

private void doCheckRow(TeacherRollCallRow row, MultipleSelectionElement check) {
    int index = row.getIndexOfCheck(check);
    List<Integer> indexList = Collections.singletonList(index);
    LectureBlockRollCall rollCall;
    String before = lectureService.toAuditXml(row.getRollCall());
    if (check.isAtLeastSelected(1)) {
        rollCall = lectureService.addRollCall(row.getIdentity(), lectureBlock, row.getRollCall(), indexList);
        lectureService.auditLog(LectureBlockAuditLog.Action.addToRollCall, before, lectureService.toAuditXml(rollCall), Integer.toString(index), lectureBlock, rollCall, lectureBlock.getEntry(), row.getIdentity(), getIdentity());
    } else {
        rollCall = lectureService.removeRollCall(row.getIdentity(), lectureBlock, row.getRollCall(), indexList);
        lectureService.auditLog(LectureBlockAuditLog.Action.removeFromRollCall, before, lectureService.toAuditXml(rollCall), Integer.toString(index), lectureBlock, rollCall, lectureBlock.getEntry(), row.getIdentity(), getIdentity());
    }
    row.setRollCall(rollCall);
    if (authorizedAbsenceEnabled && row.getAuthorizedAbsence() != null) {
        if (rollCall.getAbsenceAuthorized() != null && rollCall.getAbsenceAuthorized().booleanValue()) {
            row.getAuthorizedAbsence().select(onKeys[0], true);
        } else {
            row.getAuthorizedAbsence().uncheckAll();
        }
        row.getAuthorizedAbsenceCont().setDirty(true);
    }
    row.getRollCallStatusEl().getComponent().setDirty(true);
}
Also used : LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall)

Example 12 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.

the class LectureBlockRollCallDAOTest method addLectures.

@Test
public void addLectures() {
    LectureBlock lectureBlock = createMinimalLectureBlock(4);
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
    dbInstance.commitAndCloseSession();
    List<Integer> absences = Arrays.asList(0);
    LectureBlockRollCall rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, id, null, null, null, absences);
    dbInstance.commitAndCloseSession();
    LectureBlockRollCall reloadRollCall = lectureBlockRollCallDao.loadByKey(rollCall.getKey());
    Assert.assertNotNull(reloadRollCall);
    Assert.assertEquals(1, reloadRollCall.getLecturesAbsentNumber());
    List<Integer> additionalAbsences = Arrays.asList(1, 2);
    lectureBlockRollCallDao.addLecture(lectureBlock, reloadRollCall, additionalAbsences);
    dbInstance.commitAndCloseSession();
    // check absence
    Assert.assertEquals(3, reloadRollCall.getLecturesAbsentNumber());
    List<Integer> absenceList = reloadRollCall.getLecturesAbsentList();
    Assert.assertNotNull(absenceList);
    Assert.assertEquals(3, absenceList.size());
    Assert.assertEquals(0, absenceList.get(0).intValue());
    Assert.assertEquals(1, absenceList.get(1).intValue());
    Assert.assertEquals(2, absenceList.get(2).intValue());
    // check attendee
    Assert.assertEquals(1, reloadRollCall.getLecturesAttendedNumber());
    List<Integer> attendeeList = reloadRollCall.getLecturesAttendedList();
    Assert.assertNotNull(attendeeList);
    Assert.assertEquals(1, attendeeList.size());
    Assert.assertEquals(3, attendeeList.get(0).intValue());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 13 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.

the class LectureBlockRollCallDAOTest method adaptLectures_addMixed.

@Test
public void adaptLectures_addMixed() {
    LectureBlock lectureBlock = createMinimalLectureBlock(3);
    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, 4, id);
    dbInstance.commitAndCloseSession();
    // check absence
    Assert.assertEquals(2, adaptedCall.getLecturesAbsentNumber());
    List<Integer> absenceList = adaptedCall.getLecturesAbsentList();
    Assert.assertNotNull(absenceList);
    Assert.assertEquals(2, absenceList.size());
    Assert.assertEquals(1, absenceList.get(0).intValue());
    Assert.assertEquals(2, 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(0, attendeeList.get(0).intValue());
    Assert.assertEquals(3, attendeeList.get(1).intValue());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 14 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.

the class LectureBlockRollCallDAOTest method createAndPersistRollCall.

@Test
public void createAndPersistRollCall() {
    LectureBlock lectureBlock = createMinimalLectureBlock(2);
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
    dbInstance.commitAndCloseSession();
    LectureBlockRollCall rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, id, null, null, null, null);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(rollCall);
    Assert.assertNotNull(rollCall.getKey());
    Assert.assertNotNull(rollCall.getCreationDate());
    Assert.assertNotNull(rollCall.getLastModified());
    Assert.assertEquals(lectureBlock, rollCall.getLectureBlock());
    Assert.assertEquals(id, rollCall.getIdentity());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 15 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project openolat by klemens.

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));
    }
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockRollCallSearchParameters(org.olat.modules.lecture.LectureBlockRollCallSearchParameters) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) List(java.util.List) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Aggregations

LectureBlockRollCall (org.olat.modules.lecture.LectureBlockRollCall)64 LectureBlock (org.olat.modules.lecture.LectureBlock)40 Identity (org.olat.core.id.Identity)36 Test (org.junit.Test)26 LectureBlockRollCallSearchParameters (org.olat.modules.lecture.LectureBlockRollCallSearchParameters)16 Date (java.util.Date)14 ArrayList (java.util.ArrayList)12 List (java.util.List)10 LectureService (org.olat.modules.lecture.LectureService)10 HashMap (java.util.HashMap)8 IOException (java.io.IOException)6 URI (java.net.URI)6 Collectors (java.util.stream.Collectors)6 HttpResponse (org.apache.http.HttpResponse)6 LectureBlockRollCallVO (org.olat.modules.lecture.restapi.LectureBlockRollCallVO)6 LectureBlockStatus (org.olat.modules.lecture.LectureBlockStatus)5 LectureRollCallStatus (org.olat.modules.lecture.LectureRollCallStatus)5 Map (java.util.Map)4 Roles (org.olat.core.id.Roles)4 LectureBlockAndRollCall (org.olat.modules.lecture.model.LectureBlockAndRollCall)4