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();
}
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();
}
Aggregations