Search in sources :

Example 1 with WorkspaceGrade

use of fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGrade in project muikku by otavanopisto.

the class EvaluationRESTService method listWorkspaceGrades.

@GET
@Path("/workspaces/{WORKSPACEENTITYID}/gradingScales")
@RESTPermit(handling = Handling.INLINE)
public Response listWorkspaceGrades(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId) {
    if (!sessionController.isLoggedIn()) {
        return Response.status(Status.UNAUTHORIZED).build();
    }
    WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
    if (workspaceEntity == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (!sessionController.hasWorkspacePermission(EvaluationResourcePermissionCollection.EVALUATION_LISTGRADINGSCALES, workspaceEntity)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    List<WorkspaceGradingScale> result = new ArrayList<>();
    List<GradingScale> gradingScales = gradingController.listGradingScales();
    for (GradingScale gradingScale : gradingScales) {
        List<GradingScaleItem> gradingScaleItems = gradingController.listGradingScaleItems(gradingScale);
        List<WorkspaceGrade> workspaceGrades = new ArrayList<>();
        for (GradingScaleItem gradingScaleItem : gradingScaleItems) {
            workspaceGrades.add(new WorkspaceGrade(gradingScaleItem.getName(), gradingScaleItem.getIdentifier(), gradingScaleItem.getSchoolDataSource()));
        }
        result.add(new WorkspaceGradingScale(gradingScale.getName(), gradingScale.getIdentifier(), gradingScale.getSchoolDataSource(), workspaceGrades));
    }
    return Response.ok(result).build();
}
Also used : WorkspaceGrade(fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGrade) GradingScale(fi.otavanopisto.muikku.schooldata.entity.GradingScale) WorkspaceGradingScale(fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) GradingScaleItem(fi.otavanopisto.muikku.schooldata.entity.GradingScaleItem) ArrayList(java.util.ArrayList) WorkspaceGradingScale(fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 2 with WorkspaceGrade

use of fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGrade in project muikku by otavanopisto.

the class Evaluation2RESTService method listGrades.

@GET
@Path("/compositeGradingScales")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listGrades() {
    if (!sessionController.isLoggedIn()) {
        return Response.status(Status.UNAUTHORIZED).build();
    }
    if (!sessionController.hasEnvironmentPermission(MuikkuPermissions.ACCESS_EVALUATION)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    List<WorkspaceGradingScale> restGradingScales = new ArrayList<WorkspaceGradingScale>();
    List<CompositeGradingScale> gradingScales = gradingController.listCompositeGradingScales();
    for (CompositeGradingScale gradingScale : gradingScales) {
        List<CompositeGrade> grades = gradingScale.getGrades();
        List<WorkspaceGrade> restGrades = new ArrayList<WorkspaceGrade>();
        for (CompositeGrade grade : grades) {
            restGrades.add(new WorkspaceGrade(grade.getGradeName(), grade.getGradeIdentifier(), gradingScale.getSchoolDataSource()));
        }
        restGradingScales.add(new WorkspaceGradingScale(gradingScale.getScaleName(), gradingScale.getScaleIdentifier(), gradingScale.getSchoolDataSource(), restGrades));
    }
    return Response.ok(restGradingScales).build();
}
Also used : WorkspaceGrade(fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGrade) ArrayList(java.util.ArrayList) CompositeGrade(fi.otavanopisto.muikku.schooldata.entity.CompositeGrade) WorkspaceGradingScale(fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale) CompositeGradingScale(fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Aggregations

WorkspaceGrade (fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGrade)2 WorkspaceGradingScale (fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale)2 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)1 CompositeGrade (fi.otavanopisto.muikku.schooldata.entity.CompositeGrade)1 CompositeGradingScale (fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale)1 GradingScale (fi.otavanopisto.muikku.schooldata.entity.GradingScale)1 GradingScaleItem (fi.otavanopisto.muikku.schooldata.entity.GradingScaleItem)1