diff options
author | ankitjavalkar | 2017-10-18 15:40:58 +0530 |
---|---|---|
committer | ankitjavalkar | 2017-10-25 12:54:53 +0530 |
commit | 90402ae9b0f2d4038099e9ea4e39f832063dd0dd (patch) | |
tree | af3b1d776ed2dc52d35654307589d6d611259fb2 /yaksh/models.py | |
parent | 8939dfcefc151ba41c7cb0a2ed32effab9120b0e (diff) | |
download | online_test-90402ae9b0f2d4038099e9ea4e39f832063dd0dd.tar.gz online_test-90402ae9b0f2d4038099e9ea4e39f832063dd0dd.tar.bz2 online_test-90402ae9b0f2d4038099e9ea4e39f832063dd0dd.zip |
- Fix and add test cases
- Fix god-mode/user-mode url pattern
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 6dc8ce2..de794c4 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1196,11 +1196,12 @@ class AnswerPaper(models.Model): def get_current_question(self, questions): if self.questions_order: - question_id = int(self.questions_order.split(',')[0]) - question = questions.get(id=question_id) - else: - question = questions.first() - return question + available_question_ids = questions.values_list('id', flat=True) + ordered_question_ids = [int(q) for q in self.questions_order.split(',')] + for qid in ordered_question_ids: + if qid in available_question_ids: + return questions.get(id=qid) + return questions.first() def questions_left(self): """Returns the number of questions left.""" |