quiz/models.py
author nishanth
Tue, 29 Jun 2010 11:21:52 +0530
changeset 57 0ca5016cde82
parent 43 265ed367e8cc
child 59 0b57494e8b4e
permissions -rw-r--r--
added another field to the question_bank model and hence the choices related to that model
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
     1
from django.db import models
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
     2
from django.contrib.auth.models import User
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
     3
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
     4
from offline.event.models import Event
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
     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"),
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
     8
                 ("13", "Strings"),
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
     9
                 ("14", "Dictionaries and Piecharts"),
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
    10
                 ("15", "Statistics"),
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
    11
                 ("16", "Matrices"),
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
    12
                 ("17", "Solving linear equations"),
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
    13
                 ("18", "Finding roots"),
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
    14
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
    15
                 ("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
    16
                 ("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
    17
                 ("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
    18
                 ("24", "Dictionaries"),
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
    19
                 ("25", "Sets"),
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
    20
                 ("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
    21
                 ("27", "Functions"),
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
    22
                 )
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
    23
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    24
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
    25
    """ 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
    26
    """
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    27
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    28
    user = models.ForeignKey(User)
15
99af908a4174 added questions thro seed_db
nishanth
parents: 14
diff changeset
    29
    profession = models.CharField(max_length=20,help_text="(Ex: Faculty, Student etc.)")
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    30
    affiliated_to = models.CharField(max_length=100, verbose_name="College/Company")
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    31
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    32
class QuestionBank(models.Model):
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    33
    """ A model for holding the database of questions.
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    34
    """
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    35
57
0ca5016cde82 added another field to the question_bank model and hence the choices related to that model
nishanth
parents: 43
diff changeset
    36
    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
    37
    topic = models.CharField(max_length=2,choices=TOPIC_CHOICES)
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    38
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    39
    description = models.TextField()
22
fe197c0c9903 modified the questionbank model and changed in seed_db accordingly
nishanth
parents: 16
diff changeset
    40
    code = models.TextField()
fe197c0c9903 modified the questionbank model and changed in seed_db accordingly
nishanth
parents: 16
diff changeset
    41
    options = models.TextField()
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    42
    time_limit = models.PositiveSmallIntegerField()
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    43
    expected_ans = models.TextField()
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    44
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    45
class Answer(models.Model):
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    46
    """ A model for holding answers submitted by users.
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    47
    """
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    48
43
265ed367e8cc renamed related_name fields appropriately
nishanth
parents: 39
diff changeset
    49
    question = models.ForeignKey(QuestionBank, related_name="%(class)s")
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    50
    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
    51
    is_correct = models.BooleanField(default=False)
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    52
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    53
class Quiz(models.Model):
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    54
    """ A model to hold the proceeding of a quiz.
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    55
    """
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    56
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    57
    user = models.ForeignKey(User)
23
f57c30096b51 added the link on home to attempt quiz
nishanth
parents: 22
diff changeset
    58
    event = models.ForeignKey(Event, related_name="%(class)s")
13
ad193c5014b2 added ip field to model and used it in start page
nishanth
parents: 12
diff changeset
    59
    user_ip = models.CharField(max_length=15)
16
ad51f38d0339 implemented the start quiz functionality
nishanth
parents: 15
diff changeset
    60
    key = models.CharField(max_length=10)
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    61
    
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    62
    quiz_num = models.CharField(max_length=2)
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    63
    que_remaining = models.CharField(max_length=100)
43
265ed367e8cc renamed related_name fields appropriately
nishanth
parents: 39
diff changeset
    64
    que_answered = models.ManyToManyField(Answer, related_name="%(class)s")
15
99af908a4174 added questions thro seed_db
nishanth
parents: 14
diff changeset
    65