Skip to content

Commit

Permalink
SAK-33706 order by submission id on anonymous assignments (sakaiproje…
Browse files Browse the repository at this point in the history
  • Loading branch information
bgarciaentornos authored and ern committed Dec 13, 2017
1 parent fd657d6 commit aa0dbd3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1640,13 +1641,18 @@ public void getSubmissionsZip(OutputStream out, String reference, String query)
List<AssignmentSubmission> submissions = new ArrayList<AssignmentSubmission>(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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand All @@ -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<String, String> 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);
Expand Down

0 comments on commit aa0dbd3

Please sign in to comment.