use of org.olat.restapi.support.vo.CourseConfigVO in project openolat by klemens.
the class LecturesBlocksTest method getLectureBlock.
@Test
public void getLectureBlock() 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();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
LectureBlockVO blockVo = conn.parse(response, LectureBlockVO.class);
Assert.assertNotNull(blockVo);
Assert.assertEquals(block.getKey(), blockVo.getKey());
Assert.assertEquals(entry.getKey(), blockVo.getRepoEntryKey());
}
use of org.olat.restapi.support.vo.CourseConfigVO in project openolat by klemens.
the class LecturesBlocksTest method getLecturesBlock_course.
/**
* Get the list of lecture block through the course.
*
* @throws IOException
* @throws URISyntaxException
*/
@Test
public void getLecturesBlock_course() 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();
LectureBlock block = createLectureBlock(entry);
dbInstance.commit();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("courses").path(course.getResourceableId().toString()).path("lectureblocks").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.assertEquals(1, voList.size());
LectureBlockVO blockVo = voList.get(0);
Assert.assertEquals(block.getKey(), blockVo.getKey());
Assert.assertEquals(entry.getKey(), blockVo.getRepoEntryKey());
}
use of org.olat.restapi.support.vo.CourseConfigVO in project openolat by klemens.
the class LecturesBlocksTest method addRepositoryEntryDefaultGroupToLectureBlock.
@Test
public void addRepositoryEntryDefaultGroupToLectureBlock() 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()).path("participants").path("repositoryentry").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<Group> groups = lectureService.getLectureBlockToGroups(block);
Assert.assertNotNull(groups);
Assert.assertEquals(1, groups.size());
Group defGroup = repositoryService.getDefaultGroup(entry);
Assert.assertEquals(defGroup, groups.get(0));
}
use of org.olat.restapi.support.vo.CourseConfigVO in project openolat by klemens.
the class LecturesBlocksTest method putLecturesBlock_repository.
@Test
public void putLecturesBlock_repository() 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("New block");
lectureBlockVo.setDescription("A little description");
lectureBlockVo.setComment("A comment");
lectureBlockVo.setLocation("The secret location");
lectureBlockVo.setManagedFlagsString("all");
lectureBlockVo.setPreparation("Lot of");
lectureBlockVo.setPlannedLectures(4);
lectureBlockVo.setExternalId(externalId);
lectureBlockVo.setStartDate(new Date());
lectureBlockVo.setEndDate(new Date());
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);
Assert.assertEquals(entry.getKey(), blockVo.getRepoEntryKey());
Assert.assertEquals("New block", blockVo.getTitle());
Assert.assertEquals("A little description", blockVo.getDescription());
Assert.assertEquals("A comment", blockVo.getComment());
Assert.assertEquals("The secret location", blockVo.getLocation());
Assert.assertEquals("all", blockVo.getManagedFlagsString());
Assert.assertEquals(4, blockVo.getPlannedLectures());
Assert.assertEquals(externalId, blockVo.getExternalId());
Assert.assertNotNull(blockVo.getStartDate());
Assert.assertNotNull(blockVo.getEndDate());
// check the database
LectureBlock dbBlock = lectureService.getLectureBlock(new LectureBlockRefImpl(blockVo.getKey()));
Assert.assertNotNull(dbBlock);
Assert.assertEquals("New block", dbBlock.getTitle());
Assert.assertEquals("A little description", dbBlock.getDescription());
Assert.assertEquals("A comment", dbBlock.getComment());
Assert.assertEquals("The secret location", dbBlock.getLocation());
Assert.assertEquals("all", dbBlock.getManagedFlagsString());
Assert.assertEquals(4, dbBlock.getPlannedLecturesNumber());
Assert.assertEquals(externalId, dbBlock.getExternalId());
Assert.assertNotNull(dbBlock.getStartDate());
Assert.assertNotNull(dbBlock.getEndDate());
}
use of org.olat.restapi.support.vo.CourseConfigVO in project openolat by klemens.
the class LecturesBlocksTest method updateLecturesBlockConfiguration.
@Test
public void updateLecturesBlockConfiguration() 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"));
RepositoryEntryLectureConfigurationVO configVo = new RepositoryEntryLectureConfigurationVO();
configVo.setLectureEnabled(Boolean.TRUE);
configVo.setCalculateAttendanceRate(Boolean.TRUE);
configVo.setOverrideModuleDefault(Boolean.TRUE);
configVo.setCourseCalendarSyncEnabled(Boolean.TRUE);
configVo.setRequiredAttendanceRate(34.0d);
configVo.setRollCallEnabled(Boolean.TRUE);
configVo.setTeacherCalendarSyncEnabled(Boolean.TRUE);
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("entries").path(entry.getKey().toString()).path("lectureblocks").path("configuration").build();
HttpPost method = conn.createPost(uri, MediaType.APPLICATION_JSON);
conn.addJsonEntity(method, configVo);
HttpResponse response = conn.execute(method);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
RepositoryEntryLectureConfigurationVO updateConfigVo = conn.parse(response, RepositoryEntryLectureConfigurationVO.class);
Assert.assertNotNull(updateConfigVo);
Assert.assertEquals(Boolean.TRUE, updateConfigVo.getLectureEnabled());
Assert.assertEquals(Boolean.TRUE, updateConfigVo.getCalculateAttendanceRate());
Assert.assertEquals(Boolean.TRUE, updateConfigVo.getOverrideModuleDefault());
Assert.assertEquals(Boolean.TRUE, updateConfigVo.getCourseCalendarSyncEnabled());
Assert.assertEquals(34.0d, updateConfigVo.getRequiredAttendanceRate(), 0000.1);
Assert.assertEquals(Boolean.TRUE, updateConfigVo.getRollCallEnabled());
Assert.assertEquals(Boolean.TRUE, updateConfigVo.getTeacherCalendarSyncEnabled());
// check the database
RepositoryEntryLectureConfiguration dbConfig = lectureService.getRepositoryEntryLectureConfiguration(entry);
Assert.assertNotNull(dbConfig);
Assert.assertTrue(dbConfig.isLectureEnabled());
Assert.assertEquals(Boolean.TRUE, dbConfig.getCalculateAttendanceRate());
Assert.assertTrue(dbConfig.isOverrideModuleDefault());
Assert.assertEquals(Boolean.TRUE, dbConfig.getCourseCalendarSyncEnabled());
Assert.assertEquals(34.0d, dbConfig.getRequiredAttendanceRate(), 0000.1);
Assert.assertEquals(Boolean.TRUE, dbConfig.getRollCallEnabled());
Assert.assertEquals(Boolean.TRUE, dbConfig.getTeacherCalendarSyncEnabled());
}
Aggregations