Search in sources :

Example 1 with CompositeAssessmentRequest

use of fi.otavanopisto.muikku.schooldata.entity.CompositeAssessmentRequest in project muikku by otavanopisto.

the class Evaluation2RESTService method listAssessmentRequests.

@GET
@Path("/compositeAssessmentRequests")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listAssessmentRequests(@QueryParam("workspaceEntityId") Long workspaceEntityId) {
    if (!sessionController.isLoggedIn()) {
        return Response.status(Status.UNAUTHORIZED).build();
    }
    if (!sessionController.hasEnvironmentPermission(MuikkuPermissions.ACCESS_EVALUATION)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    List<RestAssessmentRequest> restAssessmentRequests = new ArrayList<RestAssessmentRequest>();
    if (workspaceEntityId == null) {
        // List assessment requests by staff member
        SchoolDataIdentifier loggedUser = sessionController.getLoggedUser();
        List<CompositeAssessmentRequest> assessmentRequests = gradingController.listAssessmentRequestsByStaffMember(loggedUser);
        for (CompositeAssessmentRequest assessmentRequest : assessmentRequests) {
            restAssessmentRequests.add(toRestAssessmentRequest(assessmentRequest));
        }
    } else {
        // List assessment requests by workspace
        List<String> workspaceStudentIdentifiers = new ArrayList<String>();
        WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
        SchoolDataIdentifier workspaceIdentifier = new SchoolDataIdentifier(workspaceEntity.getIdentifier(), workspaceEntity.getDataSource().getIdentifier());
        List<WorkspaceUserEntity> workspaceUserEntities = workspaceUserEntityController.listActiveWorkspaceStudents(workspaceEntity);
        for (WorkspaceUserEntity workspaceUserEntity : workspaceUserEntities) {
            workspaceStudentIdentifiers.add(workspaceUserEntity.getIdentifier());
        }
        List<CompositeAssessmentRequest> assessmentRequests = gradingController.listAssessmentRequestsByWorkspace(workspaceIdentifier, workspaceStudentIdentifiers);
        for (CompositeAssessmentRequest assessmentRequest : assessmentRequests) {
            restAssessmentRequests.add(toRestAssessmentRequest(assessmentRequest));
        }
    }
    return Response.ok(restAssessmentRequests).build();
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) ArrayList(java.util.ArrayList) RestAssessmentRequest(fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestAssessmentRequest) CompositeAssessmentRequest(fi.otavanopisto.muikku.schooldata.entity.CompositeAssessmentRequest) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Aggregations

WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)1 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)1 RestAssessmentRequest (fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestAssessmentRequest)1 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)1 CompositeAssessmentRequest (fi.otavanopisto.muikku.schooldata.entity.CompositeAssessmentRequest)1 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1