Commit 79405d9a by Chris Dodge Committed by Jonathan Piacenti

gradebook appears to bomb if there is no data to aggregate

parent 0bd39386
......@@ -77,6 +77,7 @@ class StudentGradebook(TimeStampedModel):
queryset = queryset.exclude(user__in=exclude_users)
gradebook_user_count = len(queryset)
if gradebook_user_count:
# Calculate the class average
course_avg = queryset.aggregate(Avg('grade'))['grade__avg']
if course_avg is not None and gradebook_user_count < total_user_count:
......@@ -88,6 +89,7 @@ class StudentGradebook(TimeStampedModel):
data['course_max'] = queryset.aggregate(Max('grade'))['grade__max']
data['course_min'] = queryset.aggregate(Min('grade'))['grade__min']
data['course_count'] = queryset.aggregate(Count('grade'))['grade__count']
# Construct the leaderboard as a queryset
data['queryset'] = queryset.values(
'user__id',
......
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