90 lines
2.2 KiB
Python
90 lines
2.2 KiB
Python
from django.db import models
|
|
|
|
from django.urls import reverse
|
|
|
|
import tagulous
|
|
import tagulous.models
|
|
|
|
from sortedm2m.fields import SortedManyToManyField
|
|
|
|
class Plane(models.Model):
|
|
plane = models.CharField(max_length=200)
|
|
|
|
def __str__(self):
|
|
return self.plane
|
|
|
|
class Meta:
|
|
ordering = ('plane', )
|
|
|
|
class Contrast(models.Model):
|
|
contrast = models.CharField(max_length=200)
|
|
|
|
def __str__(self):
|
|
return self.contrast
|
|
|
|
class Meta:
|
|
ordering = ('contrast', )
|
|
|
|
class Examination(models.Model):
|
|
examination = models.CharField(max_length=200)
|
|
|
|
def __str__(self):
|
|
return self.examination
|
|
|
|
class Meta:
|
|
ordering = ('examination', )
|
|
|
|
class Site(models.Model):
|
|
site = models.CharField(max_length=200)
|
|
initials = models.CharField(max_length=200)
|
|
|
|
def __str__(self):
|
|
return self.site
|
|
|
|
class Condition(tagulous.models.TagModel):
|
|
pass
|
|
|
|
class Sign(tagulous.models.TagModel):
|
|
pass
|
|
|
|
|
|
class ExamBase(models.Model):
|
|
name = models.CharField(max_length=200)
|
|
#exam_questions = SortedManyToManyField(Long, 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
|
|
)
|
|
|
|
json_creation_time = models.DateTimeField(blank=True, default=None, null=True)
|
|
|
|
#time_limit = models.IntegerField(
|
|
# help_text="Exam time limit (in seconds). Default is 2100 secondse (35 minutes)",
|
|
# default=2100,
|
|
#)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
def get_absolute_url(self):
|
|
return reverse("{}:exam_overview".format(self.app_name), kwargs={"pk": self.pk})
|
|
|
|
def get_exam_name(self):
|
|
return self.name
|
|
|
|
def get_json_url(self):
|
|
return reverse("{}:exam_json".format(self.app_name), args=(self.pk,))
|
|
|
|
def get_question_index(self, question):
|
|
return list(self.exam_questions.all()).index(question) |