diff options
author | adityacp | 2017-10-06 23:24:38 +0530 |
---|---|---|
committer | adityacp | 2017-10-06 23:24:38 +0530 |
commit | 2eb511847777e4e941ed5fc40783086d5e0bdfcc (patch) | |
tree | 04cf534ac2cdc90f386e051588bf443fc61219ff /yaksh | |
parent | f4fd03fd09c53a655eedaaa7b9804591ca434966 (diff) | |
download | online_test-2eb511847777e4e941ed5fc40783086d5e0bdfcc.tar.gz online_test-2eb511847777e4e941ed5fc40783086d5e0bdfcc.tar.bz2 online_test-2eb511847777e4e941ed5fc40783086d5e0bdfcc.zip |
Change models.py
- Change question_order field from charfield to textfield
- Refactor has_questions and current_question functions
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/models.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index c6f6a6b..eb14e06 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -958,7 +958,7 @@ class QuestionPaper(models.Model): def has_questions(self): questions = self.get_ordered_questions() + \ list(self.random_questions.all()) - return False if len(questions) == 0 else True + return len(questions) > 0 def __str__(self): return "Question Paper for " + self.quiz.description @@ -1181,15 +1181,15 @@ class AnswerPaper(models.Model): ) # set question order - questions_order = models.CharField(max_length=255, blank=True, default='') + questions_order = models.TextField(blank=True, default='') objects = AnswerPaperManager() def current_question(self): """Returns the current active question to display.""" - if self.questions_unanswered.all(): - cur_question = self.get_current_question( - self.questions_unanswered.all()) + questions = self.questions_unanswered.all() + if questions.exists(): + cur_question = self.get_current_question(questions) else: cur_question = self.get_current_question(self.questions.all()) return cur_question |