forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-31948 Don't order anonymous assignments by sortname. (sakaiprojec…
…t#3599) * SAK-31948 Sort exported sheet by anonymous ID. When exporting a spreadsheet of an assignment, sort by the anonymous ID rather then a user’s sort name. * SAK-31948 Sort Anonymous Grade Report by Anon ID. When showing the Grade report and it’s anonymous always sort based on the anonymous ID rather than the user’s surname.
- Loading branch information
Showing
3 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...pl/impl/src/java/org/sakaiproject/assignment/impl/sort/AnonymousSubmissionComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.sakaiproject.assignment.impl.sort; | ||
|
||
import org.sakaiproject.assignment.api.AssignmentSubmission; | ||
import org.sakaiproject.site.api.Site; | ||
import org.sakaiproject.site.cover.SiteService; | ||
import org.sakaiproject.user.api.User; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.text.Collator; | ||
import java.text.ParseException; | ||
import java.text.RuleBasedCollator; | ||
import java.util.Comparator; | ||
|
||
/** | ||
* Sorts assignment submissions by the submission's anonymous ID. | ||
*/ | ||
public class AnonymousSubmissionComparator implements Comparator<AssignmentSubmission> { | ||
|
||
private static Logger M_log = LoggerFactory.getLogger(AnonymousSubmissionComparator.class); | ||
|
||
private Collator collator; | ||
|
||
public AnonymousSubmissionComparator() { | ||
try { | ||
collator = new RuleBasedCollator(((RuleBasedCollator) Collator.getInstance()).getRules().replaceAll("<'\u005f'", "<' '<'\u005f'")); | ||
} catch (ParseException e) { | ||
// error with init RuleBasedCollator with rules | ||
// use the default Collator | ||
collator = Collator.getInstance(); | ||
M_log.warn(this + " AssignmentComparator cannot init RuleBasedCollator. Will use the default Collator instead. " + e); | ||
} | ||
} | ||
|
||
@Override | ||
public int compare(AssignmentSubmission a1, AssignmentSubmission a2) { | ||
int result; | ||
String name1 = a1.getAnonymousSubmissionId(); | ||
String name2 = a2.getAnonymousSubmissionId(); | ||
result = collator.compare(name1, name2); | ||
return result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters