summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authorKing2019-03-06 11:40:41 +0530
committerGitHub2019-03-06 11:40:41 +0530
commitc05e98fdd7226d2e400fce5c8bef2998bfb5e425 (patch)
tree876f0d370faf3f726e4965ff962e13d86de4f937 /yaksh
parent54d7f6484768cd38c6f15c06b82f7c286bdb45f3 (diff)
parentc6475d2dc6c08fbaac3a0803f2b88c1aed539ff1 (diff)
downloadonline_test-c05e98fdd7226d2e400fce5c8bef2998bfb5e425.tar.gz
online_test-c05e98fdd7226d2e400fce5c8bef2998bfb5e425.tar.bz2
online_test-c05e98fdd7226d2e400fce5c8bef2998bfb5e425.zip
Merge pull request #563 from ankitjavalkar/quiz-inprogress-bug-fix
Allow student to open a quiz if status is inprogress
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/models.py4
-rw-r--r--yaksh/views.py29
2 files changed, 20 insertions, 13 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 7e0364a..1d6bb89 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1604,7 +1604,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
+ 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):
diff --git a/yaksh/views.py b/yaksh/views.py
index 94ef19b..9199a3a 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -528,23 +528,28 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None,
# if any previous attempt
last_attempt = AnswerPaper.objects.get_user_last_attempt(
quest_paper, user, course_id)
- if last_attempt and last_attempt.is_attempt_inprogress():
- return show_question(
- request, last_attempt.current_question(), last_attempt,
- course_id=course_id, module_id=module_id,
- previous_question=last_attempt.current_question()
- )
+
+ if last_attempt:
+ if last_attempt.is_attempt_inprogress():
+ return show_question(
+ request, last_attempt.current_question(), last_attempt,
+ course_id=course_id, module_id=module_id,
+ previous_question=last_attempt.current_question()
+ )
+ attempt_number = last_attempt.attempt_number + 1
+ else:
+ attempt_number = 1
+
# allowed to start
if not quest_paper.can_attempt_now(user, course_id)[0]:
msg = quest_paper.can_attempt_now(user, course_id)[1]
if is_moderator(user):
return prof_manage(request, msg=msg)
- return view_module(request, module_id=module_id, course_id=course_id,
- msg=msg)
- if not last_attempt:
- attempt_number = 1
- else:
- attempt_number = last_attempt.attempt_number + 1
+ return complete(
+ request, msg, last_attempt.attempt_number, quest_paper.id,
+ course_id=course_id, module_id=module_id
+ )
+
if attempt_num is None and not quest_paper.quiz.is_exercise:
context = {
'user': user,