Search in sources :

Example 46 with LectureBlockRollCall

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);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) ArrayList(java.util.ArrayList)

Example 47 with LectureBlockRollCall

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);
}
Also used : LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall)

Example 48 with LectureBlockRollCall

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());
}
Also used : LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) ArrayList(java.util.ArrayList)

Example 49 with LectureBlockRollCall

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);
}
Also used : LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall)

Example 50 with LectureBlockRollCall

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());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

LectureBlockRollCall (org.olat.modules.lecture.LectureBlockRollCall)64 LectureBlock (org.olat.modules.lecture.LectureBlock)40 Identity (org.olat.core.id.Identity)36 Test (org.junit.Test)26 LectureBlockRollCallSearchParameters (org.olat.modules.lecture.LectureBlockRollCallSearchParameters)16 Date (java.util.Date)14 ArrayList (java.util.ArrayList)12 List (java.util.List)10 LectureService (org.olat.modules.lecture.LectureService)10 HashMap (java.util.HashMap)8 IOException (java.io.IOException)6 URI (java.net.URI)6 Collectors (java.util.stream.Collectors)6 HttpResponse (org.apache.http.HttpResponse)6 LectureBlockRollCallVO (org.olat.modules.lecture.restapi.LectureBlockRollCallVO)6 LectureBlockStatus (org.olat.modules.lecture.LectureBlockStatus)5 LectureRollCallStatus (org.olat.modules.lecture.LectureRollCallStatus)5 Map (java.util.Map)4 Roles (org.olat.core.id.Roles)4 LectureBlockAndRollCall (org.olat.modules.lecture.model.LectureBlockAndRollCall)4