Search in sources :

Example 16 with RepositoryEntryLectureConfiguration

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

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

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

the class LectureBlocksWebService method getConfiguration.

/**
 * Return the configuration of the 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 configuration of the lecture's feature
 * @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 httpRequest The HTTP request
 * @return The configuration
 */
@GET
@Path("configuration")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getConfiguration(@Context HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    if (!roles.isOLATAdmin()) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    RepositoryEntryLectureConfiguration config = lectureService.getRepositoryEntryLectureConfiguration(entry);
    RepositoryEntryLectureConfigurationVO configVo;
    if (config == null) {
        configVo = new RepositoryEntryLectureConfigurationVO();
    } else {
        configVo = new RepositoryEntryLectureConfigurationVO(config);
    }
    return Response.ok(configVo).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) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 18 with RepositoryEntryLectureConfiguration

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

the class LectureBlockDAOTest method hasLecturesAsTeacher.

@Test
public void hasLecturesAsTeacher() {
    Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-1");
    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 = lectureBlockDao.hasLecturesAsTeacher(entry, teacher);
    Assert.assertTrue(isTeacher);
}
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 19 with RepositoryEntryLectureConfiguration

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

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

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

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)

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