Skip to content

Commit

Permalink
#2781 when in percentage grade mode, translate to the proper score fo…
Browse files Browse the repository at this point in the history
…r category scores. When in letter grade, use the schema. (sakaiproject#2871)
  • Loading branch information
steveswinsburg authored and payten committed Jun 19, 2016
1 parent 03ea465 commit 359ab45
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3031,15 +3031,29 @@ public Object doInHibernate(Session session) throws HibernateException, SQLExcep
public Double calculateCategoryScore(Object gradebook, String studentUuid, CategoryDefinition category, final List<org.sakaiproject.service.gradebook.shared.Assignment> viewableAssignments, Map<Long,String> gradeMap) {

Gradebook gb = (Gradebook) gradebook;


// used for translating letter grades
final Map<String, Double> gradingSchema = gb.getSelectedGradeMapping().getGradeMap();

//collect the data and turn it into a list of AssignmentGradeRecords
//this is the info that is compatible with both applyDropScores and the calculateCategoryScore method
List<AssignmentGradeRecord> gradeRecords = new ArrayList<>();
for(org.sakaiproject.service.gradebook.shared.Assignment assignment: viewableAssignments) {

Long assignmentId = assignment.getId();
Double grade = NumberUtils.createDouble(gradeMap.get(assignmentId));

String rawGrade = gradeMap.get(assignmentId);
Double pointsPossible = assignment.getPoints();
Double grade = null;

//determine the grade we should be using depending on the grading type
if (gb.getGrade_type() == GradebookService.GRADE_TYPE_PERCENTAGE) {
grade = calculateEquivalentPointValueForPercent(pointsPossible, NumberUtils.createDouble(rawGrade));
}
if (gb.getGrade_type() == GradebookService.GRADE_TYPE_LETTER){
grade = gradingSchema.get(rawGrade);
}

//recreate the category (required fields only)
Category c = new Category();
c.setId(category.getId());
Expand Down Expand Up @@ -3121,7 +3135,7 @@ private Double calculateCategoryScore(String studentUuid, Long categoryId, List<
Assignment assignment = gradeRecord.getAssignment();

//check category ids match, otherwise skip
if(assignment.getCategory() != null && categoryId != null && categoryId.longValue() != assignment.getCategory().getId().longValue()){
if(assignment.getCategory() != null && categoryId.longValue() != assignment.getCategory().getId().longValue()){
continue;
}

Expand Down

0 comments on commit 359ab45

Please sign in to comment.