quiz/models.py
author nishanth
Thu, 22 Apr 2010 01:35:31 +0530
changeset 42 007d87112911
parent 39 0fa055b8ea98
child 43 265ed367e8cc
permissions -rw-r--r--
created a user_dump page that shows all the answers entered by user at one place

from django.db import models
from django.contrib.auth.models import User

from offline.event.models import Event

class Profile(models.Model):
    """ A profile for quiz takers.
    """

    user = models.ForeignKey(User)
    profession = models.CharField(max_length=20,help_text="(Ex: Faculty, Student etc.)")
    affiliated_to = models.CharField(max_length=100, verbose_name="College/Company")

class QuestionBank(models.Model):
    """ A model for holding the database of questions.
    """

    quiz_num = models.CharField(max_length=2)

    description = models.TextField()
    code = models.TextField()
    options = models.TextField()
    time_limit = models.PositiveSmallIntegerField()
    expected_ans = models.TextField()

class Answer(models.Model):
    """ A model for holding answers submitted by users.
    """

    question = models.ForeignKey(QuestionBank)
    submitted_ans = models.TextField()
    is_correct = models.BooleanField(default=False)

class Quiz(models.Model):
    """ A model to hold the proceeding of a quiz.
    """

    user = models.ForeignKey(User)
    event = models.ForeignKey(Event, related_name="%(class)s")
    user_ip = models.CharField(max_length=15)
    key = models.CharField(max_length=10)
    
    quiz_num = models.CharField(max_length=2)
    que_remaining = models.CharField(max_length=100)
    que_answered = models.ManyToManyField(Answer)