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
+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):