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.
#3432 Add graph to show course grade distribution (sakaiproject#4213)
* Remove unused code and cleanup other compiler warnings * #3432 made the hart component common and wired up the grading schema page to add it * #3432 Add first iteration of the bar chart for course grade stats * #3432 invert x-axis of chart. Add info about students with overrides that may affect the distribution Move comparators out of business service into own classes. * #3432 Add stats underneath the graph Add note about clicking save changes
- Loading branch information
1 parent
d4813e6
commit 7c3f39d
Showing
15 changed files
with
613 additions
and
285 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
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
39 changes: 39 additions & 0 deletions
39
...bookng/tool/src/java/org/sakaiproject/gradebookng/business/AssignmentGradeComparator.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,39 @@ | ||
package org.sakaiproject.gradebookng.business; | ||
|
||
import java.util.Comparator; | ||
|
||
import org.apache.commons.lang.builder.CompareToBuilder; | ||
import org.apache.commons.lang.math.NumberUtils; | ||
import org.sakaiproject.gradebookng.business.model.GbGradeInfo; | ||
import org.sakaiproject.gradebookng.business.model.GbStudentGradeInfo; | ||
|
||
/** | ||
* Comparator class for sorting an assignment by the grades. | ||
* | ||
* Note that this must have the assignmentId set into it so we can extract the appropriate grade entry from the map that each student | ||
* has. | ||
* | ||
*/ | ||
public class AssignmentGradeComparator implements Comparator<GbStudentGradeInfo> { | ||
|
||
private final long assignmentId; | ||
|
||
public AssignmentGradeComparator(final long assignmentId) { | ||
this.assignmentId = assignmentId; | ||
} | ||
|
||
@Override | ||
public int compare(final GbStudentGradeInfo g1, final GbStudentGradeInfo g2) { | ||
|
||
final GbGradeInfo info1 = g1.getGrades().get(this.assignmentId); | ||
final GbGradeInfo info2 = g2.getGrades().get(this.assignmentId); | ||
|
||
// for proper number ordering, these have to be numerical | ||
final Double grade1 = (info1 != null) ? NumberUtils.toDouble(info1.getGrade()) : null; | ||
final Double grade2 = (info2 != null) ? NumberUtils.toDouble(info2.getGrade()) : null; | ||
|
||
return new CompareToBuilder().append(grade1, grade2).toComparison(); | ||
|
||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...ookng/tool/src/java/org/sakaiproject/gradebookng/business/CategorySubtotalComparator.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,31 @@ | ||
package org.sakaiproject.gradebookng.business; | ||
|
||
import java.util.Comparator; | ||
|
||
import org.apache.commons.lang.builder.CompareToBuilder; | ||
import org.sakaiproject.gradebookng.business.model.GbStudentGradeInfo; | ||
|
||
/** | ||
* Comparator class for sorting a category by the subtotals | ||
* | ||
* Note that this must have the categoryId set into it so we can extract the appropriate grade entry from the map that each student has. | ||
* | ||
*/ | ||
public class CategorySubtotalComparator implements Comparator<GbStudentGradeInfo> { | ||
|
||
private final long categoryId; | ||
|
||
public CategorySubtotalComparator(final long categoryId) { | ||
this.categoryId = categoryId; | ||
} | ||
|
||
@Override | ||
public int compare(final GbStudentGradeInfo g1, final GbStudentGradeInfo g2) { | ||
|
||
final Double subtotal1 = g1.getCategoryAverages().get(this.categoryId); | ||
final Double subtotal2 = g2.getCategoryAverages().get(this.categoryId); | ||
|
||
return new CompareToBuilder().append(subtotal1, subtotal2).toComparison(); | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/CourseGradeComparator.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,60 @@ | ||
package org.sakaiproject.gradebookng.business; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.commons.lang.builder.CompareToBuilder; | ||
import org.sakaiproject.gradebookng.business.model.GbStudentGradeInfo; | ||
import org.sakaiproject.service.gradebook.shared.CourseGrade; | ||
import org.sakaiproject.service.gradebook.shared.GradebookInformation; | ||
|
||
/** | ||
* Comparator class for sorting by course grade, first by the letter grade's index in the gradebook's grading scale and then by the | ||
* number of points the student has earned. | ||
*/ | ||
public class CourseGradeComparator implements Comparator<GbStudentGradeInfo> { | ||
|
||
private List<String> ascendingGrades; | ||
|
||
public CourseGradeComparator(final GradebookInformation gradebookInformation) { | ||
final Map<String, Double> gradeMap = gradebookInformation.getSelectedGradingScaleBottomPercents(); | ||
this.ascendingGrades = new ArrayList<>(gradeMap.keySet()); | ||
this.ascendingGrades.sort(new Comparator<String>() { | ||
@Override | ||
public int compare(final String a, final String b) { | ||
return new CompareToBuilder() | ||
.append(gradeMap.get(a), gradeMap.get(b)) | ||
.toComparison(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public int compare(final GbStudentGradeInfo g1, final GbStudentGradeInfo g2) { | ||
final CourseGrade cg1 = g1.getCourseGrade().getCourseGrade(); | ||
final CourseGrade cg2 = g2.getCourseGrade().getCourseGrade(); | ||
|
||
String letterGrade1 = cg1.getMappedGrade(); | ||
if (cg1.getEnteredGrade() != null) { | ||
letterGrade1 = cg1.getEnteredGrade(); | ||
} | ||
String letterGrade2 = cg2.getMappedGrade(); | ||
if (cg2.getEnteredGrade() != null) { | ||
letterGrade2 = cg2.getEnteredGrade(); | ||
} | ||
|
||
final int gradeIndex1 = this.ascendingGrades.indexOf(letterGrade1); | ||
final int gradeIndex2 = this.ascendingGrades.indexOf(letterGrade2); | ||
|
||
final Double calculatedGrade1 = cg1.getCalculatedGrade() == null ? null : Double.valueOf(cg1.getCalculatedGrade()); | ||
final Double calculatedGrade2 = cg2.getCalculatedGrade() == null ? null : Double.valueOf(cg2.getCalculatedGrade()); | ||
|
||
return new CompareToBuilder() | ||
.append(gradeIndex1, gradeIndex2) | ||
.append(calculatedGrade1, calculatedGrade2) | ||
.toComparison(); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/FirstNameComparator.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,27 @@ | ||
package org.sakaiproject.gradebookng.business; | ||
|
||
import java.text.Collator; | ||
import java.util.Comparator; | ||
|
||
import org.apache.commons.lang.builder.CompareToBuilder; | ||
import org.sakaiproject.user.api.User; | ||
|
||
/** | ||
* Comparator class for sorting a list of users by first name. | ||
* Secondary sort is on last name to maintain consistent order for those with the same first name | ||
*/ | ||
public class FirstNameComparator implements Comparator<User> { | ||
|
||
private final Collator collator = Collator.getInstance(); | ||
|
||
@Override | ||
public int compare(final User u1, final User u2) { | ||
this.collator.setStrength(Collator.PRIMARY); | ||
return new CompareToBuilder() | ||
.append(u1.getFirstName(), u2.getFirstName(), this.collator) | ||
.append(u1.getLastName(), u2.getLastName(), this.collator) | ||
.toComparison(); | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.