chore [P-01]: подтянул бэк
This commit is contained in:
commit
f81604eec4
2 files changed
+4
-3
No files matched your search
@@ -94,7 +94,7 @@ class TestAttemptSerializer(serializers.ModelSerializer):
|
|||||||
class TestResultSerializer(serializers.ModelSerializer):
|
class TestResultSerializer(serializers.ModelSerializer):
|
||||||
attempt = TestAttemptSerializer(read_only=True)
|
attempt = TestAttemptSerializer(read_only=True)
|
||||||
answer = serializers.PrimaryKeyRelatedField(queryset=TestAnswer.objects.all(), many=False)
|
answer = serializers.PrimaryKeyRelatedField(queryset=TestAnswer.objects.all(), many=False)
|
||||||
comment = serializers.CharField(allow_null=True)
|
comment = serializers.CharField(allow_null=True, required=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TestResult
|
model = TestResult
|
||||||
|
|||||||
@@ -355,7 +355,8 @@ class TestResultView(generics.ListCreateAPIView):
|
|||||||
self.update_testing(user, test_info)
|
self.update_testing(user, test_info)
|
||||||
|
|
||||||
return Response(data={'score': test_info['score'],
|
return Response(data={'score': test_info['score'],
|
||||||
'answered_questions_total': test_info['answered_questions_total']})
|
'answered_questions_total': test_info['answered_questions_total'],
|
||||||
|
'is_passed': test_info['is_passed']})
|
||||||
|
|
||||||
def create_test_attempt(self, user, test_info):
|
def create_test_attempt(self, user, test_info):
|
||||||
"""Creates a new test attempt for the user."""
|
"""Creates a new test attempt for the user."""
|
||||||
@@ -396,7 +397,7 @@ class TestResultView(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
pass_perc = test_answers[0].question.test.pass_perc
|
pass_perc = test_answers[0].question.test.pass_perc
|
||||||
result = {
|
result = {
|
||||||
"is_passed": correct_questions >= pass_perc,
|
"is_passed": (correct_questions/answered_questions_total*100) >= pass_perc,
|
||||||
"score": correct_questions,
|
"score": correct_questions,
|
||||||
"test": test,
|
"test": test,
|
||||||
"answered_questions_total": answered_questions_total,
|
"answered_questions_total": answered_questions_total,
|
||||||
|
|||||||
Reference in new issue
Block a user