update anatomy to remove sortedm2m
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# Generated by Django 4.1.4 on 2024-02-17 22:10
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('anatomy', '0013_rename_exam_collection_exam_examcollection'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ExamQuestionDetail',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('exam', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='anatomy.exam')),
|
||||
('anatomyquestion', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='anatomy.anatomyquestion')),
|
||||
('sort_order', models.IntegerField(default=1000)),
|
||||
],
|
||||
options={
|
||||
'ordering': ('sort_order',),
|
||||
},
|
||||
),
|
||||
migrations.RunSQL(
|
||||
"""INSERT INTO anatomy_examquestiondetail
|
||||
SELECT * FROM anatomy_exam_exam_questions;"""
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 4.1.4 on 2024-02-17 22:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('anatomy', '0014_examquestiondetail'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='exam',
|
||||
name='exam_questions',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='exam',
|
||||
name='exam_questions',
|
||||
field=models.ManyToManyField(related_name='exams', through='anatomy.ExamQuestionDetail', to='anatomy.anatomyquestion'),
|
||||
),
|
||||
]
|
||||
+12
-3
@@ -361,14 +361,23 @@ class Answer(models.Model):
|
||||
# if self.answer:
|
||||
# self.answer.strip()
|
||||
|
||||
class ExamQuestionDetail(models.Model):
|
||||
exam = models.ForeignKey("Exam", on_delete=models.CASCADE)
|
||||
anatomyquestion = models.ForeignKey(AnatomyQuestion, on_delete=models.CASCADE)
|
||||
|
||||
sort_order = models.IntegerField(default=1000)
|
||||
|
||||
class Meta:
|
||||
ordering = ("sort_order",)
|
||||
|
||||
@reversion.register
|
||||
class Exam(ExamBase):
|
||||
app_name = "anatomy"
|
||||
|
||||
exam_questions = SortedManyToManyField(
|
||||
AnatomyQuestion, related_name="exams", blank="true"
|
||||
)
|
||||
#exam_questions = SortedManyToManyField(
|
||||
# AnatomyQuestion, related_name="exams", blank="true"
|
||||
#)
|
||||
exam_questions = models.ManyToManyField("AnatomyQuestion", through=ExamQuestionDetail, related_name="exams")
|
||||
time_limit = models.IntegerField(
|
||||
help_text="Exam time limit (in seconds)", default=5400
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user