quiz/models.py
author nishanth
Wed, 21 Apr 2010 12:11:19 +0530
changeset 29 ea1c0110e989
parent 28 456b7b9e3d13
child 39 0fa055b8ea98
permissions -rw-r--r--
fixed the display of question
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
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
     6
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
     7
    """ 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
     8
    """
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
     9
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    10
    user = models.ForeignKey(User)
15
99af908a4174 added questions thro seed_db
nishanth
parents: 14
diff changeset
    11
    profession = models.CharField(max_length=20,help_text="(Ex: Faculty, Student etc.)")
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    12
    affiliated_to = models.CharField(max_length=100, verbose_name="College/Company")
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    13
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    14
class QuestionBank(models.Model):
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    15
    """ A model for holding the database of questions.
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    16
    """
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    17
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    18
    quiz_num = models.CharField(max_length=2)
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    19
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    20
    description = models.TextField()
22
fe197c0c9903 modified the questionbank model and changed in seed_db accordingly
nishanth
parents: 16
diff changeset
    21
    code = models.TextField()
fe197c0c9903 modified the questionbank model and changed in seed_db accordingly
nishanth
parents: 16
diff changeset
    22
    options = models.TextField()
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    23
    time_limit = models.PositiveSmallIntegerField()
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    24
    expected_ans = models.TextField()
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    25
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    26
class Answer(models.Model):
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    27
    """ A model for holding answers submitted by users.
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    28
    """
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    29
14
ea7d372bfbff implemented more constraints on the register for test page
nishanth
parents: 13
diff changeset
    30
    question = models.ForeignKey(QuestionBank)
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    31
    submitted_ans = models.TextField()
14
ea7d372bfbff implemented more constraints on the register for test page
nishanth
parents: 13
diff changeset
    32
    is_correct = models.BooleanField()
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    33
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    34
class Quiz(models.Model):
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    35
    """ A model to hold the proceeding of a quiz.
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    36
    """
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    37
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    38
    user = models.ForeignKey(User)
23
f57c30096b51 added the link on home to attempt quiz
nishanth
parents: 22
diff changeset
    39
    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
    40
    user_ip = models.CharField(max_length=15)
16
ad51f38d0339 implemented the start quiz functionality
nishanth
parents: 15
diff changeset
    41
    key = models.CharField(max_length=10)
12
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    42
    
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    43
    quiz_num = models.CharField(max_length=2)
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    44
    que_remaining = models.CharField(max_length=100)
81cd0140a0f2 created the register user functionality.
nishanth
parents:
diff changeset
    45
    que_answered = models.ManyToManyField(Answer)
15
99af908a4174 added questions thro seed_db
nishanth
parents: 14
diff changeset
    46