Search in sources :

Example 6 with WorkspaceMaterialReply

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);
}
Also used : WorkspaceMaterialReply(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply)

Example 7 with 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));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) WorkspaceMaterialReply(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply)

Example 8 with WorkspaceMaterialReply

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();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) WorkspaceMaterialReply(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply)

Example 9 with WorkspaceMaterialReply

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;
}
Also used : WorkspaceJournalEntry(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceJournalEntry) WorkspaceMaterialReply(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)

Example 10 with WorkspaceMaterialReply

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;
}
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

WorkspaceMaterialReply (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply)11 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)6 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)4 WorkspaceMaterialReplyState (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReplyState)3 EntityManager (javax.persistence.EntityManager)3 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)2 WorkspaceMaterialEvaluation (fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation)2 ArrayList (java.util.ArrayList)2 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)1 SupplementationRequest (fi.otavanopisto.muikku.plugins.evaluation.model.SupplementationRequest)1 RestAssignment (fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestAssignment)1 RestSupplementationRequest (fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestSupplementationRequest)1 WorkspaceGradingScale (fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale)1 WorkspaceJournalEntry (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceJournalEntry)1 WorkspaceMaterialField (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField)1 WorkspaceRootFolder (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceRootFolder)1 CompositeGradingScale (fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale)1 GradingScale (fi.otavanopisto.muikku.schooldata.entity.GradingScale)1 GradingScaleItem (fi.otavanopisto.muikku.schooldata.entity.GradingScaleItem)1