Search in sources :

Example 31 with RepositoryEntryLectureConfiguration

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

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

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

the class LectureServiceTest method getRepositoryEntryLectureConfiguration.

@Test
public void getRepositoryEntryLectureConfiguration() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(config);
    Assert.assertEquals(entry, config.getEntry());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Test(org.junit.Test)

Example 33 with RepositoryEntryLectureConfiguration

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

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)

Example 34 with RepositoryEntryLectureConfiguration

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

the class RepositoryEntryLectureConfigurationDAOTest method getRepositoryEntryLectureConfiguration_lectureBlock.

@Test
public void getRepositoryEntryLectureConfiguration_lectureBlock() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntryLectureConfiguration config = lectureConfigurationDao.createConfiguration(entry);
    dbInstance.commit();
    LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
    lectureBlock.setStartDate(new Date());
    lectureBlock.setEndDate(new Date());
    lectureBlock.setTitle("Hello lecturers");
    lectureBlock = lectureBlockDao.update(lectureBlock);
    dbInstance.commitAndCloseSession();
    // get the configuration
    RepositoryEntryLectureConfiguration reloadedConfig = lectureConfigurationDao.getConfiguration(lectureBlock);
    Assert.assertEquals(config, reloadedConfig);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Date(java.util.Date) Test(org.junit.Test)

Example 35 with RepositoryEntryLectureConfiguration

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

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)

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