Search in sources :

Example 6 with WorkspaceMaterialEvaluation

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

the class Evaluation2RESTService method listWorkspaceAssignments.

@GET
@Path("/workspace/{WORKSPACEENTITYID}/assignments")
@RESTPermit(handling = Handling.INLINE)
public Response listWorkspaceAssignments(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @QueryParam("userEntityId") Long userEntityId) {
    // Workspace entity
    WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
    if (workspaceEntity == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    // User entity (optional)
    UserEntity userEntity = null;
    if (userEntityId != null) {
        userEntity = userEntityController.findUserEntityById(userEntityId);
        if (userEntity == null) {
            return Response.status(Status.NOT_FOUND).build();
        }
    }
    // Workspace materials...
    List<WorkspaceMaterial> workspaceMaterials = workspaceMaterialController.listWorkspaceMaterialsByAssignmentType(workspaceEntity, WorkspaceMaterialAssignmentType.EVALUATED, BooleanPredicate.IGNORE);
    workspaceMaterials.addAll(workspaceMaterialController.listWorkspaceMaterialsByAssignmentType(workspaceEntity, WorkspaceMaterialAssignmentType.EXERCISE, BooleanPredicate.IGNORE));
    // ...to RestAssignments
    List<RestAssignment> assignments = new ArrayList<RestAssignment>();
    for (WorkspaceMaterial workspaceMaterial : workspaceMaterials) {
        Long workspaceMaterialEvaluationId = null;
        Long workspaceMaterialId = workspaceMaterial.getId();
        Long materialId = workspaceMaterial.getMaterialId();
        String path = workspaceMaterial.getPath();
        String title = workspaceMaterial.getTitle();
        Boolean evaluable = workspaceMaterial.getAssignmentType() == WorkspaceMaterialAssignmentType.EVALUATED;
        Date submitted = null;
        Date evaluated = null;
        String grade = null;
        String literalEvaluation = null;
        if (userEntity != null) {
            WorkspaceMaterialReply workspaceMaterialReply = workspaceMaterialReplyController.findWorkspaceMaterialReplyByWorkspaceMaterialAndUserEntity(workspaceMaterial, userEntity);
            if (workspaceMaterialReply != null) {
                WorkspaceMaterialReplyState replyState = workspaceMaterialReply.getState();
                if (replyState == WorkspaceMaterialReplyState.SUBMITTED || replyState == WorkspaceMaterialReplyState.PASSED || replyState == WorkspaceMaterialReplyState.FAILED || replyState == WorkspaceMaterialReplyState.INCOMPLETE) {
                    submitted = workspaceMaterialReply.getLastModified();
                }
            } else if (workspaceMaterial.getHidden()) {
                // Skip hidden material which has no reply
                continue;
            }
            WorkspaceMaterialEvaluation workspaceMaterialEvaluation = evaluationController.findWorkspaceMaterialEvaluationByWorkspaceMaterialAndStudent(workspaceMaterial, userEntity);
            if (workspaceMaterialEvaluation != null) {
                workspaceMaterialEvaluationId = workspaceMaterialEvaluation.getId();
                evaluated = workspaceMaterialEvaluation.getEvaluated();
                GradingScale gradingScale = gradingController.findGradingScale(workspaceMaterialEvaluation.getGradingScaleSchoolDataSource(), workspaceMaterialEvaluation.getGradingScaleIdentifier());
                if (gradingScale != null) {
                    GradingScaleItem gradingScaleItem = gradingController.findGradingScaleItem(gradingScale, workspaceMaterialEvaluation.getGradeSchoolDataSource(), workspaceMaterialEvaluation.getGradeIdentifier());
                    if (gradingScaleItem != null) {
                        grade = gradingScaleItem.getName();
                    }
                }
                literalEvaluation = workspaceMaterialEvaluation.getVerbalAssessment();
            } else {
                SupplementationRequest supplementationRequest = evaluationController.findSupplementationRequestByStudentAndWorkspaceMaterialAndArchived(userEntity.getId(), workspaceMaterial.getId(), Boolean.FALSE);
                if (supplementationRequest != null) {
                    evaluated = supplementationRequest.getRequestDate();
                    literalEvaluation = supplementationRequest.getRequestText();
                }
            }
        }
        if (!(workspaceMaterial.getHidden() && submitted == null)) {
            assignments.add(new RestAssignment(workspaceMaterialEvaluationId, workspaceMaterialId, materialId, path, title, evaluable, submitted, evaluated, grade, literalEvaluation));
        }
    }
    return Response.ok(assignments).build();
}
Also used : CompositeGradingScale(fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale) GradingScale(fi.otavanopisto.muikku.schooldata.entity.GradingScale) WorkspaceGradingScale(fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale) RestAssignment(fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestAssignment) WorkspaceMaterialReply(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply) GradingScaleItem(fi.otavanopisto.muikku.schooldata.entity.GradingScaleItem) ArrayList(java.util.ArrayList) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial) Date(java.util.Date) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) WorkspaceMaterialEvaluation(fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation) SupplementationRequest(fi.otavanopisto.muikku.plugins.evaluation.model.SupplementationRequest) RestSupplementationRequest(fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestSupplementationRequest) WorkspaceMaterialReplyState(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReplyState) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 7 with WorkspaceMaterialEvaluation

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

