From 9f4ec011117d984c735dcdc8045a45bf22961dbc Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Date: Fri, 1 Nov 2024 23:18:21 -0400 Subject: [PATCH] Update serializers.py --- breathecode/assessment/serializers.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/breathecode/assessment/serializers.py b/breathecode/assessment/serializers.py index e7f46a9f2..d2acfacc9 100644 --- a/breathecode/assessment/serializers.py +++ b/breathecode/assessment/serializers.py @@ -162,7 +162,6 @@ class HookUserAssessmentSerializer(serpy.Serializer): status_text = serpy.Field() conversion_info = serpy.Field() - total_score = serpy.Field() comment = serpy.Field() started_at = serpy.Field() @@ -170,6 +169,16 @@ class HookUserAssessmentSerializer(serpy.Serializer): created_at = serpy.Field() + summary = serpy.MethodField() + def get_summary(self, obj): + total_score, last_one = obj.get_score() + + last_answer = None + if last_one is not None: + last_answer = AnswerSmallSerializer(last_one).data + + return {"last_answer": last_answer, "live_score": total_score} + class PublicUserAssessmentSerializer(serpy.Serializer): id = serpy.Field()