return mascotMood on answer submission
The math-app frontend prototype drives a RobotMascot with a fixed set of
moods; this gives that animation an explicit backend signal. Complements
the existing Lesson.mascot_animation / LessonIntro.mascotAnimation, which
are unchanged.
serializers.py
- AnswerResponseSerializer: new mascotMood field.
views.py
- QuestionAnswerView: mascotMood = 'happy' for a correct answer else
'encourage', on both the fresh response and the idempotent-replay
response.
tests.py
- QuestionAnswerMascotMoodTests: correct -> happy, wrong -> encourage,
and the mood is preserved across an idempotent replay.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -199,6 +199,7 @@ class QuestionAnswerView(APIView):
|
||||
'correctOptionId': str(correct_choice.id) if correct_choice else '',
|
||||
'xpEarned': existing.xp_earned,
|
||||
'heartsRemaining': hearts.current_hearts if hearts else 5,
|
||||
'mascotMood': 'happy' if existing.correct else 'encourage',
|
||||
}
|
||||
return Response(AnswerResponseSerializer(data).data)
|
||||
|
||||
@@ -245,6 +246,7 @@ class QuestionAnswerView(APIView):
|
||||
'correctOptionId': str(correct_choice.id) if correct_choice else '',
|
||||
'xpEarned': xp_earned,
|
||||
'heartsRemaining': hearts_remaining if hearts_remaining is not None else 5,
|
||||
'mascotMood': 'happy' if choice.is_correct else 'encourage',
|
||||
}
|
||||
return Response(AnswerResponseSerializer(data).data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user