Search in sources :

Example 11 with RepositoryEntryLectureConfiguration

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

Example 12 with RepositoryEntryLectureConfiguration

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

the class RepositoryEntryLectureConfigurationDAOTest method createAndConfigureLectureConfiguration.

@Test
public void createAndConfigureLectureConfiguration() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntryLectureConfiguration config = lectureConfigurationDao.createConfiguration(entry);
    dbInstance.commitAndCloseSession();
    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();
    RepositoryEntryLectureConfiguration reloadedConfig = lectureConfigurationDao.getConfiguration(entry);
    Assert.assertEquals(config, reloadedConfig);
    Assert.assertEquals(mergedConfig, reloadedConfig);
    Assert.assertEquals(true, reloadedConfig.isLectureEnabled());
    Assert.assertEquals(true, reloadedConfig.isOverrideModuleDefault());
    Assert.assertEquals(Boolean.TRUE, reloadedConfig.getCalculateAttendanceRate());
    Assert.assertEquals(0.75d, reloadedConfig.getRequiredAttendanceRate(), 0.0001);
    Assert.assertEquals(Boolean.TRUE, reloadedConfig.getParticipantCalendarSyncEnabled());
    Assert.assertEquals(Boolean.TRUE, reloadedConfig.getTeacherCalendarSyncEnabled());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Test(org.junit.Test)

Example 13 with RepositoryEntryLectureConfiguration

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

the class LecturesBlocksTest method updateLecturesBlockConfiguration.

@Test
public void updateLecturesBlockConfiguration() throws IOException, URISyntaxException {
    Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
    ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence config", "Course with absence configuration", new CourseConfigVO());
    RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    dbInstance.commit();
    RestConnection conn = new RestConnection();
    Assert.assertTrue(conn.login("administrator", "openolat"));
    RepositoryEntryLectureConfigurationVO configVo = new RepositoryEntryLectureConfigurationVO();
    configVo.setLectureEnabled(Boolean.TRUE);
    configVo.setCalculateAttendanceRate(Boolean.TRUE);
    configVo.setOverrideModuleDefault(Boolean.TRUE);
    configVo.setCourseCalendarSyncEnabled(Boolean.TRUE);
    configVo.setRequiredAttendanceRate(34.0d);
    configVo.setRollCallEnabled(Boolean.TRUE);
    configVo.setTeacherCalendarSyncEnabled(Boolean.TRUE);
    URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").path("configuration").build();
    HttpPost method = conn.createPost(uri, MediaType.APPLICATION_JSON);
    conn.addJsonEntity(method, configVo);
    HttpResponse response = conn.execute(method);
    // check the response
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());
    RepositoryEntryLectureConfigurationVO updateConfigVo = conn.parse(response, RepositoryEntryLectureConfigurationVO.class);
    Assert.assertNotNull(updateConfigVo);
    Assert.assertEquals(Boolean.TRUE, updateConfigVo.getLectureEnabled());
    Assert.assertEquals(Boolean.TRUE, updateConfigVo.getCalculateAttendanceRate());
    Assert.assertEquals(Boolean.TRUE, updateConfigVo.getOverrideModuleDefault());
    Assert.assertEquals(Boolean.TRUE, updateConfigVo.getCourseCalendarSyncEnabled());
    Assert.assertEquals(34.0d, updateConfigVo.getRequiredAttendanceRate(), 0000.1);
    Assert.assertEquals(Boolean.TRUE, updateConfigVo.getRollCallEnabled());
    Assert.assertEquals(Boolean.TRUE, updateConfigVo.getTeacherCalendarSyncEnabled());
    // check the database
    RepositoryEntryLectureConfiguration dbConfig = lectureService.getRepositoryEntryLectureConfiguration(entry);
    Assert.assertNotNull(dbConfig);
    Assert.assertTrue(dbConfig.isLectureEnabled());
    Assert.assertEquals(Boolean.TRUE, dbConfig.getCalculateAttendanceRate());
    Assert.assertTrue(dbConfig.isOverrideModuleDefault());
    Assert.assertEquals(Boolean.TRUE, dbConfig.getCourseCalendarSyncEnabled());
    Assert.assertEquals(34.0d, dbConfig.getRequiredAttendanceRate(), 0000.1);
    Assert.assertEquals(Boolean.TRUE, dbConfig.getRollCallEnabled());
    Assert.assertEquals(Boolean.TRUE, dbConfig.getTeacherCalendarSyncEnabled());
}
Also used : CourseConfigVO(org.olat.restapi.support.vo.CourseConfigVO) HttpPost(org.apache.http.client.methods.HttpPost) RepositoryEntryLectureConfigurationVO(org.olat.modules.lecture.restapi.RepositoryEntryLectureConfigurationVO) HttpResponse(org.apache.http.HttpResponse) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) URI(java.net.URI) Test(org.junit.Test)

Example 14 with RepositoryEntryLectureConfiguration

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

the class LectureServiceImpl method getRepositoryEntryLectureConfiguration.

@Override
public RepositoryEntryLectureConfiguration getRepositoryEntryLectureConfiguration(RepositoryEntry entry) {
    RepositoryEntryLectureConfiguration config = lectureConfigurationDao.getConfiguration(entry);
    if (config == null) {
        RepositoryEntry reloadedEntry = repositoryEntryDao.loadForUpdate(entry);
        config = lectureConfigurationDao.getConfiguration(entry);
        if (config == null) {
            config = lectureConfigurationDao.createConfiguration(reloadedEntry);
        }
        dbInstance.commit();
    }
    return config;
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration)

Example 15 with RepositoryEntryLectureConfiguration

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

the class LectureServiceImpl method syncCalendars.

@Override
public void syncCalendars(LectureBlock lectureBlock) {
    RepositoryEntryLectureConfiguration config = lectureConfigurationDao.getConfiguration(lectureBlock);
    if (ConfigurationHelper.isSyncTeacherCalendarEnabled(config, lectureModule)) {
        List<Identity> teachers = getTeachers(lectureBlock);
        syncInternalCalendar(lectureBlock, teachers);
    } else {
        List<Identity> teachers = getTeachers(lectureBlock);
        unsyncInternalCalendar(lectureBlock, teachers);
    }
    if (ConfigurationHelper.isSyncCourseCalendarEnabled(config, lectureModule)) {
        syncCourseCalendar(lectureBlock, config.getEntry());
    } else {
        unsyncCourseCalendar(lectureBlock, config.getEntry());
    }
/*if(ConfigurationHelper.isSyncParticipantCalendarEnabled(config, lectureModule)) {
			List<Identity> participants = getParticipants(lectureBlock);
			syncInternalCalendar(lectureBlock, participants);
		} else {
			List<Identity> participants = getParticipants(lectureBlock);
			unsyncInternalCalendar(lectureBlock, participants);
		}*/
}
Also used : RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Identity(org.olat.core.id.Identity)

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