summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authorankitjavalkar2017-03-06 19:56:56 +0530
committerankitjavalkar2017-03-06 20:16:38 +0530
commita53df8040785cffaf46bfc1775c59eed7c4a15c3 (patch)
tree0d0ad3531b048935043a0634d8ee7d426c597039 /yaksh
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')
-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"""