Search in sources :

Example 1 with RepositoryEntryLectureConfiguration

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

the class LectureServiceImpl method deleteLectureBlock.

@Override
public void deleteLectureBlock(LectureBlock lectureBlock) {
    // first remove events
    LectureBlock reloadedBlock = lectureBlockDao.loadByKey(lectureBlock.getKey());
    RepositoryEntry entry = reloadedBlock.getEntry();
    RepositoryEntryLectureConfiguration config = getRepositoryEntryLectureConfiguration(entry);
    if (ConfigurationHelper.isSyncCourseCalendarEnabled(config, lectureModule)) {
        unsyncCourseCalendar(lectureBlock, entry);
    }
    if (ConfigurationHelper.isSyncTeacherCalendarEnabled(config, lectureModule)) {
        List<Identity> teachers = getTeachers(reloadedBlock);
        unsyncInternalCalendar(reloadedBlock, teachers);
    }
    lectureBlockDao.delete(reloadedBlock);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Identity(org.olat.core.id.Identity)

Example 2 with RepositoryEntryLectureConfiguration

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

the class LectureBlocksWebService method updateConfiguration.

/**
 * Update the configuration of the lecture's feature of a specified
 * course or repository entry.
 * @response.representation.200.qname {http://www.example.com}repositoryEntryLectureConfigurationVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc The updated configuration
 * @response.representation.200.example {@link org.olat.modules.lecture.restapi.Examples#SAMPLE_REPOSITORYENTRYLECTURECONFIGURATIONVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The course not found
 * @param configuration The configuration
 * @param request The HTTP request
 * @return It returns the updated configuration.
 */
@POST
@Path("configuration")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response updateConfiguration(RepositoryEntryLectureConfigurationVO configuration, @Context HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    if (!roles.isOLATAdmin()) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
    if (configuration.getLectureEnabled() != null) {
        config.setLectureEnabled(configuration.getLectureEnabled());
    }
    if (configuration.getCalculateAttendanceRate() != null) {
        config.setCalculateAttendanceRate(configuration.getCalculateAttendanceRate());
    }
    if (configuration.getRequiredAttendanceRate() != null) {
        config.setRequiredAttendanceRate(configuration.getRequiredAttendanceRate());
    }
    if (configuration.getOverrideModuleDefault() != null) {
        config.setOverrideModuleDefault(configuration.getOverrideModuleDefault());
    }
    if (configuration.getCourseCalendarSyncEnabled() != null) {
        config.setCourseCalendarSyncEnabled(configuration.getCourseCalendarSyncEnabled());
    }
    if (configuration.getRollCallEnabled() != null) {
        config.setRollCallEnabled(configuration.getRollCallEnabled());
    }
    if (configuration.getTeacherCalendarSyncEnabled() != null) {
        config.setTeacherCalendarSyncEnabled(configuration.getTeacherCalendarSyncEnabled());
    }
    RepositoryEntryLectureConfiguration updatedConfig = lectureService.updateRepositoryEntryLectureConfiguration(config);
    return Response.ok(new RepositoryEntryLectureConfigurationVO(updatedConfig)).build();
}
Also used : RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes)

Example 3 with RepositoryEntryLectureConfiguration

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

the class LectureServiceTest method addTeacher.

@Test
public void addTeacher() {
    Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-1");
    Identity notTeacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-2");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = createMinimalLectureBlock(entry);
    dbInstance.commitAndCloseSession();
    // enable lecture on this entry
    RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
    config.setLectureEnabled(true);
    config = lectureService.updateRepositoryEntryLectureConfiguration(config);
    lectureService.addTeacher(lectureBlock, teacher);
    dbInstance.commitAndCloseSession();
    boolean isTeacher = lectureService.hasLecturesAsTeacher(entry, teacher);
    Assert.assertTrue(isTeacher);
    boolean isNotTeacher = lectureService.hasLecturesAsTeacher(entry, notTeacher);
    Assert.assertFalse(isNotTeacher);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Test(org.junit.Test)

Example 4 with RepositoryEntryLectureConfiguration

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

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 5 with RepositoryEntryLectureConfiguration

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

the class RepositoryEntryLectureConfigurationDAOTest method cloneConfigureLectureConfiguration.

@Test
public void cloneConfigureLectureConfiguration() {
    // create a configuration
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry cloneEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntryLectureConfiguration config = lectureConfigurationDao.createConfiguration(entry);
    config.setLectureEnabled(true);
    config.setOverrideModuleDefault(true);
    config.setCalculateAttendanceRate(Boolean.TRUE);
    config.setRequiredAttendanceRate(0.75d);
    config.setParticipantCalendarSyncEnabled(Boolean.TRUE);
    config.setTeacherCalendarSyncEnabled(Boolean.TRUE);
    RepositoryEntryLectureConfiguration mergedConfig = lectureConfigurationDao.update(config);
    dbInstance.commitAndCloseSession();
    // clone it
    RepositoryEntryLectureConfiguration clonedConfig = lectureConfigurationDao.cloneConfiguration(mergedConfig, cloneEntry);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(clonedConfig);
    RepositoryEntryLectureConfiguration reloadedClonedConfig = lectureConfigurationDao.getConfiguration(cloneEntry);
    Assert.assertEquals(clonedConfig, reloadedClonedConfig);
    Assert.assertEquals(true, reloadedClonedConfig.isLectureEnabled());
    Assert.assertEquals(true, reloadedClonedConfig.isOverrideModuleDefault());
    Assert.assertEquals(Boolean.TRUE, reloadedClonedConfig.getCalculateAttendanceRate());
    Assert.assertEquals(0.75d, reloadedClonedConfig.getRequiredAttendanceRate(), 0.0001);
    Assert.assertEquals(Boolean.TRUE, reloadedClonedConfig.getParticipantCalendarSyncEnabled());
    Assert.assertEquals(Boolean.TRUE, reloadedClonedConfig.getTeacherCalendarSyncEnabled());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Test(org.junit.Test)

Aggregations

RepositoryEntryLectureConfiguration (org.olat.modules.lecture.RepositoryEntryLectureConfiguration)40 RepositoryEntry (org.olat.repository.RepositoryEntry)30 Test (org.junit.Test)26 Identity (org.olat.core.id.Identity)18 LectureBlock (org.olat.modules.lecture.LectureBlock)16 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Group (org.olat.basesecurity.Group)4 Roles (org.olat.core.id.Roles)4 BusinessGroup (org.olat.group.BusinessGroup)4 LectureBlockToGroup (org.olat.modules.lecture.LectureBlockToGroup)4 LectureBlockStatistics (org.olat.modules.lecture.model.LectureBlockStatistics)4 RestSecurityHelper.getRoles (org.olat.restapi.security.RestSecurityHelper.getRoles)4 URI (java.net.URI)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 HttpResponse (org.apache.http.HttpResponse)2