use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReplyState in project muikku by otavanopisto.
the class EvaluationController method updateWorkspaceMaterialEvaluation.
public WorkspaceMaterialEvaluation updateWorkspaceMaterialEvaluation(WorkspaceMaterialEvaluation workspaceMaterialEvaluation, GradingScale gradingScale, GradingScaleItem grade, UserEntity assessor, Date evaluated, String verbalAssessment) {
workspaceMaterialEvaluationDAO.updateGradingScaleIdentifier(workspaceMaterialEvaluation, gradingScale.getIdentifier());
workspaceMaterialEvaluationDAO.updateGradingScaleSchoolDataSource(workspaceMaterialEvaluation, gradingScale.getSchoolDataSource());
workspaceMaterialEvaluationDAO.updateVerbalAssessment(workspaceMaterialEvaluation, verbalAssessment);
workspaceMaterialEvaluationDAO.updateGradeIdentifier(workspaceMaterialEvaluation, grade.getIdentifier());
workspaceMaterialEvaluationDAO.updateGradeSchoolDataSource(workspaceMaterialEvaluation, grade.getSchoolDataSource());
workspaceMaterialEvaluationDAO.updateAssessorEntityId(workspaceMaterialEvaluation, assessor.getId());
workspaceMaterialEvaluationDAO.updateEvaluated(workspaceMaterialEvaluation, evaluated);
WorkspaceMaterial workspaceMaterial = workspaceMaterialController.findWorkspaceMaterialById(workspaceMaterialEvaluation.getWorkspaceMaterialId());
UserEntity student = userEntityController.findUserEntityById(workspaceMaterialEvaluation.getStudentEntityId());
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 workspaceMaterialEvaluation;
}
use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReplyState 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();
}
use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReplyState in project muikku by otavanopisto.
the class Evaluation2RESTService method toRestAssessmentRequest.
private RestAssessmentRequest toRestAssessmentRequest(CompositeAssessmentRequest compositeAssessmentRequest) {
Long assignmentsDone = 0L;
Long assignmentsTotal = 0L;
// Assignments total
WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceByIdentifier(compositeAssessmentRequest.getCourseIdentifier());
if (workspaceEntity == null) {
logger.severe(String.format("WorkspaceEntity for course %s not found", compositeAssessmentRequest.getCourseIdentifier()));
} else {
List<WorkspaceMaterial> evaluatedAssignments = workspaceMaterialController.listVisibleWorkspaceMaterialsByAssignmentType(workspaceEntity, WorkspaceMaterialAssignmentType.EVALUATED);
assignmentsTotal = new Long(evaluatedAssignments.size());
// Assignments done by user
if (assignmentsTotal > 0) {
UserEntity userEntity = userEntityController.findUserEntityByUserIdentifier(compositeAssessmentRequest.getUserIdentifier());
if (userEntity == null) {
logger.severe(String.format("UserEntity not found for AssessmentRequest student %s not found", compositeAssessmentRequest.getUserIdentifier()));
} else {
List<WorkspaceMaterialReplyState> replyStates = new ArrayList<WorkspaceMaterialReplyState>();
replyStates.add(WorkspaceMaterialReplyState.FAILED);
replyStates.add(WorkspaceMaterialReplyState.PASSED);
replyStates.add(WorkspaceMaterialReplyState.SUBMITTED);
replyStates.add(WorkspaceMaterialReplyState.INCOMPLETE);
assignmentsDone = workspaceMaterialReplyController.getReplyCountByUserEntityAndReplyStatesAndWorkspaceMaterials(userEntity.getId(), replyStates, evaluatedAssignments);
}
}
}
WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findWorkspaceUserEntityByWorkspaceUserIdentifierIncludeArchived(compositeAssessmentRequest.getCourseStudentIdentifier());
UserEntity userEntity = userEntityController.findUserEntityByUserIdentifier(compositeAssessmentRequest.getUserIdentifier());
// An active workspace supplementation request will override graded, passing, and evaluationDate
Boolean graded = Boolean.TRUE;
Boolean passing = compositeAssessmentRequest.getPassing();
Date evaluationDate = compositeAssessmentRequest.getEvaluationDate();
if (userEntity != null) {
SupplementationRequest supplementationRequest = evaluationController.findSupplementationRequestByStudentAndWorkspaceAndArchived(userEntity.getId(), workspaceEntity.getId(), Boolean.FALSE);
if (supplementationRequest != null) {
graded = Boolean.FALSE;
passing = Boolean.FALSE;
evaluationDate = supplementationRequest.getRequestDate();
}
}
RestAssessmentRequest restAssessmentRequest = new RestAssessmentRequest();
restAssessmentRequest.setWorkspaceUserEntityId(workspaceUserEntity == null ? null : workspaceUserEntity.getId());
restAssessmentRequest.setWorkspaceUserIdentifier(compositeAssessmentRequest.getCourseStudentIdentifier().toId());
restAssessmentRequest.setUserEntityId(userEntity == null ? null : userEntity.getId());
restAssessmentRequest.setAssessmentRequestDate(compositeAssessmentRequest.getAssessmentRequestDate());
restAssessmentRequest.setEvaluationDate(evaluationDate);
restAssessmentRequest.setPassing(passing);
restAssessmentRequest.setGraded(graded);
restAssessmentRequest.setAssignmentsDone(assignmentsDone);
restAssessmentRequest.setAssignmentsTotal(assignmentsTotal);
restAssessmentRequest.setEnrollmentDate(compositeAssessmentRequest.getCourseEnrollmentDate());
restAssessmentRequest.setFirstName(compositeAssessmentRequest.getFirstName());
restAssessmentRequest.setLastName(compositeAssessmentRequest.getLastName());
restAssessmentRequest.setStudyProgramme(compositeAssessmentRequest.getStudyProgramme());
restAssessmentRequest.setWorkspaceEntityId(workspaceEntity == null ? null : workspaceEntity.getId());
restAssessmentRequest.setWorkspaceName(compositeAssessmentRequest.getCourseName());
restAssessmentRequest.setWorkspaceNameExtension(compositeAssessmentRequest.getCourseNameExtension());
restAssessmentRequest.setWorkspaceUrlName(workspaceEntity == null ? null : workspaceEntity.getUrlName());
return restAssessmentRequest;
}
use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReplyState 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;
}
use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReplyState in project muikku by otavanopisto.
the class WorkspaceRESTService method getEvaluatedAssignmentInfo.
@GET
@Path("/workspaces/{WORKSPACEENTITYID}/evaluatedAssignmentInfo")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response getEvaluatedAssignmentInfo(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId) {
Map<String, Long> result = new HashMap<String, Long>();
// Workspace and user
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityById(workspaceEntityId);
if (workspaceEntity == null) {
return Response.status(Status.NOT_FOUND).build();
}
UserEntity userEntity = sessionController.getLoggedUserEntity();
// Total number of evaluated assignments
List<WorkspaceMaterial> evaluatedAssignments = workspaceMaterialController.listVisibleWorkspaceMaterialsByAssignmentType(workspaceEntity, WorkspaceMaterialAssignmentType.EVALUATED);
result.put("assignmentsTotal", new Long(evaluatedAssignments.size()));
// Done number of evaluated assignments
List<WorkspaceMaterialReplyState> replyStates = new ArrayList<WorkspaceMaterialReplyState>();
replyStates.add(WorkspaceMaterialReplyState.FAILED);
replyStates.add(WorkspaceMaterialReplyState.PASSED);
replyStates.add(WorkspaceMaterialReplyState.SUBMITTED);
Long assignmentsDone = workspaceMaterialReplyController.getReplyCountByUserEntityAndReplyStatesAndWorkspaceMaterials(userEntity.getId(), replyStates, evaluatedAssignments);
result.put("assignmentsDone", assignmentsDone);
return Response.ok(result).build();
}
Aggregations