diff options
author | prathamesh | 2014-06-26 17:51:06 +0530 |
---|---|---|
committer | prathamesh | 2014-06-26 17:51:06 +0530 |
commit | b61c62291424089478064af1fceb81c1ed4e5c54 (patch) | |
tree | 424631d9db8cf4f1ba10fe3ae9cdccec16ce0d43 /testapp/exam/models.py | |
parent | f50f2a37a0908a05a4da1d03f9e3c776d32df74c (diff) | |
download | online_test-b61c62291424089478064af1fceb81c1ed4e5c54.tar.gz online_test-b61c62291424089478064af1fceb81c1ed4e5c54.tar.bz2 online_test-b61c62291424089478064af1fceb81c1ed4e5c54.zip |
Made pass field as boolean field.
And changed variables to lowercases
Diffstat (limited to 'testapp/exam/models.py')
-rw-r--r-- | testapp/exam/models.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/testapp/exam/models.py b/testapp/exam/models.py index eb270ae..62c707b 100644 --- a/testapp/exam/models.py +++ b/testapp/exam/models.py @@ -16,7 +16,7 @@ class Profile(models.Model): position = models.CharField(max_length=64) -LANGUAGES = ( +languages = ( ("python", "Python"), ("bash", "Bash"), ("C", "C Language"), @@ -26,7 +26,7 @@ LANGUAGES = ( ) -QUESTION_TYPES = ( +question_types = ( ("mcq", "Multiple Choice"), ("code", "Code"), ) @@ -53,10 +53,10 @@ class Question(models.Model): # The language for question. language = models.CharField(max_length=24, - choices=LANGUAGES) + choices=languages) # The type of question. - type = models.CharField(max_length=24, choices=QUESTION_TYPES) + type = models.CharField(max_length=24, choices=question_types) # Is this question active or not. If it is inactive it will not be used # when creating a QuestionPaper. @@ -122,7 +122,7 @@ class Quiz(models.Model): prerequisite = models.ForeignKey("Quiz", null=True) # Programming language for a quiz - language = models.CharField(max_length=20, choices=LANGUAGES) + language = models.CharField(max_length=20, choices=languages) class Meta: verbose_name_plural = "Quizzes" @@ -248,8 +248,8 @@ class AnswerPaper(models.Model): # Marks percent scored by the user percent = models.FloatField(null=True, default=None) - # Result of the quiz, either PASSED or FAILED. - result = models.CharField(max_length=8, null=True, default=None) + # Result of the quiz, pass if True. + result = models.NullBooleanField() def current_question(self): """Returns the current active question to display.""" @@ -338,9 +338,9 @@ class AnswerPaper(models.Model): """ if self.percent is not None: if self.percent >= self.question_paper.quiz.pass_criteria: - self.result = "PASSED" + self.result = True else: - self.result = "FAILED" + self.result = False def get_question_answers(self): """ |