use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply in project muikku by otavanopisto.
the class WorkspaceMaterialReplyDAO method create.
public WorkspaceMaterialReply create(WorkspaceMaterial workspaceMaterial, WorkspaceMaterialReplyState state, Long userEntityId, Long numberOfTries, Date created, Date lastModified, Date submitted, Date withdrawn) {
WorkspaceMaterialReply workspaceMaterialReply = new WorkspaceMaterialReply();
workspaceMaterialReply.setWorkspaceMaterial(workspaceMaterial);
workspaceMaterialReply.setUserEntityId(userEntityId);
workspaceMaterialReply.setNumberOfTries(numberOfTries);
workspaceMaterialReply.setCreated(created);
workspaceMaterialReply.setLastModified(lastModified);
workspaceMaterialReply.setState(state);
workspaceMaterialReply.setSubmitted(submitted);
workspaceMaterialReply.setWithdrawn(withdrawn);
return persist(workspaceMaterialReply);
}
use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply in project muikku by otavanopisto.
the class WorkspaceMaterialReplyDAO method findByWorkspaceMaterialAndUserEntityId.
public WorkspaceMaterialReply findByWorkspaceMaterialAndUserEntityId(WorkspaceMaterial workspaceMaterial, Long userEntityId) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<WorkspaceMaterialReply> criteria = criteriaBuilder.createQuery(WorkspaceMaterialReply.class);
Root<WorkspaceMaterialReply> root = criteria.from(WorkspaceMaterialReply.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(WorkspaceMaterialReply_.workspaceMaterial), workspaceMaterial), criteriaBuilder.equal(root.get(WorkspaceMaterialReply_.userEntityId), userEntityId)));
return getSingleResult(entityManager.createQuery(criteria));
}
use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply in project muikku by otavanopisto.
the class WorkspaceMaterialReplyDAO method countByUserAndStatesAndMaterials.
public Long countByUserAndStatesAndMaterials(Long userEntityId, List<WorkspaceMaterialReplyState> replyStates, List<WorkspaceMaterial> materials) {
if (materials == null || materials.isEmpty()) {
return 0L;
}
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> criteria = criteriaBuilder.createQuery(Long.class);
Root<WorkspaceMaterialReply> root = criteria.from(WorkspaceMaterialReply.class);
criteria.select(criteriaBuilder.count(root));
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(WorkspaceMaterialReply_.userEntityId), userEntityId), root.get(WorkspaceMaterialReply_.state).in(replyStates), root.get(WorkspaceMaterialReply_.workspaceMaterial).in(materials)));
return entityManager.createQuery(criteria).getSingleResult();
}
use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply in project muikku by otavanopisto.
the class GuiderController method getStudentWorkspaceActivity.
public GuiderStudentWorkspaceActivity getStudentWorkspaceActivity(WorkspaceEntity workspaceEntity, SchoolDataIdentifier userIdentifier) {
UserEntity userEntity = userEntityController.findUserEntityByUserIdentifier(userIdentifier);
if (userEntity == null) {
return null;
}
GuiderStudentWorkspaceActivity activity = new GuiderStudentWorkspaceActivity();
activity.setLastVisit(workspaceVisitController.getLastVisit(workspaceEntity, userEntity));
activity.setNumVisits(workspaceVisitController.getNumVisits(workspaceEntity, userEntity));
WorkspaceJournalEntry workspaceJournalEntry = workspaceJournalController.findLatestsEntryByWorkspaceEntityAndUserEntity(workspaceEntity, userEntity);
if (workspaceJournalEntry != null) {
activity.setJournalEntryCount(workspaceJournalController.countEntriesByWorkspaceEntityAndUserEntity(workspaceEntity, userEntity));
activity.setLastJournalEntry(workspaceJournalEntry.getCreated());
}
List<WorkspaceMaterial> evaluatedAssignments = workspaceMaterialController.listVisibleWorkspaceMaterialsByAssignmentType(workspaceEntity, WorkspaceMaterialAssignmentType.EVALUATED);
for (WorkspaceMaterial evaluatedAssignment : evaluatedAssignments) {
WorkspaceMaterialReply workspaceMaterialReply = workspaceMaterialReplyController.findWorkspaceMaterialReplyByWorkspaceMaterialAndUserEntity(evaluatedAssignment, userEntity);
if (workspaceMaterialReply == null) {
activity.getEvaluables().addUnanswered();
} else {
switch(workspaceMaterialReply.getState()) {
case WITHDRAWN:
activity.getEvaluables().addAnswered(workspaceMaterialReply.getWithdrawn());
break;
case ANSWERED:
activity.getEvaluables().addAnswered(workspaceMaterialReply.getLastModified());
break;
case FAILED:
activity.getEvaluables().addFailed(workspaceMaterialReply.getSubmitted());
break;
case PASSED:
activity.getEvaluables().addPassed(workspaceMaterialReply.getSubmitted());
break;
case SUBMITTED:
activity.getEvaluables().addSubmitted(workspaceMaterialReply.getSubmitted());
break;
case UNANSWERED:
activity.getEvaluables().addUnanswered();
break;
case INCOMPLETE:
activity.getEvaluables().addIncomplete(workspaceMaterialReply.getLastModified());
break;
}
}
}
List<WorkspaceMaterial> exerciseAssignments = workspaceMaterialController.listVisibleWorkspaceMaterialsByAssignmentType(workspaceEntity, WorkspaceMaterialAssignmentType.EXERCISE);
for (WorkspaceMaterial exerciseAssignment : exerciseAssignments) {
WorkspaceMaterialReply workspaceMaterialReply = workspaceMaterialReplyController.findWorkspaceMaterialReplyByWorkspaceMaterialAndUserEntity(exerciseAssignment, userEntity);
if (workspaceMaterialReply == null) {
activity.getExercises().addUnanswered();
} else {
switch(workspaceMaterialReply.getState()) {
case UNANSWERED:
case ANSWERED:
case WITHDRAWN:
activity.getExercises().addUnanswered();
break;
case PASSED:
case FAILED:
case SUBMITTED:
case INCOMPLETE:
activity.getExercises().addAnswered(workspaceMaterialReply.getSubmitted());
break;
}
}
}
return activity;
}
use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply 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;
}
Aggregations