From f1dde181a6c30d32ea4f4cf3d2d29b780c4d45a5 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Tue, 29 Jan 2019 12:17:09 +0530 Subject: Fix condition for comparison of current attempt number and maximum attempts allowed in _is_attempt_allowed --- yaksh/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index cce90e7..7a4d8d1 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1600,7 +1600,7 @@ class QuestionPaper(models.Model): attempts = AnswerPaper.objects.get_total_attempt(questionpaper=self, user=user, course_id=course_id) - return attempts != self.quiz.attempts_allowed + return attempts < self.quiz.attempts_allowed or self.quiz.attempts_allowed == -1 def can_attempt_now(self, user, course_id): if self._is_attempt_allowed(user, course_id): -- cgit From c6475d2dc6c08fbaac3a0803f2b88c1aed539ff1 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Mon, 4 Mar 2019 20:21:16 +0530 Subject: Fix PEP8 issues --- yaksh/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 7a4d8d1..c4e5a50 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1600,7 +1600,9 @@ class QuestionPaper(models.Model): attempts = AnswerPaper.objects.get_total_attempt(questionpaper=self, user=user, course_id=course_id) - return attempts < self.quiz.attempts_allowed or self.quiz.attempts_allowed == -1 + attempts_allowed = attempts < self.quiz.attempts_allowed + infinite_attempts = self.quiz.attempts_allowed == -1 + return attempts_allowed or infinite_attempts def can_attempt_now(self, user, course_id): if self._is_attempt_allowed(user, course_id): -- cgit