Commit b69d526a by Matt Drayer Committed by Jonathan Piacenti

mattdrayer/api-null-points-check: Ensure aggregate operation result

parent 59970d3f
......@@ -1561,9 +1561,10 @@ class CoursesLeadersList(SecureListAPIView):
data['points'] = user_points
points = queryset.aggregate(total=Sum('grade'))
users_total = CourseEnrollment.users_enrolled_in(course_key).exclude(id__in=exclude_users).count()
if users_total:
course_avg = round(points['total'] / float(users_total), 1)
if points and points['total'] is not None:
users_total = CourseEnrollment.users_enrolled_in(course_key).exclude(id__in=exclude_users).count()
if users_total:
course_avg = round(points['total'] / float(users_total), 1)
data['course_avg'] = course_avg
queryset = queryset.filter(student__is_active=True).values('student__id', 'student__username',
'student__profile__title',
......
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