diff --git a/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java b/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java index e8813387162d..c8ec7c5ff1d1 100644 --- a/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java +++ b/assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java @@ -75,6 +75,7 @@ import org.sakaiproject.assignment.api.model.AssignmentSubmissionSubmitter; import org.sakaiproject.assignment.api.model.AssignmentSupplementItemAttachment; import org.sakaiproject.assignment.api.model.AssignmentSupplementItemService; +import org.sakaiproject.assignment.impl.sort.AnonymousSubmissionComparator; import org.sakaiproject.assignment.impl.sort.AssignmentSubmissionComparator; import org.sakaiproject.assignment.impl.sort.UserComparator; import org.sakaiproject.assignment.persistence.AssignmentRepository; @@ -1640,13 +1641,18 @@ public void getSubmissionsZip(OutputStream out, String reference, String query) List submissions = new ArrayList(submitters.values()); StringBuilder exceptionMessage = new StringBuilder(); - + SortedIterator sortedIterator; + if (assignmentUsesAnonymousGrading(assignment)){ + sortedIterator = new SortedIterator(submissions.iterator(), new AnonymousSubmissionComparator()); + } else { + sortedIterator = new SortedIterator(submissions.iterator(), new AssignmentSubmissionComparator(applicationContext.getBean(AssignmentService.class), siteService, userDirectoryService)); + } if (allowGradeSubmission(reference)) { zipSubmissions(reference, assignment.getTitle(), assignment.getTypeOfGrade(), assignment.getTypeOfSubmission(), - new SortedIterator(submissions.iterator(), new AssignmentSubmissionComparator(applicationContext.getBean(AssignmentService.class), siteService, userDirectoryService)), + sortedIterator, out, exceptionMessage, withStudentSubmissionText, diff --git a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java index 31b76d5bb84f..f139243bfb60 100644 --- a/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java +++ b/assignment/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java @@ -11913,6 +11913,8 @@ protected int sizeResources(SessionState state) { returnResources.add(us); } } + // Have we found an anonymous assignment in the list. + hasOneAnon = hasOneAnon || assignmentService.assignmentUsesAnonymousGrading(assignment); } break; } @@ -11923,6 +11925,7 @@ protected int sizeResources(SessionState state) { String sort = ""; ascending = (String) state.getAttribute(SORTED_ASC); sort = (String) state.getAttribute(SORTED_BY); + if (MODE_INSTRUCTOR_GRADE_ASSIGNMENT.equals(mode) || MODE_INSTRUCTOR_GRADE_SUBMISSION.equals(mode) && (sort == null || !sort.startsWith("sorted_grade_submission_by"))) { ascending = (String) state.getAttribute(SORTED_GRADE_SUBMISSION_ASC); @@ -11942,16 +11945,9 @@ protected int sizeResources(SessionState state) { if (SORTED_GRADE_SUBMISSION_BY_LASTNAME.equals(sort) && (MODE_INSTRUCTOR_GRADE_ASSIGNMENT.equals(mode) || MODE_INSTRUCTOR_GRADE_SUBMISSION.equals(mode))) { String aRef = (String) state.getAttribute(EXPORT_ASSIGNMENT_REF); - try { - Assignment assignment = assignmentService.getAssignment(aRef); - if (assignment != null) { - Map props = assignment.getProperties(); - if (props != null) { - ac.setAnon(Boolean.valueOf(props.get(NEW_ASSIGNMENT_CHECK_ANONYMOUS_GRADING))); - } - } - } catch (IdUnusedException | PermissionException iue) { - // ignore, continue with default sort + Assignment assignment = getAssignment(aRef, "sizeResources", state); + if (assignment != null) { + ac.setAnon(assignmentService.assignmentUsesAnonymousGrading(assignment)); } } else if (hasOneAnon) { ac.setAnon(true);