summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/live_server_tests/selenium_test.py4
-rw-r--r--yaksh/models.py8
-rw-r--r--yaksh/test_models.py4
3 files changed, 10 insertions, 6 deletions
diff --git a/yaksh/live_server_tests/selenium_test.py b/yaksh/live_server_tests/selenium_test.py
index d91f3ec..277f08e 100644
--- a/yaksh/live_server_tests/selenium_test.py
+++ b/yaksh/live_server_tests/selenium_test.py
@@ -29,8 +29,8 @@ class SeleniumTest():
except Exception as e:
self.driver.close()
msg = ("An Error occurred while running the Selenium load"
- " test on Yaksh!"
- "Error:\n ".format(e))
+ " test on Yaksh!\n"
+ "Error:\n{0}".format(e))
raise SeleniumTestError(msg)
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]
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index b6934e3..cd66aed 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -735,13 +735,13 @@ class AnswerPaperTestCases(unittest.TestCase):
# Then
self.assertEqual(self.answerpaper.questions_left(), 0)
- self.assertTrue(current_question is not None)
+ self.assertTrue(current_question is None)
# When
next_question_id = self.answerpaper.next_question(current_question_id)
# Then
- self.assertTrue(next_question_id is not None)
+ self.assertTrue(next_question_id is None)
def test_update_marks(self):
""" Test update_marks method of AnswerPaper"""