the class Evaluation2RESTService method updateWorkspaceMaterialAssessment.

@PUT
@Path("/workspace/{WORKSPACEENTITYID}/user/{USERENTITYID}/workspacematerial/{WORKSPACEMATERIALID}/assessment")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response updateWorkspaceMaterialAssessment(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("USERENTITYID") Long userEntityId, @PathParam("WORKSPACEMATERIALID") Long workspaceMaterialId, RestAssessment payload) {
    if (!sessionController.isLoggedIn()) {
        return Response.status(Status.UNAUTHORIZED).build();
    }
    if (!sessionController.hasEnvironmentPermission(MuikkuPermissions.ACCESS_EVALUATION)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    // User entity
    UserEntity userEntity = userEntityController.findUserEntityById(userEntityId);
    if (userEntity == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    // Workspace material
    WorkspaceMaterial workspaceMaterial = workspaceMaterialController.findWorkspaceMaterialById(workspaceMaterialId);
    if (workspaceMaterial == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    // Workspace material evaluation
    WorkspaceMaterialEvaluation workspaceMaterialEvaluation = evaluationController.findWorkspaceMaterialEvaluationByWorkspaceMaterialAndStudent(workspaceMaterial, userEntity);
    if (workspaceMaterialEvaluation == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    // Grade
    SchoolDataIdentifier gradingScaleIdentifier = SchoolDataIdentifier.fromId(payload.getGradingScaleIdentifier());
    GradingScale gradingScale = gradingController.findGradingScale(gradingScaleIdentifier);
    SchoolDataIdentifier gradeIdentifier = SchoolDataIdentifier.fromId(payload.getGradeIdentifier());
    GradingScaleItem gradingScaleItem = gradingController.findGradingScaleItem(gradingScale, gradeIdentifier);
    // Assessor
    SchoolDataIdentifier assessorIdentifier = SchoolDataIdentifier.fromId(payload.getAssessorIdentifier());
    User assessingUser = userController.findUserByIdentifier(assessorIdentifier);
    UserEntity assessor = userEntityController.findUserEntityByUser(assessingUser);
    workspaceMaterialEvaluation = evaluationController.updateWorkspaceMaterialEvaluation(workspaceMaterialEvaluation, gradingScale, gradingScaleItem, assessor, payload.getAssessmentDate(), payload.getVerbalAssessment());
    // WorkspaceMaterialEvaluation to RestAssessment
    RestAssessment restAssessment = new RestAssessment(workspaceMaterialEvaluation.getId().toString(), assessorIdentifier.toId(), gradingScaleIdentifier.toId(), gradeIdentifier.toId(), workspaceMaterialEvaluation.getVerbalAssessment(), workspaceMaterialEvaluation.getEvaluated(), gradingScaleItem.isPassingGrade());
    return Response.ok(restAssessment).build();
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) CompositeGradingScale(fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale) GradingScale(fi.otavanopisto.muikku.schooldata.entity.GradingScale) WorkspaceGradingScale(fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale) User(fi.otavanopisto.muikku.schooldata.entity.User) WorkspaceUser(fi.otavanopisto.muikku.schooldata.entity.WorkspaceUser) WorkspaceMaterialEvaluation(fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation) GradingScaleItem(fi.otavanopisto.muikku.schooldata.entity.GradingScaleItem) RestAssessment(fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestAssessment) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) PUT(javax.ws.rs.PUT)

Example 8 with WorkspaceMaterialEvaluation

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

the class Evaluation2RESTService method createWorkspaceMaterialSupplementationRequest.

@POST
@Path("/workspace/{WORKSPACEENTITYID}/user/{USERENTITYID}/workspacematerial/{WORKSPACEMATERIALID}/supplementationrequest")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response createWorkspaceMaterialSupplementationRequest(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("USERENTITYID") Long userEntityId, @PathParam("WORKSPACEMATERIALID") Long workspaceMaterialId, RestSupplementationRequest payload) {
    if (!sessionController.isLoggedIn()) {
        return Response.status(Status.UNAUTHORIZED).build();
    }
    if (!sessionController.hasEnvironmentPermission(MuikkuPermissions.ACCESS_EVALUATION)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    // User entity
    UserEntity userEntity = userEntityController.findUserEntityById(userEntityId);
    if (userEntity == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    // Workspace material
    WorkspaceMaterial workspaceMaterial = workspaceMaterialController.findWorkspaceMaterialById(workspaceMaterialId);
    if (workspaceMaterial == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    // Workspace material supplementation request
    SupplementationRequest supplementationRequest = evaluationController.findSupplementationRequestByStudentAndWorkspaceMaterial(userEntityId, workspaceMaterialId);
    if (supplementationRequest == null) {
        supplementationRequest = evaluationController.createSupplementationRequest(payload.getUserEntityId(), payload.getStudentEntityId(), null, payload.getWorkspaceMaterialId(), payload.getRequestDate(), payload.getRequestText());
    } else {
        supplementationRequest = evaluationController.updateSupplementationRequest(supplementationRequest, payload.getUserEntityId(), payload.getRequestDate(), payload.getRequestText());
    }
    // Delete possible workspace material assessment
    WorkspaceMaterialEvaluation workspaceMaterialEvaluation = evaluationController.findWorkspaceMaterialEvaluationByWorkspaceMaterialAndStudent(workspaceMaterial, userEntity);
    if (workspaceMaterialEvaluation != null) {
        evaluationController.deleteWorkspaceMaterialEvaluation(workspaceMaterialEvaluation);
    }
    // SupplementationRequest to RestSupplementationRequest
    RestSupplementationRequest restSupplementationRequest = new RestSupplementationRequest(supplementationRequest.getId(), supplementationRequest.getUserEntityId(), supplementationRequest.getStudentEntityId(), supplementationRequest.getWorkspaceEntityId(), supplementationRequest.getWorkspaceMaterialId(), supplementationRequest.getRequestDate(), supplementationRequest.getRequestText());
    return Response.ok(restSupplementationRequest).build();
}
Also used : WorkspaceMaterialEvaluation(fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation) RestSupplementationRequest(fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestSupplementationRequest) SupplementationRequest(fi.otavanopisto.muikku.plugins.evaluation.model.SupplementationRequest) RestSupplementationRequest(fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestSupplementationRequest) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) POST(javax.ws.rs.POST)

Example 9 with WorkspaceMaterialEvaluation

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

the class Evaluation2RESTService method findWorkspaceMaterialAssessment.

@GET
@Path("/workspace/{WORKSPACEENTITYID}/user/{USERENTITYID}/workspacematerial/{WORKSPACEMATERIALID}/assessment")
@RESTPermit(handling = Handling.INLINE)
public Response findWorkspaceMaterialAssessment(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("USERENTITYID") Long userEntityId, @PathParam("WORKSPACEMATERIALID") Long workspaceMaterialId) {
    if (!sessionController.isLoggedIn()) {
        return Response.status(Status.UNAUTHORIZED).build();
    }
    if (!sessionController.hasEnvironmentPermission(MuikkuPermissions.ACCESS_EVALUATION)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    // User entity
    UserEntity userEntity = userEntityController.findUserEntityById(userEntityId);
    if (userEntity == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    // Workspace material
    WorkspaceMaterial workspaceMaterial = workspaceMaterialController.findWorkspaceMaterialById(workspaceMaterialId);
    if (workspaceMaterial == null) {
        return Response.status(Status.NOT_FOUND).entity("workspaceMaterial not found").build();
    }
    // Workspace material evaluation
    WorkspaceMaterialEvaluation workspaceMaterialEvaluation = evaluationController.findWorkspaceMaterialEvaluationByWorkspaceMaterialAndStudent(workspaceMaterial, userEntity);
    if (workspaceMaterialEvaluation == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    // WorkspaceMaterialEvaluation to RestAssessment
    UserEntity assessingUser = userEntityController.findUserEntityById(workspaceMaterialEvaluation.getAssessorEntityId());
    String assessmentIdentifier = workspaceMaterialEvaluation.getId().toString();
    String assessingUserIdentifier = new SchoolDataIdentifier(assessingUser.getDefaultIdentifier(), assessingUser.getDefaultSchoolDataSource().getIdentifier()).toId();
    String gradingScaleIdentifier = new SchoolDataIdentifier(workspaceMaterialEvaluation.getGradingScaleIdentifier(), workspaceMaterialEvaluation.getGradingScaleSchoolDataSource()).toId();
    String gradeIdentifier = new SchoolDataIdentifier(workspaceMaterialEvaluation.getGradeIdentifier(), workspaceMaterialEvaluation.getGradeSchoolDataSource()).toId();
    RestAssessment restAssessment = new RestAssessment(assessmentIdentifier, assessingUserIdentifier, gradingScaleIdentifier, gradeIdentifier, workspaceMaterialEvaluation.getVerbalAssessment(), workspaceMaterialEvaluation.getEvaluated(), // TODO Passing grade
    null);
    return Response.ok(restAssessment).build();
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) WorkspaceMaterialEvaluation(fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation) RestAssessment(fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestAssessment) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 10 with WorkspaceMaterialEvaluation

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

the class EvaluationController method createWorkspaceMaterialEvaluation.

public WorkspaceMaterialEvaluation createWorkspaceMaterialEvaluation(UserEntity student, WorkspaceMaterial workspaceMaterial, GradingScale gradingScale, GradingScaleItem grade, UserEntity assessor, Date evaluated, String verbalAssessment) {
    WorkspaceMaterialEvaluation evaluation = workspaceMaterialEvaluationDAO.create(student.getId(), workspaceMaterial.getId(), gradingScale.getIdentifier(), gradingScale.getSchoolDataSource(), grade.getIdentifier(), grade.getSchoolDataSource(), assessor.getId(), evaluated, verbalAssessment);
    WorkspaceMaterialReply reply = workspaceMaterialReplyController.findWorkspaceMaterialReplyByWorkspaceMaterialAndUserEntity(workspaceMaterial, student);
    WorkspaceMaterialReplyState state = grade.isPassingGrade() ? WorkspaceMaterialReplyState.PASSED : WorkspaceMaterialReplyState.FAILED;
    if (reply == null) {
        workspaceMaterialReplyController.createWorkspaceMaterialReply(workspaceMaterial, state, student);
    } else {
        workspaceMaterialReplyController.updateWorkspaceMaterialReply(reply, state);
    }
    return evaluation;
}
Also used : WorkspaceMaterialEvaluation(fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation) WorkspaceMaterialReply(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply) WorkspaceMaterialReplyState(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReplyState)

Aggregations

WorkspaceMaterialEvaluation (fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation)11 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)6 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)6 Path (javax.ws.rs.Path)6 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)5 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)5 SupplementationRequest (fi.otavanopisto.muikku.plugins.evaluation.model.SupplementationRequest)3 RestAssessment (fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestAssessment)3 RestSupplementationRequest (fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestSupplementationRequest)3 WorkspaceGradingScale (fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale)3 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)3 CompositeGradingScale (fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale)3 GradingScale (fi.otavanopisto.muikku.schooldata.entity.GradingScale)3 GradingScaleItem (fi.otavanopisto.muikku.schooldata.entity.GradingScaleItem)3 EntityManager (javax.persistence.EntityManager)3 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 WorkspaceMaterialReply (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply)2 WorkspaceMaterialReplyState (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReplyState)2 User (fi.otavanopisto.muikku.schooldata.entity.User)2 WorkspaceUser (fi.otavanopisto.muikku.schooldata.entity.WorkspaceUser)2