From 73e827669e572b169f783fc8c7c71214d88ef388 Mon Sep 17 00:00:00 2001 From: Cja Date: Fri, 31 Jan 2025 12:25:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B2=20TestResultCreate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/back/tests/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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