use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAOTest method adaptLectures_removeAbsences.
@Test
public void adaptLectures_removeAbsences() {
LectureBlock lectureBlock = createMinimalLectureBlock(4);
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
dbInstance.commitAndCloseSession();
List<Integer> absences = Arrays.asList(0, 1, 2, 3);
LectureBlockRollCall rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, id, null, null, null, absences);
dbInstance.commitAndCloseSession();
LectureBlockRollCall reloadRollCall = lectureBlockRollCallDao.loadByKey(rollCall.getKey());
Assert.assertNotNull(reloadRollCall);
Assert.assertEquals(4, reloadRollCall.getLecturesAbsentNumber());
// adapt the number of lectures
LectureBlockRollCall adaptedCall = lectureBlockRollCallDao.adaptLecture(lectureBlock, reloadRollCall, 2, id);
dbInstance.commitAndCloseSession();
// check absence
Assert.assertEquals(2, adaptedCall.getLecturesAbsentNumber());
List<Integer> absenceList = adaptedCall.getLecturesAbsentList();
Assert.assertNotNull(absenceList);
Assert.assertEquals(2, absenceList.size());
Assert.assertEquals(0, absenceList.get(0).intValue());
Assert.assertEquals(1, absenceList.get(1).intValue());
// check attendee
Assert.assertEquals(0, reloadRollCall.getLecturesAttendedNumber());
List<Integer> attendeeList = reloadRollCall.getLecturesAttendedList();
Assert.assertNotNull(attendeeList);
Assert.assertEquals(0, attendeeList.size());
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAOTest method createAndLoadRollCall.
@Test
public void createAndLoadRollCall() {
LectureBlock lectureBlock = createMinimalLectureBlock(2);
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
dbInstance.commitAndCloseSession();
LectureBlockRollCall rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, id, null, null, null, null);
dbInstance.commitAndCloseSession();
LectureBlockRollCall reloadRollCall = lectureBlockRollCallDao.loadByKey(rollCall.getKey());
Assert.assertNotNull(reloadRollCall);
Assert.assertNotNull(reloadRollCall.getKey());
Assert.assertNotNull(reloadRollCall.getCreationDate());
Assert.assertNotNull(reloadRollCall.getLastModified());
Assert.assertEquals(rollCall, reloadRollCall);
Assert.assertEquals(lectureBlock, reloadRollCall.getLectureBlock());
Assert.assertEquals(id, reloadRollCall.getIdentity());
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LecturesBlockRollCallTest method getRollCallByKey.
@Test
public void getRollCallByKey() 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();
// GET REST call
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("lectures").path("rollcalls").path(rollCall.getKey().toString()).build();
HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
LectureBlockRollCallVO rollCallVo = conn.parse(response, LectureBlockRollCallVO.class);
Assert.assertNotNull(rollCallVo);
Assert.assertEquals(rollCall.getKey(), rollCallVo.getKey());
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LecturesBlockPDFExport method getRows.
private Row[] getRows(List<Identity> rows, List<LectureBlockRollCall> rollCalls) {
int numOfRows = rows.size();
Map<Identity, LectureBlockRollCall> rollCallMap = new HashMap<>();
for (LectureBlockRollCall rollCall : rollCalls) {
rollCallMap.put(rollCall.getIdentity(), rollCall);
}
Row[] content = new Row[numOfRows];
for (int i = 0; i < numOfRows; i++) {
Identity row = rows.get(i);
String fullname = getName(row);
String comment = null;
boolean authorised = false;
boolean[] absences = new boolean[numOfLectures];
Arrays.fill(absences, false);
LectureBlockRollCall rollCall = rollCallMap.get(rows.get(i));
if (rollCall != null) {
if (rollCall.getLecturesAbsentList() != null) {
List<Integer> absenceList = rollCall.getLecturesAbsentList();
for (int j = 0; j < numOfLectures; j++) {
absences[j] = absenceList.contains(new Integer(j));
}
}
if (rollCall.getAbsenceAuthorized() != null) {
authorised = rollCall.getAbsenceAuthorized().booleanValue();
}
if (StringHelper.containsNonWhitespace(rollCall.getComment())) {
comment = rollCall.getComment();
}
}
content[i] = new Row(fullname, absences, authorised, comment);
}
return content;
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method adaptAll.
@Override
public void adaptAll(Identity author) {
List<LectureBlock> lectureBlocks = lectureBlockDao.getLectureBlocks();
for (LectureBlock lectureBlock : lectureBlocks) {
List<LectureBlockRollCall> rollCallList = lectureBlockRollCallDao.getRollCalls(lectureBlock);
for (LectureBlockRollCall rollCall : rollCallList) {
int numOfLectures = lectureBlock.getEffectiveLecturesNumber();
if (numOfLectures <= 0 && lectureBlock.getStatus() != LectureBlockStatus.cancelled) {
numOfLectures = lectureBlock.getPlannedLecturesNumber();
}
lectureBlockRollCallDao.adaptLecture(lectureBlock, rollCall, numOfLectures, author);
}
dbInstance.commitAndCloseSession();
}
}
Aggregations