use of org.olat.modules.lecture.LectureBlockRollCall in project openolat by klemens.
the class TeacherRollCallController method doCheckAllRow.
private void doCheckAllRow(TeacherRollCallRow row) {
List<Integer> allAbsences = new ArrayList<>(numOfLectures);
for (int i = 0; i < numOfLectures; i++) {
allAbsences.add(i);
}
LectureBlockRollCall rollCall = lectureService.addRollCall(row.getIdentity(), lectureBlock, row.getRollCall(), null, allAbsences);
for (MultipleSelectionElement check : row.getChecks()) {
check.select(onKeys[0], true);
}
row.setRollCall(rollCall);
if (authorizedAbsenceEnabled) {
if (rollCall.getAbsenceAuthorized() != null && rollCall.getAbsenceAuthorized().booleanValue()) {
row.getAuthorizedAbsence().select(onKeys[0], true);
} else {
row.getAuthorizedAbsence().uncheckAll();
}
row.getAuthorizedAbsenceCont().setDirty(true);
}
row.getRollCallStatusEl().getComponent().setDirty(true);
tableEl.reloadData();
flc.setDirty(true);
}
use of org.olat.modules.lecture.LectureBlockRollCall in project openolat by klemens.
the class TeacherRollCallController method doAuthorizedAbsence.
private void doAuthorizedAbsence(TeacherRollCallRow row, MultipleSelectionElement check) {
LectureBlockRollCall rollCall = row.getRollCall();
boolean authorized = check.isAtLeastSelected(1);
if (rollCall == null) {
rollCall = lectureService.getOrCreateRollCall(row.getIdentity(), lectureBlock, authorized, null);
lectureService.auditLog(LectureBlockAuditLog.Action.createRollCall, null, lectureService.toAuditXml(rollCall), authorized ? "true" : "false", lectureBlock, rollCall, lectureBlock.getEntry(), row.getIdentity(), getIdentity());
} else {
String before = lectureService.toAuditXml(rollCall);
rollCall.setAbsenceAuthorized(authorized);
rollCall = lectureService.updateRollCall(rollCall);
lectureService.auditLog(LectureBlockAuditLog.Action.updateAuthorizedAbsence, before, lectureService.toAuditXml(rollCall), authorized ? "true" : "false", lectureBlock, rollCall, lectureBlock.getEntry(), row.getIdentity(), getIdentity());
}
row.getReasonLink().setVisible(authorized);
row.getAuthorizedAbsenceCont().setDirty(true);
row.getAuthorizedAbsence().clearError();
row.setRollCall(rollCall);
row.getRollCallStatusEl().getComponent().setDirty(true);
}
use of org.olat.modules.lecture.LectureBlockRollCall in project openolat by klemens.
the class TeacherRollCallController method saveLectureBlocks.
private void saveLectureBlocks() {
String before = lectureService.toAuditXml(lectureBlock);
for (int i = tableModel.getRowCount(); i-- > 0; ) {
TeacherRollCallRow row = tableModel.getObject(i);
int numOfChecks = row.getChecks().length;
List<Integer> absenceList = new ArrayList<>(numOfChecks);
for (int j = 0; j < numOfChecks; j++) {
if (row.getCheck(j).isAtLeastSelected(1)) {
absenceList.add(j);
}
}
String comment = row.getCommentEl().getValue();
LectureBlockRollCall rollCall = lectureService.addRollCall(row.getIdentity(), lectureBlock, row.getRollCall(), comment, absenceList);
row.setRollCall(rollCall);
}
lectureBlock = lectureService.getLectureBlock(lectureBlock);
if (lectureBlock.getRollCallStatus() == null) {
lectureBlock.setRollCallStatus(LectureRollCallStatus.open);
}
if (lectureBlock.getStatus() == null || lectureBlock.getStatus() == LectureBlockStatus.active) {
lectureBlock.setStatus(LectureBlockStatus.active);
}
lectureBlock = lectureService.save(lectureBlock, null);
lectureService.recalculateSummary(lectureBlock.getEntry());
String after = lectureService.toAuditXml(lectureBlock);
lectureService.auditLog(LectureBlockAuditLog.Action.saveLectureBlock, before, after, null, lectureBlock, null, lectureBlock.getEntry(), null, getIdentity());
}
use of org.olat.modules.lecture.LectureBlockRollCall in project openolat by klemens.
the class TeacherRollCallController method doReason.
private void doReason(TeacherRollCallRow row, String reason) {
LectureBlockRollCall rollCall = row.getRollCall();
String before = lectureService.toAuditXml(rollCall);
if (rollCall == null) {
row.getAuthorizedAbsence().select(onKeys[0], true);
rollCall = lectureService.getOrCreateRollCall(row.getIdentity(), lectureBlock, true, reason);
lectureService.auditLog(LectureBlockAuditLog.Action.createRollCall, before, lectureService.toAuditXml(rollCall), reason, lectureBlock, rollCall, lectureBlock.getEntry(), row.getIdentity(), getIdentity());
} else {
rollCall.setAbsenceReason(reason);
rollCall = lectureService.updateRollCall(rollCall);
lectureService.auditLog(LectureBlockAuditLog.Action.updateRollCall, before, lectureService.toAuditXml(rollCall), reason, lectureBlock, rollCall, lectureBlock.getEntry(), row.getIdentity(), getIdentity());
}
row.setRollCall(rollCall);
}
use of org.olat.modules.lecture.LectureBlockRollCall in project openolat by klemens.
the class LectureBlockRollCallDAOTest method createRollCall_absences.
@Test
public void createRollCall_absences() {
LectureBlock lectureBlock = createMinimalLectureBlock(3);
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
dbInstance.commitAndCloseSession();
List<Integer> absences = Collections.singletonList(2);
LectureBlockRollCall rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, id, null, null, null, absences);
dbInstance.commitAndCloseSession();
LectureBlockRollCall reloadRollCall = lectureBlockRollCallDao.loadByKey(rollCall.getKey());
Assert.assertNotNull(reloadRollCall);
Assert.assertEquals(rollCall, reloadRollCall);
// check absence
Assert.assertEquals(1, reloadRollCall.getLecturesAbsentNumber());
List<Integer> absenceList = reloadRollCall.getLecturesAbsentList();
Assert.assertNotNull(absenceList);
Assert.assertEquals(1, absenceList.size());
Assert.assertEquals(2, absenceList.get(0).intValue());
// check attendee
Assert.assertEquals(2, reloadRollCall.getLecturesAttendedNumber());
List<Integer> attendeeList = reloadRollCall.getLecturesAttendedList();
Assert.assertNotNull(attendeeList);
Assert.assertEquals(2, attendeeList.size());
Assert.assertEquals(0, attendeeList.get(0).intValue());
Assert.assertEquals(1, attendeeList.get(1).intValue());
}
Aggregations