diff --git a/example_ans.json b/example_ans.json new file mode 100644 index 0000000..b678f9a --- /dev/null +++ b/example_ans.json @@ -0,0 +1,51 @@ + +16 +{ + "answers": [ + { + "question": 23, + "answer": 67 + }, + { + "question": 24, + "answer": 70 + }, + { + "question": 25, + "answer": 74 + }, + { + "question": 26, + "answer": 81 + }, + { + "question": 27, + "answer": 85 + } + ] +} + +{ + "answers": [ + { + "question": 23, + "answer": 67 + }, + { + "question": 24, + "answer": 70 + }, + { + "question": 25, + "answer": 74 + }, + { + "question": 26, + "answer": 81 + }, + { + "question": 27, + "answer": 84 + } + ] +} \ No newline at end of file diff --git a/test.json b/test.json index 97bf228..c40bf9b 100644 --- a/test.json +++ b/test.json @@ -1,124 +1,124 @@ { - "name": "fiz1", + "name": "Matematyka 1", "passing_score": 3, "questions": [ { - "name": "Jaki jest najwyższy szczyt w Polsce ? ", + "name": "jaki jest wzór na pole powierzchni prostopadłościanu?", "description": "ramię głowicy", "answers": [ { - "description": "Rysy", + "description": "P = a*b*c", + "is_correct": false + }, + { + "description": "P = 2(a*b+b*c+a*c)", "is_correct": true }, { - "description": "Śnieżka", + "description": "P = a*b + b*c + a*c", "is_correct": false }, { - "description": "Babia góra", - "is_correct": false - }, - { - "description": "Tarnica", + "description": "P = 2*a*b*c", "is_correct": false } ] }, { - "name": "Jaką długość ma Odra na terenie Polski ?", + "name": "ile wynosi pole kwadratu o boku długości 4cm", "description": "złącze.", "answers": [ { - "description": "854", + "description": "12", "is_correct": false }, { - "description": "742", - "is_correct": true - }, - { - "description": "772", + "description": "8", "is_correct": false }, { - "description": "808", + "description": "16", + "is_correct": false + }, + { + "description": "20", "is_correct": false } ] }, { - "name": "Jaką wysokość ma śnieżka?", + "name": "ile wynosi objętość prostopadłościanu o wymiarach a=4, b=3,c=8", "description": "kieszeń napędu", "answers": [ { - "description": "1346", + "description": "56", "is_correct": false }, { - "description": "1603", + "description": "96", "is_correct": true }, { - "description": "2000", + "description": "82", "is_correct": false }, { - "description": "1863", + "description": "106", "is_correct": false } ] }, { - "name": "która rzeka jest najdłuższa", + "name": "Jaką miarę na kąt którego cosinus wynosi 1?", "description": "płytka drukowana .", "answers": [ { - "description": "Warta", - "is_correct": false - }, - { - "description": "Narew", - "is_correct": false - }, - { - "description": "Wisła", + "description": "0", "is_correct": true }, { - "description": "Bug", + "description": "45", + "is_correct": false + }, + { + "description": "90", + "is_correct": false + }, + { + "description": "30", "is_correct": false } ] }, { - "name": "Która rzeka nie przebiega przez Poznań?", + "name": "Jaka jest pochodna funkcji f(x) = 3x+1?", "description": "karta dźwiękowa.", "answers": [ { - "description": "Warta", + "description": "4", "is_correct": false }, { - "description": "Głuszynka", - "is_correct": false - }, - { - "description": "Wierzbak", - "is_correct": false - }, - { - "description": "Noteć", + "description": "3", "is_correct": true + }, + { + "description": "0", + "is_correct": false + }, + { + "description": "1", + "is_correct": false } ] } ], "category": { - "name": "Geografia" + "name": "Matematyka" } -} \ No newline at end of file +} diff --git a/trials/views.py b/trials/views.py index 12dcd13..44530ab 100644 --- a/trials/views.py +++ b/trials/views.py @@ -42,7 +42,9 @@ class TestValidateAPIView(views.APIView): def post(self, request, test_id, **kwargs): test = Test.objects.get(id=test_id) + import pdb;pdb.set_trace() score = self.get_score(test, request.data["answers"]) + import pdb;pdb.set_trace() status = score >= test.passing_score return Response({ "status": self.PASSED.get(status, self.UNKNOWN), diff --git a/users/views.py b/users/views.py index 0d42270..d6705ec 100644 --- a/users/views.py +++ b/users/views.py @@ -28,7 +28,7 @@ class RegisterViewSet(generics.GenericAPIView): last_name=data["last_name"], password=data["password"] ) - return Response({"detail": "Done"}, status=status.HTTP_200_OK) + return Response({"detail": "Konto zostało pomyślnie założone. Możesz się zalogować!"}, status=status.HTTP_200_OK) else: return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)