use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
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();
}
use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class CoursesWebService method createEmptyCourse.
/**
* Creates an empty course
* @response.representation.200.qname {http://www.example.com}courseVO
* @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_COURSEVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param courseVo The course
* @param request The HTTP request
* @return It returns the newly created course
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response createEmptyCourse(CourseVO courseVo, @Context HttpServletRequest request) {
if (!isAuthor(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
UserRequest ureq = getUserRequest(request);
CourseConfigVO configVO = new CourseConfigVO();
ICourse course = createEmptyCourse(ureq.getIdentity(), courseVo.getTitle(), courseVo.getTitle(), courseVo.getTitle(), courseVo.getDescription(), courseVo.getSoftKey(), RepositoryEntry.ACC_OWNERS, false, courseVo.getAuthors(), courseVo.getLocation(), courseVo.getExternalId(), courseVo.getExternalRef(), courseVo.getManagedFlags(), configVO);
CourseVO vo = ObjectFactory.get(course);
return Response.ok(vo).build();
}
use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class LecturesBlocksRootTest method getLecturesBlock_date.
@Test
public void getLecturesBlock_date() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-root-1");
ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence", "Course with absence", new CourseConfigVO());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
LectureBlock block = createLectureBlock(entry);
dbInstance.commit();
lectureService.addTeacher(block, author);
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
String date = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss").format(new Date());
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("lectures").queryParam("date", date).build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
List<LectureBlockVO> voList = parseLectureBlockArray(response.getEntity().getContent());
Assert.assertNotNull(voList);
Assert.assertFalse(voList.isEmpty());
LectureBlockVO lectureBlockVo = null;
for (LectureBlockVO vo : voList) {
if (vo.getKey().equals(block.getKey())) {
lectureBlockVo = vo;
}
}
Assert.assertNotNull(lectureBlockVo);
Assert.assertEquals(block.getKey(), lectureBlockVo.getKey());
Assert.assertEquals(entry.getKey(), lectureBlockVo.getRepoEntryKey());
}
use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class LecturesBlocksRootTest method getLecturesBlock.
@Test
public void getLecturesBlock() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-root-all");
ICourse course = CoursesWebService.createEmptyCourse(author, "Course with absence", "Course with absence", new CourseConfigVO());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
LectureBlock block = createLectureBlock(entry);
dbInstance.commit();
lectureService.addTeacher(block, author);
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("lectures").build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
List<LectureBlockVO> voList = parseLectureBlockArray(response.getEntity().getContent());
Assert.assertNotNull(voList);
Assert.assertFalse(voList.isEmpty());
LectureBlockVO lectureBlockVo = null;
for (LectureBlockVO vo : voList) {
if (vo.getKey().equals(block.getKey())) {
lectureBlockVo = vo;
}
}
Assert.assertNotNull(lectureBlockVo);
Assert.assertEquals(block.getKey(), lectureBlockVo.getKey());
Assert.assertEquals(entry.getKey(), lectureBlockVo.getRepoEntryKey());
}
use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class CourseTest method testGetCourseConfig.
@Test
public void testGetCourseConfig() throws IOException, URISyntaxException {
assertTrue("Cannot login as administrator", conn.login("administrator", "openolat"));
URI uri = conn.getContextURI().path("repo").path("courses").path(course1.getResourceableId().toString()).path("configuration").build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
CourseConfigVO courseConfig = conn.parse(response, CourseConfigVO.class);
Assert.assertNotNull(courseConfig);
Assert.assertNotNull(courseConfig.getCssLayoutRef());
Assert.assertNotNull(courseConfig.getCalendar());
Assert.assertNotNull(courseConfig.getChat());
Assert.assertNotNull(courseConfig.getEfficencyStatement());
}
Aggregations