diff options
author | prathamesh | 2014-06-24 17:42:08 +0530 |
---|---|---|
committer | prathamesh | 2014-06-24 17:42:08 +0530 |
commit | b1ecd46e3924cae0201bdf4bc16f34c7ae16b081 (patch) | |
tree | d08d6640c27a5e90cbdf9ca325c86149b7da6dbf /testapp/exam/models.py | |
parent | fa402a2c9a34a1728f863ddcbab62fa8e030099e (diff) | |
download | online_test-b1ecd46e3924cae0201bdf4bc16f34c7ae16b081.tar.gz online_test-b1ecd46e3924cae0201bdf4bc16f34c7ae16b081.tar.bz2 online_test-b1ecd46e3924cae0201bdf4bc16f34c7ae16b081.zip |
modification in models
Added shuffle option in the question paper.
Added language field, passing criteria and prerequisite quiz in quiz.
Added pass/fail result and percentage field in the answerpaper.
Diffstat (limited to 'testapp/exam/models.py')
-rw-r--r-- | testapp/exam/models.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/testapp/exam/models.py b/testapp/exam/models.py index 42c5d5a..a6897a4 100644 --- a/testapp/exam/models.py +++ b/testapp/exam/models.py @@ -115,6 +115,15 @@ class Quiz(models.Model): # Description of quiz. description = models.CharField(max_length=256) + # Mininum passing percentage condition. + pass_criteria = models.FloatField("Passing percentage", default=40) + + # List of prerequisite quizzes to be passed to take this quiz + prerequisite = models.ForeignKey("self", null=True) + + # Programming language for a quiz + language = models.CharField(max_length=20, choices=LANGUAGES) + class Meta: verbose_name_plural = "Quizzes" @@ -137,6 +146,9 @@ class QuestionPaper(models.Model): # Questions that will be fetched randomly from the Question Set. random_questions = models.ManyToManyField("QuestionSet") + # Option to shuffle questions, each time a new question paper is created. + shuffle_questions = models.BooleanField(default=False) + # Total marks for the question paper. total_marks = models.FloatField() @@ -167,8 +179,9 @@ class QuestionPaper(models.Model): + datetime.timedelta(minutes=self.quiz.duration) ans_paper.question_paper = self questions = self._get_questions_for_answerpaper() - question_ids = [str(x.id) for x in questions] - shuffle(questions) + question_ids = [str(x.id) for x in questions] + if self.shuffle_questions: + shuffle(question_ids) ans_paper.questions = "|".join(question_ids) ans_paper.save() return ans_paper @@ -230,6 +243,12 @@ class AnswerPaper(models.Model): # Teacher comments on the question paper. comments = models.TextField() + # Result of the quiz, either PASS or FAIL. + result = models.CharField(max_length=4) + + # Marks percent scored by the user + percent = models.FloatField(null=True) + def current_question(self): """Returns the current active question to display.""" qs = self.questions.split('|') |