Skip to content

Commit

Permalink
feat: update stats API (#568)
Browse files Browse the repository at this point in the history
Co-authored-by: Muhammad Faraz  Maqsood <[email protected]>
  • Loading branch information
Faraz32123 and Muhammad Faraz Maqsood authored Jul 18, 2024
1 parent ec8108f commit ebd31d9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions openedx/features/sdaia_features/course_progress/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,25 @@ def get(self, request):
criteria=F("badge_class__criteria"),
image=F("badge_class__image"),
)
transformed_user_badges = []
for badge in user_badges:
badge["course_id"] = str(badge["course_id"])
badge_image = badge["image"]
transformed_user_badges.append(
{
"image_url": badge["image_url"],
"assertion_url": badge["assertion_url"],
"created": badge["created"],
"badge_class": {
"slug": badge["slug"],
"issuing_component": badge["issuing_component"],
"display_name": badge["display_name"],
"course_id": str(badge["course_id"]),
"description": badge["description"],
"criteria": badge["criteria"],
"image_url": f"{settings.LMS_ROOT_URL}{settings.MEDIA_URL}{badge_image}",
},
}
)

############ USER SCORE ############
leaderboard = LeaderboardEntry.objects.filter(user=user)
Expand All @@ -138,7 +155,7 @@ def get(self, request):
"enrolled_programs": no_of_programs,
"score": score,
"user_certificates": user_certificates,
"user_badges": user_badges,
"user_badges": transformed_user_badges,
},
)

Expand Down

0 comments on commit ebd31d9

Please sign in to comment.