Creating test
This commit is contained in:
parent
979fe8fff6
commit
065710d84f
@ -9,12 +9,13 @@ class QuestionManager(Manager):
|
|||||||
self, *,
|
self, *,
|
||||||
answers=[],
|
answers=[],
|
||||||
test=None,
|
test=None,
|
||||||
|
description=None,
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
Answer = apps.get_model("answers", "Answer")
|
Answer = apps.get_model("answers", "Answer")
|
||||||
instance = super().create(
|
instance = super().create(
|
||||||
test=test,
|
test=test,
|
||||||
description=kwargs.get("description"),
|
description=description,
|
||||||
)
|
)
|
||||||
for answer in answers:
|
for answer in answers:
|
||||||
Answer.objects.create(
|
Answer.objects.create(
|
||||||
|
@ -10,7 +10,7 @@ class Question(models.Model):
|
|||||||
related_name="questions"
|
related_name="questions"
|
||||||
)
|
)
|
||||||
name = models.CharField(max_length=200, default="")
|
name = models.CharField(max_length=200, default="")
|
||||||
description = models.TextField()
|
description = models.CharField(max_length=200)
|
||||||
points = models.PositiveSmallIntegerField(default=1)
|
points = models.PositiveSmallIntegerField(default=1)
|
||||||
|
|
||||||
def get_answers_secret(self):
|
def get_answers_secret(self):
|
||||||
|
@ -23,12 +23,16 @@ class TestManager(Manager):
|
|||||||
passing_score=kwargs.get("passing_score"),
|
passing_score=kwargs.get("passing_score"),
|
||||||
category=category[0]
|
category=category[0]
|
||||||
)
|
)
|
||||||
|
# import pdb;pdb.set_trace()
|
||||||
for question in questions:
|
for question in questions:
|
||||||
question_instance = Question.objects.create(
|
question_instance = Question.objects.create(
|
||||||
name=question["name"],
|
name=question["name"],
|
||||||
descripton=question["description"]
|
description=question["description"],
|
||||||
|
test=instance
|
||||||
)
|
)
|
||||||
for answer in question["answers"]:
|
for answer in question["answers"]:
|
||||||
|
import pdb;
|
||||||
|
pdb.set_trace()
|
||||||
Answer.objects.create(
|
Answer.objects.create(
|
||||||
description=answer["description"],
|
description=answer["description"],
|
||||||
is_correct=answer["is_correct"],
|
is_correct=answer["is_correct"],
|
||||||
|
Loading…
Reference in New Issue
Block a user