Search in sources :

Example 61 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project openolat by klemens.

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

Example 62 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project openolat by klemens.

the class ParticipantLectureBlocksController method doAppealAudit.

private void doAppealAudit(LectureBlockAndRollCall row, String message) {
    logAudit("Appeal send for lecture block: " + row.getLectureBlockTitle() + " (" + row.getLectureBlockRef().getKey() + ")", null);
    LectureBlock lectureBlock = lectureService.getLectureBlock(row.getLectureBlockRef());
    LectureBlockRollCall rollCall = lectureService.getRollCall(row.getRollCallRef());
    lectureService.auditLog(Action.sendAppeal, null, null, message, lectureBlock, rollCall, entry, assessedIdentity, null);
    dbInstance.commit();
    loadModel();
    tableEl.reset(false, false, true);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall)

Example 63 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project openolat by klemens.

the class LectureBlockRollCallWebService method getRollCalls.

/**
 * Return a list lecture block roll call.
 *
 * @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
 * @param closed If true, the status of the block is done or the status of the roll call is closed or auto closed
 * @param hasAbsence If true, the roll call has an absence
 * @param hasSupervisorNotificationDate If true, the roll call has a supervisor notification date set
 * @param httpRequest  The HTTP request
 * @return The roll calls
 */
@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRollCalls(@QueryParam("closed") Boolean closed, @QueryParam("hasAbsence") Boolean hasAbsence, @QueryParam("hasSupervisorNotificationDate") Boolean hasSupervisorNotificationDate, @QueryParam("lectureBlockKey") Long lectureBlockKey, @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();
    if (hasAbsence != null) {
        searchParams.setHasAbsence(hasAbsence);
    }
    if (hasSupervisorNotificationDate != null) {
        searchParams.setHasSupervisorNotificationDate(hasSupervisorNotificationDate);
    }
    if (closed != null) {
        searchParams.setClosed(closed);
    }
    if (lectureBlockKey != null) {
        searchParams.setLectureBlockKey(lectureBlockKey);
    }
    List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(searchParams);
    List<LectureBlockRollCallVO> voList = new ArrayList<>(rollCalls.size());
    for (LectureBlockRollCall rollCall : rollCalls) {
        voList.add(new LectureBlockRollCallVO(rollCall));
    }
    LectureBlockRollCallVO[] voes = voList.toArray(new LectureBlockRollCallVO[voList.size()]);
    return Response.ok(voes).build();
}
Also used : LectureBlockRollCallSearchParameters(org.olat.modules.lecture.LectureBlockRollCallSearchParameters) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) ArrayList(java.util.ArrayList) 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 64 with LectureBlockRollCall

use of org.olat.modules.lecture.LectureBlockRollCall in project openolat by klemens.

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)

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