use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.
the class LectureServiceTest method createMinimalLectureBlock.
private LectureBlock createMinimalLectureBlock(RepositoryEntry entry) {
LectureBlock lectureBlock = lectureService.createLectureBlock(entry);
lectureBlock.setStartDate(new Date());
lectureBlock.setEndDate(new Date());
lectureBlock.setTitle("Hello lecturers");
lectureBlock.setPlannedLecturesNumber(4);
return lectureService.save(lectureBlock, null);
}
use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.
the class LectureServiceTest method getParticipants.
@Test
public void getParticipants() {
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-4-1");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("participant-4-2");
// a lecture block
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = createMinimalLectureBlock(entry);
// add 2 participants to the "course"
repositoryEntryRelationDAO.addRole(participant1, entry, GroupRole.participant.name());
repositoryEntryRelationDAO.addRole(participant2, entry, GroupRole.participant.name());
dbInstance.commitAndCloseSession();
// add the course to the lecture
Group defGroup = repositoryService.getDefaultGroup(entry);
lectureBlock = lectureService.save(lectureBlock, Collections.singletonList(defGroup));
dbInstance.commitAndCloseSession();
List<Identity> participants = lectureService.getParticipants(lectureBlock);
Assert.assertNotNull(participants);
Assert.assertEquals(2, participants.size());
Assert.assertTrue(participants.contains(participant1));
Assert.assertTrue(participants.contains(participant2));
}
use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.
the class ReasonDAOTest method isReasonInUse.
@Test
public void isReasonInUse() {
// create a reason
String title = "3. reason";
String description = "Use it";
Reason reason = reasonDao.createReason(title, description);
dbInstance.commitAndCloseSession();
// add to a lecture block
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
lectureBlock.setStartDate(new Date());
lectureBlock.setEndDate(new Date());
lectureBlock.setTitle("Hello lecturers");
lectureBlock.setReasonEffectiveEnd(reason);
lectureBlock = lectureBlockDao.update(lectureBlock);
dbInstance.commitAndCloseSession();
// check
boolean inUse = reasonDao.isReasonInUse(reason);
Assert.assertTrue(inUse);
}
use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.
the class LecturesBlockRollCallTest method getAndUpdateSupervisorDate.
@Test
public void getAndUpdateSupervisorDate() throws IOException, URISyntaxException {
// a closed lecture block
LectureBlock lectureBlock = createMinimalLectureBlock(3);
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
dbInstance.commit();
List<Integer> absences = Arrays.asList(1, 2);
LectureBlockRollCall rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, id, null, null, null, absences);
dbInstance.commitAndCloseSession();
// POST REST call
LectureBlockRollCallVO rollCallVo = new LectureBlockRollCallVO();
rollCallVo.setKey(rollCall.getKey());
rollCallVo.setLecturesAbsentNumber(rollCall.getLecturesAbsentNumber());
rollCallVo.setLecturesAttendedNumber(rollCall.getLecturesAttendedNumber());
rollCallVo.setComment(rollCall.getComment());
rollCallVo.setAbsenceReason(rollCall.getAbsenceReason());
rollCallVo.setAbsenceAuthorized(rollCall.getAbsenceAuthorized());
rollCallVo.setAbsenceSupervisorNotificationDate(new Date());
rollCallVo.setIdentityKey(id.getKey());
rollCallVo.setLectureBlockKey(lectureBlock.getKey());
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("lectures").path("rollcalls").build();
HttpPost postMethod = conn.createPost(uri, MediaType.APPLICATION_JSON);
conn.addJsonEntity(postMethod, rollCallVo);
HttpResponse response = conn.execute(postMethod);
// check the response
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
LectureBlockRollCallVO updatedRollCallVo = conn.parse(response, LectureBlockRollCallVO.class);
Assert.assertNotNull(updatedRollCallVo);
Assert.assertEquals(rollCall.getKey(), updatedRollCallVo.getKey());
Assert.assertNotNull(updatedRollCallVo.getAbsenceSupervisorNotificationDate());
// reload the roll call from the database
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setRollCallKey(rollCall.getKey());
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertNotNull(rollCalls);
Assert.assertEquals(1, rollCalls.size());
LectureBlockRollCall updatedRollCall = rollCalls.get(0);
Assert.assertEquals(rollCall, updatedRollCall);
Assert.assertNotNull(updatedRollCall.getAbsenceSupervisorNotificationDate());
}
use of org.olat.modules.lecture.LectureBlock 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());
}
Aggregations