diff options
author | Prabhu Ramachandran | 2017-10-05 19:56:07 +0530 |
---|---|---|
committer | GitHub | 2017-10-05 19:56:07 +0530 |
commit | 72c9a0f2a84925b9f8096702aa702e1deb49e2ce (patch) | |
tree | 7efe929fbc1d58d3ca3cd65753600d3b995c3ded /yaksh | |
parent | 9249ba66edecb68d5d946425974625b743386635 (diff) | |
parent | 2ffbca59a947bcef7f4ae28b2bd1d73d18179380 (diff) | |
download | online_test-72c9a0f2a84925b9f8096702aa702e1deb49e2ce.tar.gz online_test-72c9a0f2a84925b9f8096702aa702e1deb49e2ce.tar.bz2 online_test-72c9a0f2a84925b9f8096702aa702e1deb49e2ce.zip |
Merge pull request #344 from ankitjavalkar/allow-paper-revisit
Allow user to quit the paper manually and revisit the paper if necessary
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/models.py | 3 | ||||
-rw-r--r-- | yaksh/templates/exam.html | 8 | ||||
-rw-r--r-- | yaksh/test_models.py | 5 |
3 files changed, 11 insertions, 5 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 2fcb767..b5bde04 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 @@ <form id="logout" action="{{URL_ROOT}}/exam/quit/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/" method="post" class="pull-right"> {% csrf_token %} <ul class="nav navbar-nav navbar"> - <li style="padding: 10px"><button class="btn btn-danger btn-sm" type="submit" name="quit">Quit Exam <span class="glyphicon glyphicon-off"></span></button></li> + <li style="padding: 10px"><button class="btn btn-danger btn-sm" type="submit" name="quit"> + {% if paper.questions_unanswered.all %} + Quit Exam + {% else %} + Finish Exam + {% endif %} + <span class="glyphicon glyphicon-off"></span></button></li> </ul> </form> <div class="time-div" id="time_left"></div> 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""" |