Commit cc8e929d by Matt Drayer Committed by Jonathan Piacenti

mattdrayer/api: Switched from created to modified date for grades leaderboard

parent c6b72c6e
...@@ -29,7 +29,7 @@ class CourseLeadersSerializer(serializers.Serializer): ...@@ -29,7 +29,7 @@ class CourseLeadersSerializer(serializers.Serializer):
avatar_url = serializers.CharField(source='user__profile__avatar_url') avatar_url = serializers.CharField(source='user__profile__avatar_url')
# Percentage grade (versus letter grade) # Percentage grade (versus letter grade)
grade = serializers.FloatField(source='grade') grade = serializers.FloatField(source='grade')
created = serializers.DateTimeField() recorded = serializers.DateTimeField(source='modified')
class CourseCompletionsLeadersSerializer(serializers.Serializer): class CourseCompletionsLeadersSerializer(serializers.Serializer):
......
...@@ -95,8 +95,8 @@ class StudentGradebook(TimeStampedModel): ...@@ -95,8 +95,8 @@ class StudentGradebook(TimeStampedModel):
'user__profile__title', 'user__profile__title',
'user__profile__avatar_url', 'user__profile__avatar_url',
'grade', 'grade',
'created')\ 'modified')\
.order_by('-grade', 'created')[:count] .order_by('-grade', 'modified')[:count]
# If a user_id value was provided, we need to provide some additional user-specific data to the caller # If a user_id value was provided, we need to provide some additional user-specific data to the caller
if user_id: if user_id:
user_grade = 0 user_grade = 0
...@@ -110,7 +110,7 @@ class StudentGradebook(TimeStampedModel): ...@@ -110,7 +110,7 @@ class StudentGradebook(TimeStampedModel):
user_time_scored = user_queryset.created user_time_scored = user_queryset.created
users_above = queryset.filter(grade__gte=user_grade)\ users_above = queryset.filter(grade__gte=user_grade)\
.exclude(user__id=user_id)\ .exclude(user__id=user_id)\
.exclude(grade=user_grade, created__gt=user_time_scored) .exclude(grade=user_grade, modified__gt=user_time_scored)
data['user_position'] = len(users_above) + 1 data['user_position'] = len(users_above) + 1
data['user_grade'] = user_grade data['user_grade'] = user_grade
......
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