Switch to ExmBase

This commit is contained in:
Ross
2021-02-06 21:53:56 +00:00
parent e0b73c70f5
commit 687a3758d8
3 changed files with 14 additions and 83 deletions
+4 -30
View File
@@ -13,7 +13,7 @@ from sortedm2m.fields import SortedManyToManyField
import string
from generic.models import Examination
from generic.models import Examination, ExamBase
image_storage = FileSystemStorage(
# Physical file location ROOT
@@ -263,42 +263,16 @@ class Answer(models.Model):
# self.answer.strip()
class Exam(models.Model):
name = models.CharField(max_length=200)
class Exam(ExamBase):
app_name = "anatomy"
exam_questions = SortedManyToManyField(
AnatomyQuestion, related_name="exams", blank="true"
)
active = models.BooleanField(
help_text="If an exam should be available", default=True
)
publish_results = models.BooleanField(
help_text="If an exams results should be available", default=True
)
recreate_json = models.BooleanField(
help_text="If the json cache needs updating", default=False
)
time_limit = models.IntegerField(
help_text="Exam time limit (in seconds)", default=5400
)
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse("anatomy:exam_overview", kwargs={"pk": self.pk})
def get_exam_name(self):
return self.name
def get_json_url(self):
return reverse("anatomy:exam_json", args=(self.pk,))
def get_question_index(self, question):
return list(self.exam_questions.all()).index(question)
# class UserAnswer(models.Model):
+6 -24
View File
@@ -11,6 +11,8 @@ from django.utils.translation import ugettext_lazy as _
from sortedm2m.fields import SortedManyToManyField
from generic.models import ExamBase
class Category(models.Model):
category = models.CharField(max_length=200)
@@ -124,40 +126,20 @@ class Question(models.Model):
return (self.a, self.b, self.c, self.d, self.e)
class Exam(models.Model):
name = models.CharField(max_length=200)
class Exam(ExamBase):
app_name = "rapids"
exam_questions = SortedManyToManyField(
Question, related_name="exams", blank="true"
)
active = models.BooleanField(
help_text="If an exam should be available", default=True
)
publish_results = models.BooleanField(
help_text="If an exams results should be available", default=True
)
time_limit = models.IntegerField(
help_text="Exam time limit (in seconds)",
blank=True,
null=True,
)
def __str__(self):
return self.name
def get_exam_name(self):
return self.name
#def get_json_url(self):
# return reverse("anatomy:exam_json", args=(self.pk,))
def get_question_index(self, question):
return list(self.exam_questions.all()).index(question)
def get_absolute_url(self):
return reverse("physics:exam_overview", kwargs={"pk": self.pk})
recreate_json = None
class CidUserAnswer(models.Model):
+4 -29
View File
@@ -18,7 +18,7 @@ from sortedm2m.fields import SortedManyToManyField
import string
from generic.models import Site, Condition, Sign
from generic.models import Site, Condition, Sign, ExamBase
image_storage = FileSystemStorage(
# Physical file location ROOT
@@ -339,42 +339,17 @@ class RapidCreationDefault(models.Model):
return reverse('rapids:rapid_create')
class Exam(models.Model):
name = models.CharField(max_length=200)
class Exam(ExamBase):
app_name = "rapids"
exam_questions = SortedManyToManyField(
Rapid, related_name="exams", blank="true"
)
active = models.BooleanField(
help_text="If an exam should be available", default=True
)
publish_results = models.BooleanField(
help_text="If an exams results should be available", default=True
)
recreate_json = models.BooleanField(
help_text="If the json cache needs updating", default=False
)
time_limit = models.IntegerField(
help_text="Exam time limit (in seconds). Default is 2100 secondse (35 minutes)", default=2100
)
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse("rapids:exam_overview", kwargs={"pk": self.pk})
def get_exam_name(self):
return self.name
def get_json_url(self):
return reverse("rapids:exam_json", args=(self.pk,))
def get_question_index(self, question):
return list(self.exam_questions.all()).index(question)
class CidUserAnswer(models.Model):
"""User answers by candidate"""