use of org.olat.restapi.support.vo.CourseConfigVO in project openolat by klemens.
the class LecturesBlocksTest method removeRepositoryEntryDefaultGroupToLectureBlock.
@Test
public void removeRepositoryEntryDefaultGroupToLectureBlock() 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();
LectureBlock block = createLectureBlock(entry);
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureService.save(block, Collections.singletonList(defGroup));
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").path(block.getKey().toString()).path("participants").path("repositoryentry").build();
HttpDelete method = conn.createDelete(uri, MediaType.APPLICATION_JSON);
HttpResponse response = conn.execute(method);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
// check the database
List<Group> groups = lectureService.getLectureBlockToGroups(block);
Assert.assertNotNull(groups);
Assert.assertEquals(0, groups.size());
}
use of org.olat.restapi.support.vo.CourseConfigVO in project openolat by klemens.
the class LecturesBlocksTest method putLecturesBlock_autoclosed.
/**
* Check that the done and autoclosed status are set.
*
* @throws IOException
* @throws URISyntaxException
*/
@Test
public void putLecturesBlock_autoclosed() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence", "Course with absence", new CourseConfigVO());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
String externalId = UUID.randomUUID().toString();
LectureBlockVO lectureBlockVo = new LectureBlockVO();
lectureBlockVo.setTitle("A block to close");
lectureBlockVo.setDescription("A description");
lectureBlockVo.setManagedFlagsString("all");
lectureBlockVo.setPlannedLectures(4);
lectureBlockVo.setExternalId(externalId);
lectureBlockVo.setStartDate(new Date());
lectureBlockVo.setEndDate(new Date());
lectureBlockVo.setStatus("done");
lectureBlockVo.setRollCallStatus("autoclosed");
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").build();
HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
conn.addJsonEntity(method, lectureBlockVo);
HttpResponse response = conn.execute(method);
// check the response
Assertions.assertThat(response.getStatusLine().getStatusCode()).isIn(200, 201);
LectureBlockVO blockVo = conn.parse(response.getEntity().getContent(), LectureBlockVO.class);
Assert.assertNotNull(blockVo);
// check the database
LectureBlock dbBlock = lectureService.getLectureBlock(new LectureBlockRefImpl(blockVo.getKey()));
Assert.assertNotNull(dbBlock);
Assert.assertEquals("A block to close", dbBlock.getTitle());
Assert.assertEquals("A description", dbBlock.getDescription());
Assert.assertEquals("all", dbBlock.getManagedFlagsString());
Assert.assertEquals(4, dbBlock.getPlannedLecturesNumber());
Assert.assertEquals(externalId, dbBlock.getExternalId());
Assert.assertNotNull(dbBlock.getStartDate());
Assert.assertNotNull(dbBlock.getEndDate());
Assert.assertEquals(LectureBlockStatus.done, dbBlock.getStatus());
Assert.assertEquals(LectureRollCallStatus.autoclosed, dbBlock.getRollCallStatus());
}
use of org.olat.restapi.support.vo.CourseConfigVO in project openolat by klemens.
the class LecturesBlocksTest method deleteLectureBlock.
@Test
public void deleteLectureBlock() 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();
LectureBlock block = createLectureBlock(entry);
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").path(block.getKey().toString()).build();
HttpDelete method = conn.createDelete(uri, MediaType.APPLICATION_JSON);
HttpResponse response = conn.execute(method);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
LectureBlock deletedBlock = lectureService.getLectureBlock(block);
Assert.assertNull(deletedBlock);
}
use of org.olat.restapi.support.vo.CourseConfigVO in project openolat by klemens.
the class CourseWebService method updateConfiguration.
/**
* Update the course configuration
* @response.representation.200.qname {http://www.example.com}courseConfigVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The metadatas of the created course
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_COURSECONFIGVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course not found
* @param courseId The course resourceable's id
* @param calendar Enable/disable the calendar (value: true/false) (optional)
* @param chat Enable/disable the chat (value: true/false) (optional)
* @param cssLayoutRef Set the custom CSS file for the layout (optional)
* @param efficencyStatement Enable/disable the efficencyStatement (value: true/false) (optional)
* @param glossarySoftkey Set the glossary (optional)
* @param sharedFolderSoftkey Set the shared folder (optional)
* @param request The HTTP request
* @return It returns the XML/Json representation of the <code>CourseConfig</code>
* object representing the course configuration.
*/
@POST
@Path("configuration")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response updateConfiguration(@PathParam("courseId") Long courseId, @FormParam("calendar") Boolean calendar, @FormParam("chat") Boolean chat, @FormParam("cssLayoutRef") String cssLayoutRef, @FormParam("efficencyStatement") Boolean efficencyStatement, @FormParam("glossarySoftkey") String glossarySoftkey, @FormParam("sharedFolderSoftkey") String sharedFolderSoftkey, @Context HttpServletRequest request) {
if (!isAuthor(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
ICourse editedCourse = CourseFactory.openCourseEditSession(courseId);
// change course config
CourseConfig courseConfig = editedCourse.getCourseEnvironment().getCourseConfig();
if (calendar != null) {
courseConfig.setCalendarEnabled(calendar.booleanValue());
}
if (chat != null) {
courseConfig.setChatIsEnabled(chat.booleanValue());
}
if (StringHelper.containsNonWhitespace(cssLayoutRef)) {
courseConfig.setCssLayoutRef(cssLayoutRef);
}
if (efficencyStatement != null) {
courseConfig.setEfficencyStatementIsEnabled(efficencyStatement.booleanValue());
}
if (StringHelper.containsNonWhitespace(glossarySoftkey)) {
courseConfig.setGlossarySoftKey(glossarySoftkey);
}
if (StringHelper.containsNonWhitespace(sharedFolderSoftkey)) {
courseConfig.setSharedFolderSoftkey(sharedFolderSoftkey);
}
CourseFactory.setCourseConfig(editedCourse.getResourceableId(), courseConfig);
CourseFactory.closeCourseEditSession(editedCourse.getResourceableId(), true);
CourseConfigVO vo = ObjectFactory.getConfig(editedCourse);
return Response.ok(vo).build();
}
Aggregations