diff --git a/src/back/tests/views.py b/src/back/tests/views.py index 1906a5351..5ba64630c 100644 --- a/src/back/tests/views.py +++ b/src/back/tests/views.py @@ -144,7 +144,7 @@ class TestResultCreate(generics.ListCreateAPIView): serializer.save(attempt=test_attempt) self.update_testing(user, test_info) - return Response(test_info['is_passed']) + return Response(data={'score': test_info['score'], 'answered_questions_total': test_info['answered_questions_total']}) def create_test_attempt(self, user, test_info): test = test_info['test'] @@ -163,6 +163,7 @@ class TestResultCreate(generics.ListCreateAPIView): answer_ids = [item['answer'] for item in request.data] test_answers = TestAnswer.objects.filter(id__in=answer_ids) test = test_answers[0].question.test + answered_questions_total = test_answers.values('question').distinct().count() correct_questions = sum( TestAnswer.objects.filter( @@ -179,7 +180,8 @@ class TestResultCreate(generics.ListCreateAPIView): result = { "is_passed": correct_questions >= pass_perc, "score": correct_questions, - "test": test + "test": test, + "answered_questions_total": answered_questions_total, } return result