Search in sources :

Example 21 with RepositoryEntryLectureConfiguration

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

the class RepositoryEntryLectureConfigurationDAOTest method isConfigurationEnabledFor.

@Test
public void isConfigurationEnabledFor() {
    // 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);
    // check that the configuration enables the lectures feature
    boolean enabled = lectureConfigurationDao.isConfigurationEnabledFor(entry);
    Assert.assertTrue(enabled);
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Test(org.junit.Test)

Example 22 with RepositoryEntryLectureConfiguration

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

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

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

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

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

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

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

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)

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