.
This commit is contained in:
+11
-13
@@ -40,8 +40,7 @@ class MarkAnatomyQuestionForm(Form):
|
|||||||
|
|
||||||
class AnatomyQuestionForm(ModelForm):
|
class AnatomyQuestionForm(ModelForm):
|
||||||
|
|
||||||
exams = ModelMultipleChoiceField(queryset=Exam.objects.all())
|
exams = ModelMultipleChoiceField(required=False, queryset=Exam.objects.all())
|
||||||
|
|
||||||
|
|
||||||
class Media:
|
class Media:
|
||||||
# Django also includes a few javascript files necessary
|
# Django also includes a few javascript files necessary
|
||||||
@@ -94,15 +93,13 @@ class AnatomyQuestionForm(ModelForm):
|
|||||||
# queryset=Exam.objects.all(),
|
# queryset=Exam.objects.all(),
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
if kwargs.get("instance"):
|
||||||
if kwargs.get('instance'):
|
|
||||||
# We get the 'initial' keyword argument or initialize it
|
# We get the 'initial' keyword argument or initialize it
|
||||||
# as a dict if it didn't exist.
|
# as a dict if it didn't exist.
|
||||||
initial = kwargs.setdefault('initial', {})
|
initial = kwargs.setdefault("initial", {})
|
||||||
# The widget for a ModelMultipleChoiceField expects
|
# The widget for a ModelMultipleChoiceField expects
|
||||||
# a list of primary key for the selected data.
|
# a list of primary key for the selected data.
|
||||||
initial['exams'] = [t.pk for t in
|
initial["exams"] = [t.pk for t in kwargs["instance"].exams.all()]
|
||||||
kwargs['instance'].exams.all()]
|
|
||||||
|
|
||||||
ModelForm.__init__(self, *args, **kwargs)
|
ModelForm.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
@@ -117,7 +114,7 @@ class AnatomyQuestionForm(ModelForm):
|
|||||||
old_save_m2m()
|
old_save_m2m()
|
||||||
# This is where we actually link the pizza with toppings
|
# This is where we actually link the pizza with toppings
|
||||||
instance.exams.clear()
|
instance.exams.clear()
|
||||||
for exam in self.cleaned_data['exams']:
|
for exam in self.cleaned_data["exams"]:
|
||||||
instance.exams.add(exam)
|
instance.exams.add(exam)
|
||||||
|
|
||||||
self.save_m2m = save_m2m
|
self.save_m2m = save_m2m
|
||||||
@@ -152,7 +149,7 @@ AnswerFormSet = inlineformset_factory(
|
|||||||
fields=["answer", "status"],
|
fields=["answer", "status"],
|
||||||
widgets={
|
widgets={
|
||||||
"answer": Textarea(
|
"answer": Textarea(
|
||||||
attrs={"required": "true", "minlength": 2, "maxlength": 500, 'rows': 3}
|
attrs={"required": "true", "minlength": 2, "maxlength": 500, "rows": 3}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
exclude=[],
|
exclude=[],
|
||||||
@@ -168,7 +165,7 @@ AnswerUpdateFormSet = inlineformset_factory(
|
|||||||
fields=["answer", "status"],
|
fields=["answer", "status"],
|
||||||
widgets={
|
widgets={
|
||||||
"answer": Textarea(
|
"answer": Textarea(
|
||||||
attrs={"required": "true", "minlength": 2, "maxlength": 500, 'rows': 3}
|
attrs={"required": "true", "minlength": 2, "maxlength": 500, "rows": 3}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
exclude=[],
|
exclude=[],
|
||||||
@@ -178,19 +175,20 @@ AnswerUpdateFormSet = inlineformset_factory(
|
|||||||
field_classes="testing",
|
field_classes="testing",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ExaminationForm(ModelForm):
|
class ExaminationForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Examination
|
model = Examination
|
||||||
fields = ['examination']
|
fields = ["examination"]
|
||||||
|
|
||||||
|
|
||||||
class StructureForm(ModelForm):
|
class StructureForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Structure
|
model = Structure
|
||||||
fields = ['structure']
|
fields = ["structure"]
|
||||||
|
|
||||||
|
|
||||||
class BodyPartForm(ModelForm):
|
class BodyPartForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = BodyPart
|
model = BodyPart
|
||||||
fields = ['bodypart']
|
fields = ["bodypart"]
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.1.3 on 2020-12-28 22:35
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('anatomy', '0014_exam_time_limit'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='exam',
|
||||||
|
name='time_limit',
|
||||||
|
field=models.IntegerField(default=5400, help_text='Exam time limit (in seconds)'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# Generated by Django 3.1.3 on 2020-12-28 22:35
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('physics', '0002_auto_20201216_2207'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='question',
|
||||||
|
name='a_feedback',
|
||||||
|
field=models.TextField(blank=True, help_text='Feedback for answer'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='question',
|
||||||
|
name='b_feedback',
|
||||||
|
field=models.TextField(blank=True, help_text='Feedback for answer'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='question',
|
||||||
|
name='c_feedback',
|
||||||
|
field=models.TextField(blank=True, help_text='Feedback for answer'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='question',
|
||||||
|
name='d_feedback',
|
||||||
|
field=models.TextField(blank=True, help_text='Feedback for answer'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='question',
|
||||||
|
name='e_feedback',
|
||||||
|
field=models.TextField(blank=True, help_text='Feedback for answer'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -33,6 +33,10 @@ class Question(models.Model):
|
|||||||
a_answer = models.BooleanField(
|
a_answer = models.BooleanField(
|
||||||
help_text=answer_help_text, default=True
|
help_text=answer_help_text, default=True
|
||||||
)
|
)
|
||||||
|
a_feedback = models.TextField(
|
||||||
|
blank=True,
|
||||||
|
help_text="Feedback for answer",
|
||||||
|
)
|
||||||
|
|
||||||
b = models.TextField(
|
b = models.TextField(
|
||||||
blank=False,
|
blank=False,
|
||||||
@@ -41,6 +45,10 @@ class Question(models.Model):
|
|||||||
b_answer = models.BooleanField(
|
b_answer = models.BooleanField(
|
||||||
help_text=answer_help_text, default=True
|
help_text=answer_help_text, default=True
|
||||||
)
|
)
|
||||||
|
b_feedback = models.TextField(
|
||||||
|
blank=True,
|
||||||
|
help_text="Feedback for answer",
|
||||||
|
)
|
||||||
|
|
||||||
c = models.TextField(
|
c = models.TextField(
|
||||||
blank=False,
|
blank=False,
|
||||||
@@ -49,6 +57,10 @@ class Question(models.Model):
|
|||||||
c_answer = models.BooleanField(
|
c_answer = models.BooleanField(
|
||||||
help_text=answer_help_text, default=True
|
help_text=answer_help_text, default=True
|
||||||
)
|
)
|
||||||
|
c_feedback = models.TextField(
|
||||||
|
blank=True,
|
||||||
|
help_text="Feedback for answer",
|
||||||
|
)
|
||||||
|
|
||||||
d = models.TextField(
|
d = models.TextField(
|
||||||
blank=False,
|
blank=False,
|
||||||
@@ -57,6 +69,10 @@ class Question(models.Model):
|
|||||||
d_answer = models.BooleanField(
|
d_answer = models.BooleanField(
|
||||||
help_text=answer_help_text, default=True
|
help_text=answer_help_text, default=True
|
||||||
)
|
)
|
||||||
|
d_feedback = models.TextField(
|
||||||
|
blank=True,
|
||||||
|
help_text="Feedback for answer",
|
||||||
|
)
|
||||||
|
|
||||||
e = models.TextField(
|
e = models.TextField(
|
||||||
blank=False,
|
blank=False,
|
||||||
@@ -65,6 +81,10 @@ class Question(models.Model):
|
|||||||
e_answer = models.BooleanField(
|
e_answer = models.BooleanField(
|
||||||
help_text=answer_help_text, default=True
|
help_text=answer_help_text, default=True
|
||||||
)
|
)
|
||||||
|
e_feedback = models.TextField(
|
||||||
|
blank=True,
|
||||||
|
help_text="Feedback for answer",
|
||||||
|
)
|
||||||
|
|
||||||
created_date = models.DateTimeField(default=timezone.now)
|
created_date = models.DateTimeField(default=timezone.now)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user