Search in sources :

Example 1 with RepositoryEntryLectureConfigurationVO

use of org.olat.modules.lecture.restapi.RepositoryEntryLectureConfigurationVO 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);
}
Also used : CourseConfigVO(org.olat.restapi.support.vo.CourseConfigVO) RepositoryEntryLectureConfigurationVO(org.olat.modules.lecture.restapi.RepositoryEntryLectureConfigurationVO) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) URI(java.net.URI) Test(org.junit.Test)

Example 2 with RepositoryEntryLectureConfigurationVO

use of org.olat.modules.lecture.restapi.RepositoryEntryLectureConfigurationVO 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());
}
Also used : CourseConfigVO(org.olat.restapi.support.vo.CourseConfigVO) HttpPost(org.apache.http.client.methods.HttpPost) RepositoryEntryLectureConfigurationVO(org.olat.modules.lecture.restapi.RepositoryEntryLectureConfigurationVO) HttpResponse(org.apache.http.HttpResponse) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) URI(java.net.URI) Test(org.junit.Test)

Example 3 with RepositoryEntryLectureConfigurationVO

use of org.olat.modules.lecture.restapi.RepositoryEntryLectureConfigurationVO in project OpenOLAT by OpenOLAT.

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());
}
Also used : CourseConfigVO(org.olat.restapi.support.vo.CourseConfigVO) HttpPost(org.apache.http.client.methods.HttpPost) RepositoryEntryLectureConfigurationVO(org.olat.modules.lecture.restapi.RepositoryEntryLectureConfigurationVO) HttpResponse(org.apache.http.HttpResponse) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) URI(java.net.URI) Test(org.junit.Test)

Example 4 with RepositoryEntryLectureConfigurationVO

use of org.olat.modules.lecture.restapi.RepositoryEntryLectureConfigurationVO in project openolat by klemens.

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);
}
Also used : CourseConfigVO(org.olat.restapi.support.vo.CourseConfigVO) RepositoryEntryLectureConfigurationVO(org.olat.modules.lecture.restapi.RepositoryEntryLectureConfigurationVO) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) URI(java.net.URI) Test(org.junit.Test)

Aggregations

URI (java.net.URI)4 HttpResponse (org.apache.http.HttpResponse)4 Test (org.junit.Test)4 Identity (org.olat.core.id.Identity)4 ICourse (org.olat.course.ICourse)4 RepositoryEntryLectureConfigurationVO (org.olat.modules.lecture.restapi.RepositoryEntryLectureConfigurationVO)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 CourseConfigVO (org.olat.restapi.support.vo.CourseConfigVO)4 HttpGet (org.apache.http.client.methods.HttpGet)2 HttpPost (org.apache.http.client.methods.HttpPost)2 RepositoryEntryLectureConfiguration (org.olat.modules.lecture.RepositoryEntryLectureConfiguration)2