This commit is contained in:
Hubert Jankowski 2021-12-13 23:22:11 +01:00
parent f939051139
commit b9f012e864
4 changed files with 114 additions and 11 deletions

View File

@ -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

View File

@ -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(

115
test.json
View File

@ -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"
}
}

View File

@ -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"],