diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.properties b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.properties
index 7c217fbe0f0c..3638e50c1271 100644
--- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.properties
+++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.properties
@@ -312,14 +312,15 @@ no-students.label = There are no students with gradebook entries
gradebookpage.uncategorised = Uncategorized
label.statistics.title = Grade Statistics for {0}
-label.statistics.average = Average
-label.statistics.graded = Graded
-label.statistics.outof = Out of
-label.statistics.gradedoutof = {0} / {1}
-label.statistics.median = Median
-label.statistics.lowest = Lowest
-label.statistics.highest = Highest
-label.statistics.variance = Variance
+label.statistics.average = Average (Mean) Score
+label.statistics.averagevalue = {0} / {1} ({2})
+label.statistics.graded = Total Graded Scores
+label.statistics.median = Median Score
+label.statistics.medianvalue = {0} / {1} ({2})
+label.statistics.lowest = Lowest Score
+label.statistics.lowestvalue = {0} / {1} ({2})
+label.statistics.highest = Highest Score
+label.statistics.highestvalue = {0} / {1} ({2})
label.statistics.deviation = Standard Deviation
coursegrade.option.override = Course Grade Override
diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/FormatHelper.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/FormatHelper.java
index 0dc89fa657c7..22d0f4052a46 100644
--- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/FormatHelper.java
+++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/FormatHelper.java
@@ -11,19 +11,30 @@
public class FormatHelper {
/**
- * The value is a double (ie 12.34) that needs to be formatted as a percentage with two decimal places precision.
- *
+ * The value is a double (ie 12.34542) that needs to be formatted as a percentage with two decimal places precision.
+ * And drop off any .0 if no decimal places.
+ *
* @param score as a double
- * @return percentage to decimal places with a '%' for good measure
+ * @return double to decimal places
*/
- public static String formatDoubleAsPercentage(final Double score) {
+ public static String formatDoubleToTwoDecimalPlaces(final Double score) {
final NumberFormat df = NumberFormat.getInstance();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
df.setRoundingMode(RoundingMode.DOWN);
+ return formatGrade(df.format(score));
+ }
+
+ /**
+ * The value is a double (ie 12.34) that needs to be formatted as a percentage with two decimal places precision.
+ *
+ * @param score as a double
+ * @return percentage to decimal places with a '%' for good measure
+ */
+ public static String formatDoubleAsPercentage(final Double score) {
// TODO does the % need to be internationalised?
- return df.format(score) + "%";
+ return formatDoubleToTwoDecimalPlaces(score) + "%";
}
public static String formatStringAsPercentage(final String string) {
diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeStatisticsPanel.html b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeStatisticsPanel.html
index b9ec841e45e0..0df7df796162 100644
--- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeStatisticsPanel.html
+++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeStatisticsPanel.html
@@ -7,22 +7,18 @@
Assignment Statistics
-
-
-
-
+
+
-
-
-
-
+
+
diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeStatisticsPanel.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeStatisticsPanel.java
index de4c0a9a9873..be92a56ad19e 100644
--- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeStatisticsPanel.java
+++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/panels/GradeStatisticsPanel.java
@@ -18,6 +18,7 @@
import org.sakaiproject.gradebookng.business.GradebookNgBusinessService;
import org.sakaiproject.gradebookng.business.model.GbGradeInfo;
import org.sakaiproject.gradebookng.business.model.GbStudentGradeInfo;
+import org.sakaiproject.gradebookng.business.util.FormatHelper;
import org.sakaiproject.service.gradebook.shared.Assignment;
public class GradeStatisticsPanel extends Panel {
@@ -62,26 +63,20 @@ public void onInitialize() {
}
}
- add(new Label("graded", new StringResourceModel("label.statistics.gradedoutof",
- null, new Object[] {
- String.valueOf(allGrades.size()),
- String.valueOf(gradeInfo.size()) }).getString()));
- add(new Label("outof", String.valueOf(assignment.getPoints())));
+ add(new Label("graded", String.valueOf(allGrades.size())));
if (allGrades.size() > 0) {
Collections.sort(allGrades);
- add(new Label("average", String.valueOf(calculateAverage(allGrades))));
- add(new Label("median", String.valueOf(calculateMedian(allGrades))));
- add(new Label("lowest", String.valueOf(Collections.min(allGrades))));
- add(new Label("highest", String.valueOf(Collections.max(allGrades))));
- add(new Label("variance", String.valueOf(calculateVariance(allGrades))));
- add(new Label("deviation", String.valueOf(calculateStandardDeviation(allGrades))));
+ add(new Label("average", constructAverageLabel(allGrades, assignment)));
+ add(new Label("median", constructMedianLabel(allGrades, assignment)));
+ add(new Label("lowest", constructLowestLabel(allGrades, assignment)));
+ add(new Label("highest", constructHighestLabel(allGrades, assignment)));
+ add(new Label("deviation", constructStandardDeviationLabel(allGrades)));
} else {
add(new Label("average", "-"));
add(new Label("median", "-"));
add(new Label("lowest", "-"));
add(new Label("highest", "-"));
- add(new Label("variance", "-"));
add(new Label("deviation", "-"));
}
@@ -95,6 +90,56 @@ public void onClick(final AjaxRequestTarget target) {
});
}
+ private String constructAverageLabel(final List allGrades, final Assignment assignment) {
+ double average = calculateAverage(allGrades);
+ String averageFormatted = FormatHelper.formatDoubleToTwoDecimalPlaces(Double.valueOf(average));
+ Double total = assignment.getPoints();
+ String percentage = FormatHelper.formatDoubleAsPercentage(100 * (average / total.doubleValue()));
+
+ return (new StringResourceModel("label.statistics.averagevalue",
+ null,
+ new Object[] { averageFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage })).getString();
+ }
+
+ private String constructMedianLabel(final List allGrades, final Assignment assignment) {
+ double median = calculateMedian(allGrades);
+ String medianFormatted = FormatHelper.formatDoubleToTwoDecimalPlaces(Double.valueOf(median));
+ Double total = assignment.getPoints();
+ String percentage = FormatHelper.formatDoubleAsPercentage(100 * (median / total.doubleValue()));
+
+ return (new StringResourceModel("label.statistics.medianvalue",
+ null,
+ new Object[] { medianFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage })).getString();
+ }
+
+ private String constructLowestLabel(final List allGrades, final Assignment assignment) {
+ double lowest = Collections.min(allGrades);
+ String lowestFormatted = FormatHelper.formatDoubleToTwoDecimalPlaces(Double.valueOf(lowest));
+ Double total = assignment.getPoints();
+ String percentage = FormatHelper.formatDoubleAsPercentage(100 * (lowest / total.doubleValue()));
+
+ return (new StringResourceModel("label.statistics.lowestvalue",
+ null,
+ new Object[] { lowestFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage })).getString();
+ }
+
+ private String constructHighestLabel(final List allGrades, final Assignment assignment) {
+ double highest = Collections.max(allGrades);
+ String highestFormatted = FormatHelper.formatDoubleToTwoDecimalPlaces(Double.valueOf(highest));
+ Double total = assignment.getPoints();
+ String percentage = FormatHelper.formatDoubleAsPercentage(100 * (highest / total.doubleValue()));
+
+ return new StringResourceModel("label.statistics.highestvalue",
+ null,
+ new Object[] { highestFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage }).getString();
+ }
+
+ private String constructStandardDeviationLabel(final List allGrades) {
+ double deviation = calculateStandardDeviation(allGrades);
+
+ return FormatHelper.formatDoubleToTwoDecimalPlaces(Double.valueOf(deviation));
+ }
+
private double calculateAverage(final List allGrades) {
double sum = 0;
for (int i = 0; i < allGrades.size(); i++) {