use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class LecturesBlocksTest method addTeacherToLectureBlock.
@Test
public void addTeacherToLectureBlock() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
Identity teacher = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-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()).path("teachers").path(teacher.getKey().toString()).build();
HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
// check the database
List<Identity> teachers = lectureService.getTeachers(block);
Assert.assertTrue(teachers.contains(teacher));
}
use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class LecturesBlocksTest method getLecturesBlockConfiguration.
@Test
public void getLecturesBlockConfiguration() 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();
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("configuration").build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
RepositoryEntryLectureConfigurationVO configVo = conn.parse(response, RepositoryEntryLectureConfigurationVO.class);
Assert.assertNotNull(configVo);
}
use of org.olat.restapi.support.vo.CourseConfigVO in project OpenOLAT by OpenOLAT.
the class LecturesBlocksTest method removeTeacherToLectureBlock.
@Test
public void removeTeacherToLectureBlock() throws IOException, URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("lect-1");
Identity teacher1 = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-2");
Identity teacher2 = JunitTestHelper.createAndPersistIdentityAsRndUser("teacher-3");
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();
lectureService.addTeacher(block, teacher1);
lectureService.addTeacher(block, teacher2);
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("teachers").path(teacher1.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());
EntityUtils.consume(response.getEntity());
// check the database
List<Identity> teachers = lectureService.getTeachers(block);
Assert.assertEquals(1, teachers.size());
Assert.assertFalse(teachers.contains(teacher1));
Assert.assertTrue(teachers.contains(teacher2));
}
use of org.olat.restapi.support.vo.CourseConfigVO in project openolat by klemens.
the class CourseCalendarTest method putCalendarEvents.
@Test
public void putCalendarEvents() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
Identity admin = BaseSecurityManager.getInstance().findIdentityByName("administrator");
Assert.assertTrue(conn.login("administrator", "openolat"));
CourseConfigVO config = new CourseConfigVO();
config.setCalendar(Boolean.TRUE);
ICourse course = CoursesWebService.createEmptyCourse(admin, "Course with calendar", "Course with calendar", config);
dbInstance.commitAndCloseSession();
// create an event
EventVO event1 = new EventVO();
Calendar cal = Calendar.getInstance();
event1.setBegin(cal.getTime());
cal.add(Calendar.HOUR_OF_DAY, 1);
event1.setEnd(cal.getTime());
String subject1 = UUID.randomUUID().toString();
event1.setSubject(subject1);
EventVO event2 = new EventVO();
event2.setBegin(cal.getTime());
cal.add(Calendar.HOUR_OF_DAY, 1);
event2.setEnd(cal.getTime());
String subject2 = UUID.randomUUID().toString();
event2.setSubject(subject2);
EventVO[] newEvents = new EventVO[2];
newEvents[0] = event1;
newEvents[1] = event2;
URI eventUri = UriBuilder.fromUri(getContextURI()).path("repo").path("courses").path(course.getResourceableId().toString()).path("calendar").path("events").build();
HttpPut putEventMethod = conn.createPut(eventUri, MediaType.APPLICATION_JSON, true);
conn.addJsonEntity(putEventMethod, newEvents);
HttpResponse putEventResponse = conn.execute(putEventMethod);
assertEquals(200, putEventResponse.getStatusLine().getStatusCode());
EntityUtils.consume(putEventResponse.getEntity());
// check if the event is saved
KalendarRenderWrapper calendarWrapper = calendarManager.getCourseCalendar(course);
Collection<KalendarEvent> savedEvents = calendarWrapper.getKalendar().getEvents();
boolean found1 = false;
boolean found2 = false;
for (KalendarEvent savedEvent : savedEvents) {
if (subject1.equals(savedEvent.getSubject())) {
found1 = true;
} else if (subject2.equals(savedEvent.getSubject())) {
found2 = true;
}
}
Assert.assertTrue(found1);
Assert.assertTrue(found2);
conn.shutdown();
}
use of org.olat.restapi.support.vo.CourseConfigVO in project openolat by klemens.
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