Search in sources :

Example 76 with LectureBlock

use of org.olat.modules.lecture.LectureBlock 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)

Example 77 with LectureBlock

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

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());
}
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 78 with LectureBlock

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

the class LectureParticipantSummaryDAOTest method createMinimalLectureBlock.

private LectureBlock createMinimalLectureBlock(RepositoryEntry entry) {
    LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
    lectureBlock.setStartDate(new Date());
    lectureBlock.setEndDate(new Date());
    lectureBlock.setTitle("Hello lecturers");
    return lectureBlockDao.update(lectureBlock);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Date(java.util.Date)

Example 79 with LectureBlock

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

the class LectureServiceTest method getParticipantLecturesStatistics.

@Test
public void getParticipantLecturesStatistics() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-6-1");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-6-2");
    // a closed lecture block in the past
    LectureBlock lectureBlock1 = createClosedLectureBlockInPast(entry);
    LectureBlock lectureBlock2 = createClosedLectureBlockInPast(entry);
    LectureBlock lectureBlock3 = createClosedLectureBlockInPast(entry);
    // create summary in the past
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -4);
    lectureParticipantSummaryDao.createSummary(entry, participant1, cal.getTime());
    lectureParticipantSummaryDao.createSummary(entry, participant2, cal.getTime());
    // add participants to the "course"
    repositoryEntryRelationDAO.addRole(participant1, entry, GroupRole.participant.name());
    repositoryEntryRelationDAO.addRole(participant2, entry, GroupRole.participant.name());
    dbInstance.commitAndCloseSession();
    RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
    config.setLectureEnabled(true);
    lectureService.updateRepositoryEntryLectureConfiguration(config);
    // add the course to the lectures
    Group defGroup = repositoryService.getDefaultGroup(entry);
    lectureBlock1 = lectureService.save(lectureBlock1, Collections.singletonList(defGroup));
    lectureBlock2 = lectureService.save(lectureBlock2, Collections.singletonList(defGroup));
    lectureBlock3 = lectureService.save(lectureBlock3, Collections.singletonList(defGroup));
    dbInstance.commitAndCloseSession();
    lectureService.addRollCall(participant1, lectureBlock1, null, toList(1, 2));
    lectureService.addRollCall(participant1, lectureBlock2, null, toList(1, 2, 3, 4));
    lectureService.addRollCall(participant2, lectureBlock1, null, toList(1, 2, 3, 4));
    lectureService.addRollCall(participant2, lectureBlock3, null, toList(2, 3, 4));
    dbInstance.commitAndCloseSession();
    // check first participant
    List<LectureBlockStatistics> statistics_1 = lectureService.getParticipantLecturesStatistics(participant1);
    Assert.assertNotNull(statistics_1);
    Assert.assertEquals(1, statistics_1.size());
    LectureBlockStatistics statistic_1 = statistics_1.get(0);
    Assert.assertEquals(12, statistic_1.getTotalPersonalPlannedLectures());
    Assert.assertEquals(2, statistic_1.getTotalAttendedLectures());
    Assert.assertEquals(6, statistic_1.getTotalAbsentLectures());
    // check second participant
    List<LectureBlockStatistics> statistics_2 = lectureService.getParticipantLecturesStatistics(participant2);
    Assert.assertNotNull(statistics_2);
    Assert.assertEquals(1, statistics_2.size());
    LectureBlockStatistics statistic_2 = statistics_2.get(0);
    Assert.assertEquals(12, statistic_2.getTotalPersonalPlannedLectures());
    Assert.assertEquals(1, statistic_2.getTotalAttendedLectures());
    Assert.assertEquals(7, statistic_2.getTotalAbsentLectures());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) BusinessGroup(org.olat.group.BusinessGroup) Calendar(java.util.Calendar) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) LectureBlockStatistics(org.olat.modules.lecture.model.LectureBlockStatistics) Test(org.junit.Test)

Example 80 with LectureBlock

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

the class LectureServiceTest method getLectureStatistics_checkQuerySyntax.

@Test
public void getLectureStatistics_checkQuerySyntax() {
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-5-1");
    // a lecture block
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = createMinimalLectureBlock(entry);
    // add participant to the "course"
    repositoryEntryRelationDAO.addRole(participant, entry, GroupRole.participant.name());
    dbInstance.commitAndCloseSession();
    // enable lectures
    RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
    config.setLectureEnabled(true);
    lectureService.updateRepositoryEntryLectureConfiguration(config);
    // add the course to the lecture
    Group defGroup = repositoryService.getDefaultGroup(entry);
    lectureBlock = lectureService.save(lectureBlock, Collections.singletonList(defGroup));
    dbInstance.commitAndCloseSession();
    lectureService.addRollCall(participant, lectureBlock, null, Collections.singletonList(3));
    dbInstance.commitAndCloseSession();
    // add
    List<LectureBlockStatistics> statistics = lectureService.getParticipantLecturesStatistics(participant);
    Assert.assertNotNull(statistics);
    Assert.assertEquals(1, statistics.size());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) LectureBlockStatistics(org.olat.modules.lecture.model.LectureBlockStatistics) Test(org.junit.Test)

Aggregations

LectureBlock (org.olat.modules.lecture.LectureBlock)232 Identity (org.olat.core.id.Identity)132 Test (org.junit.Test)116 RepositoryEntry (org.olat.repository.RepositoryEntry)98 Date (java.util.Date)64 LectureBlockRollCall (org.olat.modules.lecture.LectureBlockRollCall)42 URI (java.net.URI)30 ArrayList (java.util.ArrayList)30 HttpResponse (org.apache.http.HttpResponse)30 Group (org.olat.basesecurity.Group)30 Calendar (java.util.Calendar)26 ICourse (org.olat.course.ICourse)24 BusinessGroup (org.olat.group.BusinessGroup)24 CourseConfigVO (org.olat.restapi.support.vo.CourseConfigVO)24 LectureBlockToGroup (org.olat.modules.lecture.LectureBlockToGroup)22 RepositoryEntryLectureConfiguration (org.olat.modules.lecture.RepositoryEntryLectureConfiguration)20 LecturesBlockSearchParameters (org.olat.modules.lecture.model.LecturesBlockSearchParameters)16 List (java.util.List)14 HttpGet (org.apache.http.client.methods.HttpGet)14 LectureBlockToTeacher (org.olat.modules.lecture.model.LectureBlockToTeacher)14