Commit 8040cd80 by Matt Drayer Committed by Jonathan Piacenti

mattdrayer/api-points-possible-zero-check: Addressed divide by zero case

parent a7d3d9d4
...@@ -161,6 +161,7 @@ def calculate_proforma_grade(grade_summary, grading_policy): ...@@ -161,6 +161,7 @@ def calculate_proforma_grade(grade_summary, grading_policy):
remaining_weight = 1.00 remaining_weight = 1.00
proforma_grade = 0.00 proforma_grade = 0.00
totaled_scores = grade_summary['totaled_scores'] totaled_scores = grade_summary['totaled_scores']
grade = 0.00
for section in totaled_scores: for section in totaled_scores:
points_earned = 0.00 points_earned = 0.00
points_possible = 0.00 points_possible = 0.00
...@@ -172,6 +173,7 @@ def calculate_proforma_grade(grade_summary, grading_policy): ...@@ -172,6 +173,7 @@ def calculate_proforma_grade(grade_summary, grading_policy):
if score.earned or (score.due and score.due < timezone.now()): if score.earned or (score.due and score.due < timezone.now()):
points_earned = points_earned + score.earned points_earned = points_earned + score.earned
points_possible = points_possible + score.possible points_possible = points_possible + score.possible
if points_possible:
grade = points_earned / points_possible grade = points_earned / points_possible
section_policy = next((policy for policy in grading_policy['GRADER'] if policy['type'] == section), None) section_policy = next((policy for policy in grading_policy['GRADER'] if policy['type'] == section), None)
if section_policy is not None: if section_policy is not None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment