Commit f581f4f8 by Matt Drayer Committed by Jonathan Piacenti

mattdrayer/api: Check course average aggregation result before modifying

parent c04fcc7b
...@@ -78,7 +78,7 @@ class StudentGradebook(TimeStampedModel): ...@@ -78,7 +78,7 @@ class StudentGradebook(TimeStampedModel):
# Calculate the class average # Calculate the class average
course_avg = queryset.aggregate(Avg('grade'))['grade__avg'] course_avg = queryset.aggregate(Avg('grade'))['grade__avg']
if gradebook_user_count < total_user_count: if course_avg is not None and gradebook_user_count < total_user_count:
# Take into account any ungraded students (assumes zeros for grades...) # Take into account any ungraded students (assumes zeros for grades...)
course_avg = course_avg / total_user_count * gradebook_user_count course_avg = course_avg / total_user_count * gradebook_user_count
......
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