use of fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation in project muikku by otavanopisto.
the class WorkspaceMaterialEvaluationDAO method create.
public WorkspaceMaterialEvaluation create(Long studentEntityId, Long workspaceMaterialId, String gradingScaleIdentifier, String gradingScaleSchoolDataSource, String gradeIdentifier, String gradeSchoolDataSource, Long assessorEntityId, Date evaluated, String verbalAssessment) {
WorkspaceMaterialEvaluation workspaceMaterialEvaluation = new WorkspaceMaterialEvaluation();
workspaceMaterialEvaluation.setAssessorEntityId(assessorEntityId);
workspaceMaterialEvaluation.setEvaluated(evaluated);
workspaceMaterialEvaluation.setGradingScaleIdentifier(gradingScaleIdentifier);
workspaceMaterialEvaluation.setGradingScaleSchoolDataSource(gradingScaleSchoolDataSource);
workspaceMaterialEvaluation.setGradeIdentifier(gradeIdentifier);
workspaceMaterialEvaluation.setGradeSchoolDataSource(gradeSchoolDataSource);
workspaceMaterialEvaluation.setStudentEntityId(studentEntityId);
workspaceMaterialEvaluation.setVerbalAssessment(verbalAssessment);
workspaceMaterialEvaluation.setWorkspaceMaterialId(workspaceMaterialId);
return persist(workspaceMaterialEvaluation);
}
use of fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation in project muikku by otavanopisto.
the class WorkspaceMaterialEvaluationDAO method listByWorkspaceMaterialId.
public List<WorkspaceMaterialEvaluation> listByWorkspaceMaterialId(Long workspaceMaterialId) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<WorkspaceMaterialEvaluation> criteria = criteriaBuilder.createQuery(WorkspaceMaterialEvaluation.class);
Root<WorkspaceMaterialEvaluation> root = criteria.from(WorkspaceMaterialEvaluation.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(WorkspaceMaterialEvaluation_.workspaceMaterialId), workspaceMaterialId)));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation in project muikku by otavanopisto.
the class WorkspaceMaterialEvaluationDAO method findByWorkspaceMaterialIdAndStudentEntityId.
public WorkspaceMaterialEvaluation findByWorkspaceMaterialIdAndStudentEntityId(Long workspaceMaterialId, Long studentEntityId) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<WorkspaceMaterialEvaluation> criteria = criteriaBuilder.createQuery(WorkspaceMaterialEvaluation.class);
Root<WorkspaceMaterialEvaluation> root = criteria.from(WorkspaceMaterialEvaluation.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(WorkspaceMaterialEvaluation_.workspaceMaterialId), workspaceMaterialId), criteriaBuilder.equal(root.get(WorkspaceMaterialEvaluation_.studentEntityId), studentEntityId)));
return getSingleResult(entityManager.createQuery(criteria));
}
use of fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation in project muikku by otavanopisto.
the class WorkspaceMaterialEvaluationDAO method findByWorkspaceMaterialIdsAndStudentEntityId.
public List<WorkspaceMaterialEvaluation> findByWorkspaceMaterialIdsAndStudentEntityId(List<Long> workspaceMaterialIds, Long studentEntityId) {
EntityManager entityManager = getEntityManager();
if (workspaceMaterialIds.isEmpty()) {
return Collections.emptyList();
}
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<WorkspaceMaterialEvaluation> criteria = criteriaBuilder.createQuery(WorkspaceMaterialEvaluation.class);
Root<WorkspaceMaterialEvaluation> root = criteria.from(WorkspaceMaterialEvaluation.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(root.get(WorkspaceMaterialEvaluation_.studentEntityId).in(workspaceMaterialIds), criteriaBuilder.equal(root.get(WorkspaceMaterialEvaluation_.studentEntityId), studentEntityId)));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation in project muikku by otavanopisto.
the class Evaluation2RESTService method createWorkspaceMaterialAssessment.
@POST
@Path("/workspace/{WORKSPACEENTITYID}/user/{USERENTITYID}/workspacematerial/{WORKSPACEMATERIALID}/assessment")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response createWorkspaceMaterialAssessment(@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);
// 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);
if (workspaceMaterialEvaluation == null) {
workspaceMaterialEvaluation = evaluationController.createWorkspaceMaterialEvaluation(userEntity, workspaceMaterial, gradingScale, gradingScaleItem, assessor, payload.getAssessmentDate(), payload.getVerbalAssessment());
} else {
workspaceMaterialEvaluation = evaluationController.updateWorkspaceMaterialEvaluation(workspaceMaterialEvaluation, gradingScale, gradingScaleItem, assessor, payload.getAssessmentDate(), payload.getVerbalAssessment());
}
// Remove possible workspace assignment supplementation request
SupplementationRequest supplementationRequest = evaluationController.findSupplementationRequestByStudentAndWorkspaceMaterialAndArchived(userEntityId, workspaceMaterialId, Boolean.FALSE);
if (supplementationRequest != null) {
evaluationController.deleteSupplementationRequest(supplementationRequest);
}
// 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();
}
Aggregations