Search in sources :

Example 36 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.

the class LectureBlockRollCallWebService method updateLectureBlockRollCall.

private Response updateLectureBlockRollCall(LectureBlockRollCallVO rollCallVo, HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    if (!roles.isOLATAdmin()) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    if (rollCallVo.getKey() == null) {
        return Response.serverError().status(Status.BAD_REQUEST).build();
    }
    LectureService lectureService = CoreSpringFactory.getImpl(LectureService.class);
    LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
    searchParams.setRollCallKey(rollCallVo.getKey());
    List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(searchParams);
    if (rollCalls.size() == 1) {
        LectureBlockRollCall rollCall = rollCalls.get(0);
        rollCall.setAbsenceSupervisorNotificationDate(rollCallVo.getAbsenceSupervisorNotificationDate());
        if (rollCallVo.getAbsenceReason() != null) {
            rollCall.setAbsenceReason(rollCallVo.getAbsenceReason());
        }
        if (rollCallVo.getComment() != null) {
            rollCall.setComment(rollCallVo.getComment());
        }
        rollCall = lectureService.updateRollCall(rollCall);
        LectureBlockRollCallVO vo = new LectureBlockRollCallVO(rollCall);
        return Response.ok(vo).build();
    }
    return Response.serverError().status(Status.NOT_FOUND).build();
}
Also used : LectureBlockRollCallSearchParameters(org.olat.modules.lecture.LectureBlockRollCallSearchParameters) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) LectureService(org.olat.modules.lecture.LectureService)

Example 37 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.

the class LectureBlockRollCallWebService method getRollCall.

/**
 * Return the lecture block roll call specified by the primary key.
 *
 * @response.representation.200.qname {http://www.example.com}lectureBlockRollCallVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc A lecture block roll call
 * @response.representation.200.example {@link org.olat.modules.lecture.restapi.Examples#SAMPLE_LECTUREBLOCKROLLCALLVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The role call was not found
 * @param rollCallKey The primary key of the roll call
 * @param httpRequest  The HTTP request
 * @return The roll call
 */
@GET
@Path("{rollCallKey}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getRollCall(@PathParam("rollCallKey") Long rollCallKey, @Context HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    if (!roles.isOLATAdmin()) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    LectureService lectureService = CoreSpringFactory.getImpl(LectureService.class);
    LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
    searchParams.setRollCallKey(rollCallKey);
    List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(searchParams);
    if (rollCalls.size() == 1) {
        LectureBlockRollCall rollCall = rollCalls.get(0);
        LectureBlockRollCallVO vo = new LectureBlockRollCallVO(rollCall);
        return Response.ok(vo).build();
    }
    return Response.serverError().status(Status.NOT_FOUND).build();
}
Also used : LectureBlockRollCallSearchParameters(org.olat.modules.lecture.LectureBlockRollCallSearchParameters) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) LectureService(org.olat.modules.lecture.LectureService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 38 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.

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 39 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.

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 40 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.

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)

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