diff options
-rw-r--r-- | yaksh/models.py | 3 | ||||
-rw-r--r-- | yaksh/templates/yaksh/complete.html | 4 | ||||
-rw-r--r-- | yaksh/tests.py | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 828b0a0..bb8d193 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -529,7 +529,8 @@ class AnswerPaper(models.Model): def current_question(self): """Returns the current active question to display.""" - return self.questions_unanswered.first() + if self.questions_unanswered.all(): + return self.questions_unanswered.all()[0] def questions_left(self): """Returns the number of questions left.""" diff --git a/yaksh/templates/yaksh/complete.html b/yaksh/templates/yaksh/complete.html index 7ebd062..07cbf3a 100644 --- a/yaksh/templates/yaksh/complete.html +++ b/yaksh/templates/yaksh/complete.html @@ -5,6 +5,7 @@ {% block pagetitle %}Online Test{% endblock %} {% block content %} {% csrf_token %} + {% if paper.questions_answered.all or paper.questions_unanswered.all %} <br><center><table class="bordered-table zebra-striped span8" style="text-align:left;"> <tr><td><b>Submitted Questions</b></td> @@ -23,7 +24,8 @@ <p><b>All Questions have been Submitted</b></p> {% endif %} </td></tr> - </table></center> + </table></center> + {% endif %} <center><h2> Good bye! </h2></center> <center><h4> {{message}} </h4></center> <br><center><h4>You may now close the browser.</h4></center><br> diff --git a/yaksh/tests.py b/yaksh/tests.py index 0286232..f33f948 100644 --- a/yaksh/tests.py +++ b/yaksh/tests.py @@ -352,7 +352,7 @@ class AnswerPaperTestCases(unittest.TestCase): self.assertEqual(next_question_id.id, 3) questions_answered = self.answerpaper.get_questions_answered() self.assertEqual(questions_answered.count(), 1) - self.assertSequenceEqual(questions_answered, [self.questions.first()]) + self.assertSequenceEqual(questions_answered, [self.questions[0]]) questions_unanswered = self.answerpaper.get_questions_unanswered() self.assertEqual(questions_unanswered.count(), 2) self.assertSequenceEqual(questions_unanswered, |