Search in sources :

Example 11 with WorkspaceAssessment

use of fi.otavanopisto.muikku.schooldata.entity.WorkspaceAssessment in project muikku by otavanopisto.

the class TranscriptOfRecordsController method listStudentAssessments.

public Map<SchoolDataIdentifier, WorkspaceAssessment> listStudentAssessments(SchoolDataIdentifier studentIdentifier) {
    List<WorkspaceAssessment> assessmentsByStudent = gradingController.listAssessmentsByStudent(studentIdentifier);
    Map<SchoolDataIdentifier, WorkspaceAssessment> result = new HashMap<>();
    for (WorkspaceAssessment assessment : assessmentsByStudent) {
        WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findWorkspaceUserEntityByWorkspaceUserIdentifier(assessment.getWorkspaceUserIdentifier());
        WorkspaceEntity workspaceEntity = workspaceUserEntity.getWorkspaceEntity();
        SchoolDataIdentifier workspaceIdentifier = new SchoolDataIdentifier(workspaceEntity.getIdentifier(), workspaceEntity.getDataSource().getIdentifier());
        if (!result.containsKey(workspaceIdentifier)) {
            result.put(workspaceIdentifier, assessment);
        } else {
            WorkspaceAssessment storedAssessment = result.get(workspaceIdentifier);
            if (assessment.getDate().after(storedAssessment.getDate()))
                result.put(workspaceIdentifier, assessment);
        }
    }
    return result;
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) WorkspaceAssessment(fi.otavanopisto.muikku.schooldata.entity.WorkspaceAssessment) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) HashMap(java.util.HashMap)

Example 12 with WorkspaceAssessment

use of fi.otavanopisto.muikku.schooldata.entity.WorkspaceAssessment in project muikku by otavanopisto.

the class AssessmentRequestNotificationStrategy method getStudentIdentifiersWithoutEvaluationActivity.

private List<SchoolDataIdentifier> getStudentIdentifiersWithoutEvaluationActivity(SearchResult searchResult) {
    List<SchoolDataIdentifier> studentIdentifiers = new ArrayList<>();
    for (Map<String, Object> result : searchResult.getResults()) {
        // Convert the search result id into SchoolDataIdentifier. Skip student if this fails.
        String studentId = (String) result.get("id");
        if (StringUtils.isBlank(studentId)) {
            logger.severe("Could not process user found from search index because it had a null id");
            continue;
        }
        String[] studentIdParts = studentId.split("/", 2);
        SchoolDataIdentifier studentIdentifier = studentIdParts.length == 2 ? new SchoolDataIdentifier(studentIdParts[0], studentIdParts[1]) : null;
        if (studentIdentifier == null) {
            logger.severe(String.format("Could not process user found from search index with id %s", studentId));
            continue;
        }
        // Find the student by SchoolDataIdentifier
        User student = userController.findUserByIdentifier(studentIdentifier);
        if (student != null) {
            if (student.getStudyStartDate() == null || student.getStudyEndDate() != null) {
                continue;
            }
            // Students that have started their studies in the last 60 days should not be notified
            // (given searchResult should not even contain these but let's check it once more, just in case)
            OffsetDateTime thresholdDateTime = OffsetDateTime.now().minusDays(NOTIFICATION_THRESHOLD_DAYS);
            if (student.getStudyStartDate().isAfter(thresholdDateTime)) {
                logger.severe(String.format("Skipping student id %s that just started studies", studentId));
                continue;
            }
            // Check if student has made any assessment requests. If they have, they don't need to be notified
            WorkspaceAssessmentRequest latestRequest = gradingController.findLatestAssessmentRequestByIdentifier(studentIdentifier);
            if (latestRequest != null) {
                continue;
            }
            // Check if student has any workspace assessments. If they have, they don't need to be notified
            WorkspaceAssessment latestAssessment = gradingController.findLatestWorkspaceAssessmentByIdentifier(studentIdentifier);
            if (latestAssessment != null) {
                continue;
            }
            // By this point, we can be certain that the student has to be notified
            studentIdentifiers.add(studentIdentifier);
        }
    }
    return studentIdentifiers;
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) WorkspaceAssessment(fi.otavanopisto.muikku.schooldata.entity.WorkspaceAssessment) User(fi.otavanopisto.muikku.schooldata.entity.User) OffsetDateTime(java.time.OffsetDateTime) WorkspaceAssessmentRequest(fi.otavanopisto.muikku.schooldata.entity.WorkspaceAssessmentRequest) ArrayList(java.util.ArrayList)

Aggregations

WorkspaceAssessment (fi.otavanopisto.muikku.schooldata.entity.WorkspaceAssessment)12 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)10 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)9 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)7 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)6 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)6 Path (javax.ws.rs.Path)6 SupplementationRequest (fi.otavanopisto.muikku.plugins.evaluation.model.SupplementationRequest)4 GradingScaleItem (fi.otavanopisto.muikku.schooldata.entity.GradingScaleItem)4 User (fi.otavanopisto.muikku.schooldata.entity.User)4 RestAssessment (fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestAssessment)3 RestSupplementationRequest (fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestSupplementationRequest)3 GradingScale (fi.otavanopisto.muikku.schooldata.entity.GradingScale)3 Workspace (fi.otavanopisto.muikku.schooldata.entity.Workspace)3 WorkspaceAssessmentRequest (fi.otavanopisto.muikku.schooldata.entity.WorkspaceAssessmentRequest)3 ArrayList (java.util.ArrayList)3 WorkspaceGradingScale (fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale)2 CompositeGradingScale (fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale)2 WorkspaceUser (fi.otavanopisto.muikku.schooldata.entity.WorkspaceUser)2 HashMap (java.util.HashMap)2