Search in sources :

Example 6 with LectureService

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

the class CourseHandler method cloneLectureConfig.

private void cloneLectureConfig(RepositoryEntry source, RepositoryEntry target) {
    LectureService lectureService = CoreSpringFactory.getImpl(LectureService.class);
    lectureService.copyRepositoryEntryLectureConfiguration(source, target);
}
Also used : LectureService(org.olat.modules.lecture.LectureService)

Example 7 with LectureService

use of org.olat.modules.lecture.LectureService 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 8 with LectureService

use of org.olat.modules.lecture.LectureService 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

LectureService (org.olat.modules.lecture.LectureService)8 Roles (org.olat.core.id.Roles)6 LectureBlockRollCall (org.olat.modules.lecture.LectureBlockRollCall)6 LectureBlockRollCallSearchParameters (org.olat.modules.lecture.LectureBlockRollCallSearchParameters)6 RestSecurityHelper.getRoles (org.olat.restapi.security.RestSecurityHelper.getRoles)6 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 ArrayList (java.util.ArrayList)2