Skip to content

Commit

Permalink
SAK-33964 Ensure every mapping in grading schema is added to dataset (s…
Browse files Browse the repository at this point in the history
…akaiproject#5350)

* Remove unused code and cleanup other compiler warnings

* Add rebel.xml to gitignore so that JRebel project config is not committed

* SAK-33964 ensure the course grade dataset contains an entry for everything in the grading schema
  • Loading branch information
steveswinsburg authored and ern committed Feb 28, 2018
1 parent 15a5240 commit b644148
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public CourseGradeSummary getCourseGradeSummary(final EntityView view, final Map

// get the course grades and re-map to summary. Also sorts the data so it is ready for the consumer to use
final Map<String, CourseGrade> courseGrades = this.businessService.getCourseGrades(siteId, gradingSchema);

return reMap(courseGrades, gradingSchema.keySet());
}

Expand Down Expand Up @@ -329,7 +329,7 @@ private GbRole getUserRole(final String siteId) {

/**
* Re-map the course grades returned from the business service into our CourseGradeSummary object for returning on the REST API.
*
*
* @param courseGrades map of student to course grade
* @param gradingSchema the grading schema that has the order
* @return
Expand All @@ -339,15 +339,20 @@ private CourseGradeSummary reMap(final Map<String, CourseGrade> courseGrades, fi
courseGrades.forEach((k,v) -> {
summary.add(v.getDisplayGrade());
});

//sort the map based on the ordered schema
Map<String, Integer> originalData = summary.getDataset();
Map<String, Integer> sortedData = new LinkedHashMap<>();
final Map<String, Integer> originalData = summary.getDataset();
final Map<String, Integer> sortedData = new LinkedHashMap<>();
order.forEach(o -> {
sortedData.put(o, originalData.get(o));
// data set must contain everything in the grading schema
Integer value = originalData.get(o);
if (value == null) {
value = 0;
}
sortedData.put(o, value);
});
summary.setDataset(sortedData);

return summary;
}

Expand Down

0 comments on commit b644148

Please sign in to comment.