summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorankitjavalkar2017-03-06 19:56:56 +0530
committerankitjavalkar2017-03-06 20:16:38 +0530
commita53df8040785cffaf46bfc1775c59eed7c4a15c3 (patch)
tree0d0ad3531b048935043a0634d8ee7d426c597039 /yaksh/models.py
parentc118c7eff7abaeba18f7c375828d2e022d21cb9f (diff)
downloadonline_test-a53df8040785cffaf46bfc1775c59eed7c4a15c3.tar.gz
online_test-a53df8040785cffaf46bfc1775c59eed7c4a15c3.tar.bz2
online_test-a53df8040785cffaf46bfc1775c59eed7c4a15c3.zip
Multiple fixes:
- Add error message details to SeleniumTestError - Fix next question cycling in models - Fix model test cases
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index f0f4ca6..398f508 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -987,11 +987,12 @@ class AnswerPaper(models.Model):
Adds the completed question to the list of answered
questions and returns the next question.
"""
- next_question = self.next_question(question_id)
if question_id not in self.questions_answered.all():
self.questions_answered.add(question_id)
self.questions_unanswered.remove(question_id)
- if next_question.id == int(question_id):
+
+ next_question = self.next_question(question_id)
+ if next_question and next_question.id == int(question_id):
return None
return next_question
@@ -1001,9 +1002,12 @@ class AnswerPaper(models.Model):
available question.
"""
all_questions = self.questions.all()
+ unanswered_questions = self.questions_unanswered.all()
questions = list(all_questions.values_list('id', flat=True))
if len(questions) == 0:
return None
+ if unanswered_questions.count() == 0:
+ return None
try:
index = questions.index(int(question_id))
next_id = questions[index+1]