add exam collections

This commit is contained in:
Ross
2024-01-29 09:58:18 +00:00
parent e89cf704ed
commit 04dcb74e67
15 changed files with 186 additions and 7 deletions
@@ -0,0 +1,20 @@
# Generated by Django 4.1.4 on 2024-01-29 09:52
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('generic', '0011_examcollection'),
('anatomy', '0010_alter_anatomyquestion_answer_suggest_incorrect'),
]
operations = [
migrations.AddField(
model_name='exam',
name='exam_collection',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='generic.examcollection'),
),
]
@@ -0,0 +1,20 @@
# Generated by Django 4.1.4 on 2024-01-29 09:55
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('generic', '0011_examcollection'),
('anatomy', '0011_exam_exam_collection'),
]
operations = [
migrations.AlterField(
model_name='exam',
name='exam_collection',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='anatomy_exams', to='generic.examcollection'),
),
]
+3 -1
View File
@@ -17,7 +17,7 @@ from sortedm2m.fields import SortedManyToManyField
import string
from generic.models import CidUser, CidUserGroup, ExamUserStatus, Examination, ExamBase, QuestionBase, QuestionNote, UserAnswerBase, UserUserGroup, Modality
from generic.models import CidUser, CidUserGroup, ExamCollection, ExamUserStatus, Examination, ExamBase, QuestionBase, QuestionNote, UserAnswerBase, UserUserGroup, Modality
from atlas.models import Structure
from collections import defaultdict
@@ -404,6 +404,8 @@ class Exam(ExamBase):
exam_user_status = GenericRelation(ExamUserStatus)
exam_collection = models.ForeignKey(ExamCollection, blank=True, null=True, on_delete=models.SET_NULL, related_name="anatomy_exams")
def get_exam_json(self, based=True):
questions = self.exam_questions.all()