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);
}
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();
}
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);
}
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());
}
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());
}
Aggregations