Added description and question and answer models

This commit is contained in:
2013-08-07 22:47:31 +10:00
parent 32bb90ca72
commit 88fe7b7e79
6 changed files with 134 additions and 2 deletions

View File

@@ -20,5 +20,25 @@ class Category(CommonInfo):
class Sample(CommonInfo):
model_filename = models.CharField(max_length=1000)
description = models.CharField(max_length=2000, default='', blank=True, null=True)
parent = models.ForeignKey(Category, blank=True, null=True,
on_delete=models.SET_NULL)
class Question(models.Model):
text = models.CharField(max_length=2000)
sample = models.ForeignKey(Sample, related_name='questions')
def correct_answers(self):
return self.answers.filter(correct = True)
def __unicode__(self):
return self.text
class Answer(models.Model):
text = models.CharField(max_length=2000)
correct = models.BooleanField(default=False)
question = models.ForeignKey(Question, related_name='answers')
def __unicode__(self):
return self.text