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):
|
||||
attempt = TestAttemptSerializer(read_only=True)
|
||||
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:
|
||||
model = TestResult
|
||||
|
||||
@@ -355,7 +355,8 @@ class TestResultView(generics.ListCreateAPIView):
|
||||
self.update_testing(user, test_info)
|
||||
|
||||
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):
|
||||
"""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
|
||||
result = {
|
||||
"is_passed": correct_questions >= pass_perc,
|
||||
"is_passed": (correct_questions/answered_questions_total*100) >= pass_perc,
|
||||
"score": correct_questions,
|
||||
"test": test,
|
||||
"answered_questions_total": answered_questions_total,
|
||||
|
||||
Reference in new issue
Block a user