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