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 -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"""