add exam collections
This commit is contained in:
@@ -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
@@ -17,7 +17,7 @@ from sortedm2m.fields import SortedManyToManyField
|
|||||||
|
|
||||||
import string
|
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 atlas.models import Structure
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
@@ -404,6 +404,8 @@ class Exam(ExamBase):
|
|||||||
|
|
||||||
exam_user_status = GenericRelation(ExamUserStatus)
|
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):
|
def get_exam_json(self, based=True):
|
||||||
questions = self.exam_questions.all()
|
questions = self.exam_questions.all()
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -44,7 +44,7 @@ from generic.models import (
|
|||||||
CidUser,
|
CidUser,
|
||||||
CidUserExam,
|
CidUserExam,
|
||||||
CidUserGroup,
|
CidUserGroup,
|
||||||
ExamCollectionGenericBase,
|
ExamOrCollectionGenericBase,
|
||||||
Examination,
|
Examination,
|
||||||
# Condition,
|
# Condition,
|
||||||
ExamBase,
|
ExamBase,
|
||||||
@@ -618,7 +618,7 @@ class Series(SeriesBase):
|
|||||||
return series_json
|
return series_json
|
||||||
|
|
||||||
|
|
||||||
class CaseCollection(ExamCollectionGenericBase):
|
class CaseCollection(ExamOrCollectionGenericBase):
|
||||||
app_name = "atlas"
|
app_name = "atlas"
|
||||||
|
|
||||||
cases = models.ManyToManyField(Case, through="CaseDetail")
|
cases = models.ManyToManyField(Case, through="CaseDetail")
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Generated by Django 4.1.4 on 2024-01-29 09:52
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('generic', '0010_userprofile_site'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ExamCollection',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=255)),
|
||||||
|
('date', models.DateField(blank=True, null=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
+8
-2
@@ -519,7 +519,7 @@ class SeriesBase(models.Model):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ExamCollectionGenericBase(models.Model):
|
class ExamOrCollectionGenericBase(models.Model):
|
||||||
"""Holds functions that relate to both case and other exams
|
"""Holds functions that relate to both case and other exams
|
||||||
|
|
||||||
e.g. user management
|
e.g. user management
|
||||||
@@ -734,7 +734,7 @@ class ExamCollectionGenericBase(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ExamBase(ExamCollectionGenericBase):
|
class ExamBase(ExamOrCollectionGenericBase):
|
||||||
exam_mode = models.BooleanField(
|
exam_mode = models.BooleanField(
|
||||||
help_text="If an exam should be taken in exam mode (users results will be submited to the server for marking)",
|
help_text="If an exam should be taken in exam mode (users results will be submited to the server for marking)",
|
||||||
default=False,
|
default=False,
|
||||||
@@ -1517,3 +1517,9 @@ def create_user_profile(sender, instance, created, **kwargs):
|
|||||||
@receiver(post_save, sender=User)
|
@receiver(post_save, sender=User)
|
||||||
def save_user_profile(sender, instance, **kwargs):
|
def save_user_profile(sender, instance, **kwargs):
|
||||||
instance.userprofile.save()
|
instance.userprofile.save()
|
||||||
|
|
||||||
|
class ExamCollection(models.Model):
|
||||||
|
name = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
date = models.DateField(blank=True,null=True)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 4.1.4 on 2024-01-29 09:57
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('generic', '0011_examcollection'),
|
||||||
|
('longs', '0014_exam_stats_graph'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='exam',
|
||||||
|
name='exam_collection',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='longs_exams', to='generic.examcollection'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -28,6 +28,7 @@ from helpers.images import image_as_base64, pretty_print_dicom
|
|||||||
from generic.models import (
|
from generic.models import (
|
||||||
CidUser,
|
CidUser,
|
||||||
CidUserGroup,
|
CidUserGroup,
|
||||||
|
ExamCollection,
|
||||||
ExamUserStatus,
|
ExamUserStatus,
|
||||||
Examination,
|
Examination,
|
||||||
ExamBase,
|
ExamBase,
|
||||||
@@ -465,6 +466,8 @@ class Exam(ExamBase):
|
|||||||
|
|
||||||
exam_user_status = GenericRelation(ExamUserStatus)
|
exam_user_status = GenericRelation(ExamUserStatus)
|
||||||
|
|
||||||
|
exam_collection = models.ForeignKey(ExamCollection, blank=True, null=True, on_delete=models.SET_NULL, related_name="longs_exams")
|
||||||
|
|
||||||
def get_exam_question_json(self, question_id):
|
def get_exam_question_json(self, question_id):
|
||||||
q = get_object_or_404(Long, pk=question_id)
|
q = get_object_or_404(Long, pk=question_id)
|
||||||
|
|
||||||
|
|||||||
@@ -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'),
|
||||||
|
('physics', '0003_exam_stats_graph'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='exam',
|
||||||
|
name='exam_collection',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='rapids_exams', to='generic.examcollection'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 4.1.4 on 2024-01-29 09:57
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('generic', '0011_examcollection'),
|
||||||
|
('physics', '0004_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='physics_exams', to='generic.examcollection'),
|
||||||
|
),
|
||||||
|
]
|
||||||
+3
-1
@@ -12,7 +12,7 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
|
|
||||||
from sortedm2m.fields import SortedManyToManyField
|
from sortedm2m.fields import SortedManyToManyField
|
||||||
|
|
||||||
from generic.models import CidUser, CidUserGroup, ExamBase, ExamUserStatus, QuestionBase, QuestionNote, UserAnswerBase, UserUserGroup
|
from generic.models import CidUser, CidUserGroup, ExamBase, ExamCollection, ExamUserStatus, QuestionBase, QuestionNote, UserAnswerBase, UserUserGroup
|
||||||
|
|
||||||
import reversion
|
import reversion
|
||||||
|
|
||||||
@@ -182,6 +182,8 @@ class Exam(ExamBase):
|
|||||||
|
|
||||||
exam_user_status = GenericRelation(ExamUserStatus)
|
exam_user_status = GenericRelation(ExamUserStatus)
|
||||||
|
|
||||||
|
exam_collection = models.ForeignKey(ExamCollection, blank=True, null=True, on_delete=models.SET_NULL, related_name="physics_exams")
|
||||||
|
|
||||||
def get_take_url(self):
|
def get_take_url(self):
|
||||||
return reverse("physics:exam_start", kwargs={"pk": self.pk})
|
return reverse("physics:exam_start", kwargs={"pk": self.pk})
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 4.1.4 on 2024-01-29 09:57
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('generic', '0011_examcollection'),
|
||||||
|
('rapids', '0003_exam_stats_graph'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='exam',
|
||||||
|
name='exam_collection',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='rapids_exams', to='generic.examcollection'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -28,6 +28,7 @@ from django.contrib.contenttypes.fields import GenericRelation
|
|||||||
from generic.models import (
|
from generic.models import (
|
||||||
CidUser,
|
CidUser,
|
||||||
CidUserGroup,
|
CidUserGroup,
|
||||||
|
ExamCollection,
|
||||||
ExamUserStatus,
|
ExamUserStatus,
|
||||||
QuestionBase,
|
QuestionBase,
|
||||||
Site,
|
Site,
|
||||||
@@ -648,6 +649,8 @@ class Exam(ExamBase):
|
|||||||
|
|
||||||
exam_user_status = GenericRelation(ExamUserStatus)
|
exam_user_status = GenericRelation(ExamUserStatus)
|
||||||
|
|
||||||
|
exam_collection = models.ForeignKey(ExamCollection, blank=True, null=True, on_delete=models.SET_NULL, related_name="rapids_exams")
|
||||||
|
|
||||||
def get_normal_abnormal_breakdown(self):
|
def get_normal_abnormal_breakdown(self):
|
||||||
# Inefficient but more extendible
|
# Inefficient but more extendible
|
||||||
questions = self.exam_questions.all()
|
questions = self.exam_questions.all()
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 4.1.4 on 2024-01-29 09:57
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('generic', '0011_examcollection'),
|
||||||
|
('sbas', '0004_exam_stats_graph'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='exam',
|
||||||
|
name='exam_collection',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sbas_exams', to='generic.examcollection'),
|
||||||
|
),
|
||||||
|
]
|
||||||
+3
-1
@@ -11,7 +11,7 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
|
|
||||||
from sortedm2m.fields import SortedManyToManyField
|
from sortedm2m.fields import SortedManyToManyField
|
||||||
|
|
||||||
from generic.models import CidUser, CidUserGroup, ExamBase, ExamUserStatus, QuestionBase, QuestionNote, UserAnswerBase, UserUserGroup
|
from generic.models import CidUser, CidUserGroup, ExamBase, ExamCollection, ExamUserStatus, QuestionBase, QuestionNote, UserAnswerBase, UserUserGroup
|
||||||
|
|
||||||
import reversion
|
import reversion
|
||||||
|
|
||||||
@@ -198,6 +198,8 @@ class Exam(ExamBase):
|
|||||||
|
|
||||||
exam_user_status = GenericRelation(ExamUserStatus)
|
exam_user_status = GenericRelation(ExamUserStatus)
|
||||||
|
|
||||||
|
exam_collection = models.ForeignKey(ExamCollection, blank=True, null=True, on_delete=models.SET_NULL, related_name="sbas_exams")
|
||||||
|
|
||||||
def get_take_url(self):
|
def get_take_url(self):
|
||||||
return reverse("sbas:exam_start", kwargs={"pk": self.pk})
|
return reverse("sbas:exam_start", kwargs={"pk": self.pk})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user