From 2aa6ad38c89162eaef2e886947f9b7eabc4dfc4c Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 5 Oct 2017 16:27:51 +0530 Subject: Allow user to quit the paper manually and revisit the paper if necessary --- yaksh/models.py | 3 +-- yaksh/templates/exam.html | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/yaksh/models.py b/yaksh/models.py index 68bde48..906dd7e 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1170,6 +1170,7 @@ class AnswerPaper(models.Model): """Returns the current active question to display.""" if self.questions_unanswered.all(): return self.questions_unanswered.all()[0] + return self.questions.all()[0] def questions_left(self): """Returns the number of questions left.""" @@ -1199,8 +1200,6 @@ class AnswerPaper(models.Model): 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/templates/exam.html b/yaksh/templates/exam.html index 45b85f0..4d211d2 100644 --- a/yaksh/templates/exam.html +++ b/yaksh/templates/exam.html @@ -18,7 +18,13 @@
-- cgit From 2ffbca59a947bcef7f4ae28b2bd1d73d18179380 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 5 Oct 2017 17:02:10 +0530 Subject: Fix breaking tests --- yaksh/test_models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yaksh/test_models.py b/yaksh/test_models.py index fd31ca2..ac90c53 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -800,13 +800,14 @@ class AnswerPaperTestCases(unittest.TestCase): # Then self.assertEqual(self.answerpaper.questions_left(), 0) - self.assertTrue(current_question is None) + self.assertTrue(current_question == self.answerpaper.questions.all()[0]) # When next_question_id = self.answerpaper.next_question(current_question_id) # Then - self.assertTrue(next_question_id is None) + all_questions = self.questions.all() + self.assertTrue(next_question_id == all_questions[0]) def test_update_marks(self): """ Test update_marks method of AnswerPaper""" -- cgit