| author | nishanth |
| Tue, 06 Jul 2010 23:31:33 +0530 | |
| changeset 89 | f8e25dea5222 |
| parent 87 | e81b105b1128 |
| permissions | -rw-r--r-- |
| 12 | 1 |
from django.db import models |
2 |
from django.contrib.auth.models import User |
|
3 |
||
4 |
from offline.event.models import Event |
|
5 |
||
|
57
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
6 |
TOPIC_CHOICES = (("11", "Plotting"),
|
|
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
7 |
("12", "Lists and Files"),
|
| 59 | 8 |
("13", "For Loops"),
|
9 |
("14", "Strings"),
|
|
10 |
("15", "Dictionaries and Piecharts"),
|
|
11 |
("16", "Statistics"),
|
|
12 |
("17", "Arrays and Matrices"),
|
|
13 |
("18", "Solving linear equations"),
|
|
14 |
("19", "Finding roots"),
|
|
|
57
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
15 |
|
|
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
16 |
("21", "Basic Datatypes"),
|
|
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
17 |
("22", "Input and Output"),
|
|
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
18 |
("23", "Lists and Tuples"),
|
|
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
19 |
("24", "Dictionaries"),
|
|
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
20 |
("25", "Sets"),
|
|
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
21 |
("26", "Conditional Statements"),
|
|
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
22 |
("27", "Functions"),
|
|
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
23 |
) |
|
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
24 |
|
| 12 | 25 |
class Profile(models.Model): |
|
28
456b7b9e3d13
created a question bank xml file and created a seed_que command for adding questions to db from xml
nishanth
parents:
23
diff
changeset
|
26 |
""" A profile for quiz takers. |
|
456b7b9e3d13
created a question bank xml file and created a seed_que command for adding questions to db from xml
nishanth
parents:
23
diff
changeset
|
27 |
""" |
| 12 | 28 |
|
29 |
user = models.ForeignKey(User) |
|
| 15 | 30 |
profession = models.CharField(max_length=20,help_text="(Ex: Faculty, Student etc.)") |
| 12 | 31 |
affiliated_to = models.CharField(max_length=100, verbose_name="College/Company") |
32 |
||
33 |
class QuestionBank(models.Model): |
|
34 |
""" A model for holding the database of questions. |
|
35 |
""" |
|
36 |
||
|
57
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
37 |
quiz_num = models.CharField(max_length=2, default="00") |
|
0ca5016cde82
added another field to the question_bank model and hence the choices related to that model
nishanth
parents:
43
diff
changeset
|
38 |
topic = models.CharField(max_length=2,choices=TOPIC_CHOICES) |
| 12 | 39 |
|
40 |
description = models.TextField() |
|
|
82
79ae8288b5ff
removed the restriction on code field and options field in models
nishanth
parents:
64
diff
changeset
|
41 |
code = models.TextField(blank=True) |
|
79ae8288b5ff
removed the restriction on code field and options field in models
nishanth
parents:
64
diff
changeset
|
42 |
options = models.TextField(blank=True) |
| 12 | 43 |
time_limit = models.PositiveSmallIntegerField() |
44 |
expected_ans = models.TextField() |
|
45 |
||
| 64 | 46 |
def __unicode__(self): |
47 |
||
48 |
return self.description |
|
49 |
||
| 12 | 50 |
class Answer(models.Model): |
51 |
""" A model for holding answers submitted by users. |
|
52 |
""" |
|
53 |
||
| 43 | 54 |
question = models.ForeignKey(QuestionBank, related_name="%(class)s") |
| 12 | 55 |
submitted_ans = models.TextField() |
|
39
0fa055b8ea98
implemented correct_quiz function and added it at the time of closing quiz and modified question bank
nishanth
parents:
28
diff
changeset
|
56 |
is_correct = models.BooleanField(default=False) |
| 12 | 57 |
|
58 |
class Quiz(models.Model): |
|
59 |
""" A model to hold the proceeding of a quiz. |
|
60 |
""" |
|
61 |
||
62 |
user = models.ForeignKey(User) |
|
| 23 | 63 |
event = models.ForeignKey(Event, related_name="%(class)s") |
| 13 | 64 |
user_ip = models.CharField(max_length=15) |
| 16 | 65 |
key = models.CharField(max_length=10) |
| 12 | 66 |
|
67 |
quiz_num = models.CharField(max_length=2) |
|
68 |
que_remaining = models.CharField(max_length=100) |
|
| 43 | 69 |
que_answered = models.ManyToManyField(Answer, related_name="%(class)s") |
| 15 | 70 |