from django db import models from django utils translation import uget

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from django.db import models
from django.utils.translation import ugettext_lazy as _
class Category(models.Model):
title = models.CharField(max_length=64)
parent = models.ForeignKey('self', blank=True, null=True)
def __unicode__(self):
return self.title
class Meta:
verbose_name = _('category')
verbose_name_plural = _('categories')
class Test(models.Model):
title = models.CharField(max_length=128)
description = models.TextField(blank=True)
category = models.ForeignKey(Category)
test_time = models.TimeField(default ='00:00:00')
question_time = models.TimeField(default ='00:00:00')
question_count = models.IntegerField()
question_random = models.BooleanField()
variant_random = models.BooleanField()
def total_questions(self):
return 1
def __unicode__(self):
return self.title
class Meta:
verbose_name = _('test')
verbose_name_plural = _('tests')
class Question(models.Model):
title = models.TextField()
test = models.ManyToManyField(Test)
def __unicode__(self):
return self.title
class Meta:
verbose_name = _('question')
verbose_name_plural = _('questions')
class Variant(models.Model):
title = models.TextField()
correct = models.BooleanField()
question = models.ForeignKey(Question)
def __unicode__(self):
return self.title
class Meta:
verbose_name = _('variant')
verbose_name_plural = _('variants')
class TestUser(models.Model):
fullname = models.CharField(max_length=128)
group = models.CharField(max_length=32)
def __unicode__(self):
return "%s [%s]" % (self.fullname, self.group)
class Meta:
verbose_name = _('test user')
verbose_name_plural = _('test users')