summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
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]