From b9f012e864525993e72a14bebf6305ebb191cc43 Mon Sep 17 00:00:00 2001 From: Hubert Jankowski Date: Mon, 13 Dec 2021 23:22:11 +0100 Subject: [PATCH] tests --- categories/urls.py | 2 +- questions/managers.py | 4 +- test.json | 115 +++++++++++++++++++++++++++++++++++++++--- trials/managers.py | 4 +- 4 files changed, 114 insertions(+), 11 deletions(-) diff --git a/categories/urls.py b/categories/urls.py index a61f94c..5757d97 100644 --- a/categories/urls.py +++ b/categories/urls.py @@ -2,7 +2,7 @@ from rest_framework.routers import DefaultRouter from categories.views import CategoryModelViewSet -router = DefaultRouter() +router = DefaultRouter(trailing_slash=False) router.register("items", CategoryModelViewSet) urlpatterns = router.urls diff --git a/questions/managers.py b/questions/managers.py index ee23398..0ad0e41 100644 --- a/questions/managers.py +++ b/questions/managers.py @@ -8,14 +8,16 @@ class QuestionManager(Manager): def create( self, *, answers=[], + name=None, test=None, description=None, **kwargs ): Answer = apps.get_model("answers", "Answer") instance = super().create( + name=name, test=test, - description=description, + description=name, ) for answer in answers: Answer.objects.create( diff --git a/test.json b/test.json index bda22ee..97bf228 100644 --- a/test.json +++ b/test.json @@ -1,23 +1,124 @@ { - "name": "asd", - "passing_score": 1, + "name": "fiz1", + "passing_score": 3, "questions": [ { - "name": "heja", - "description": "czesc", + "name": "Jaki jest najwyższy szczyt w Polsce ? ", + "description": "ramię głowicy", "answers": [ { - "description": "hejka_answer", + "description": "Rysy", + "is_correct": true + }, + { + "description": "Śnieżka", "is_correct": false }, { - "description": "hejka2_answer", + "description": "Babia góra", + "is_correct": false + }, + { + "description": "Tarnica", + "is_correct": false + } + + ] + }, + { + "name": "Jaką długość ma Odra na terenie Polski ?", + "description": "złącze.", + "answers": [ + { + "description": "854", + "is_correct": false + }, + { + "description": "742", + "is_correct": true + }, + { + "description": "772", + "is_correct": false + }, + { + "description": "808", + "is_correct": false + } + + ] + }, + { + "name": "Jaką wysokość ma śnieżka?", + "description": "kieszeń napędu", + "answers": [ + { + "description": "1346", + "is_correct": false + }, + { + "description": "1603", + "is_correct": true + }, + { + "description": "2000", + "is_correct": false + }, + { + "description": "1863", + "is_correct": false + } + + ] + }, + { + "name": "która rzeka jest najdłuższa", + "description": "płytka drukowana .", + "answers": [ + { + "description": "Warta", + "is_correct": false + }, + { + "description": "Narew", + "is_correct": false + }, + { + "description": "Wisła", + "is_correct": true + }, + { + "description": "Bug", + "is_correct": false + } + + ] + }, + { + "name": "Która rzeka nie przebiega przez Poznań?", + "description": "karta dźwiękowa.", + "answers": [ + { + "description": "Warta", + "is_correct": false + }, + { + "description": "Głuszynka", + "is_correct": false + }, + { + "description": "Wierzbak", + "is_correct": false + }, + { + "description": "Noteć", "is_correct": true } + ] } ], "category": { - "name": "Polski" + "name": "Geografia" } } \ No newline at end of file diff --git a/trials/managers.py b/trials/managers.py index 72c1fc9..a8b4335 100644 --- a/trials/managers.py +++ b/trials/managers.py @@ -31,8 +31,8 @@ class TestManager(Manager): test=instance ) for answer in question["answers"]: - import pdb; - pdb.set_trace() + # import pdb; + # pdb.set_trace() Answer.objects.create( description=answer["description"], is_correct=answer["is_correct"],