Search in sources :

Example 36 with RepositoryEntryLectureConfiguration

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

the class RepositoryEntryLectureConfigurationDAOTest method deleteConfiguration_byRepositoryEntry.

@Test
public void deleteConfiguration_byRepositoryEntry() {
    // create a configuration
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntryLectureConfiguration config = lectureConfigurationDao.createConfiguration(entry);
    config.setLectureEnabled(true);
    RepositoryEntryLectureConfiguration mergedConfig = lectureConfigurationDao.update(config);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mergedConfig);
    // delete the configuration
    lectureConfigurationDao.deleteConfiguration(entry);
    dbInstance.commitAndCloseSession();
    // check that the configuration is really deleted
    RepositoryEntryLectureConfiguration deletedConfig = lectureConfigurationDao.getConfiguration(entry);
    Assert.assertNull(deletedConfig);
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Test(org.junit.Test)

Example 37 with RepositoryEntryLectureConfiguration

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

the class RepositoryEntryLectureConfigurationDAOTest method createLectureConfiguration.

@Test
public void createLectureConfiguration() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntryLectureConfiguration config = lectureConfigurationDao.createConfiguration(entry);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(config);
    Assert.assertNotNull(config.getKey());
    Assert.assertNotNull(config.getCreationDate());
    Assert.assertNotNull(config.getLastModified());
    Assert.assertEquals(entry, config.getEntry());
    Assert.assertFalse(config.isLectureEnabled());
    Assert.assertFalse(config.isOverrideModuleDefault());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Test(org.junit.Test)

Example 38 with RepositoryEntryLectureConfiguration

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

the class LectureServiceImpl method getParticipantsLecturesStatistics.

@Override
public List<LectureBlockStatistics> getParticipantsLecturesStatistics(RepositoryEntry entry) {
    boolean authorizedAbsenceEnabled = lectureModule.isAuthorizedAbsenceEnabled();
    boolean calculateAttendanceRate = lectureModule.isRollCallCalculateAttendanceRateDefaultEnabled();
    boolean absenceDefaultAuthorized = lectureModule.isAbsenceDefaultAuthorized();
    boolean countAuthorizedAbsenceAsAttendant = lectureModule.isCountAuthorizedAbsenceAsAttendant();
    double defaultRequiredAttendanceRate = lectureModule.getRequiredAttendanceRateDefault();
    RepositoryEntryLectureConfiguration config = getRepositoryEntryLectureConfiguration(entry);
    return lectureBlockRollCallDao.getStatistics(entry, config, authorizedAbsenceEnabled, absenceDefaultAuthorized, countAuthorizedAbsenceAsAttendant, calculateAttendanceRate, defaultRequiredAttendanceRate);
}
Also used : RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration)

Example 39 with RepositoryEntryLectureConfiguration

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

the class LectureServiceImpl method syncCalendars.

@Override
public void syncCalendars(RepositoryEntry entry) {
    RepositoryEntryLectureConfiguration config = getRepositoryEntryLectureConfiguration(entry);
    if (ConfigurationHelper.isSyncTeacherCalendarEnabled(config, lectureModule)) {
        List<LectureBlock> blocks = getLectureBlocks(entry);
        for (LectureBlock block : blocks) {
            List<Identity> teachers = getTeachers(block);
            syncInternalCalendar(block, teachers);
        }
    } else {
        unsyncTeachersCalendar(entry);
    }
    if (ConfigurationHelper.isSyncCourseCalendarEnabled(config, lectureModule)) {
        fullSyncCourseCalendar(config.getEntry());
    } else {
        unsyncInternalCalendar(config.getEntry());
    }
/*if(ConfigurationHelper.isSyncParticipantCalendarEnabled(config, lectureModule)) {
			List<LectureBlock> blocks = getLectureBlocks(entry);
			for(LectureBlock block:blocks) {
				List<Identity> participants = getParticipants(block);
				syncInternalCalendar(block, participants);
			}
		} else {
			unsyncParticipantsCalendar(entry);
		}*/
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Identity(org.olat.core.id.Identity)

Example 40 with RepositoryEntryLectureConfiguration

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

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)

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