use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
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.course.ICourse in project OpenOLAT by OpenOLAT.
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.course.ICourse 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.course.ICourse 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.course.ICourse 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));
}
Aggregations