diff options
author | ankitjavalkar | 2019-01-29 12:16:14 +0530 |
---|---|---|
committer | ankitjavalkar | 2019-01-30 12:27:28 +0530 |
commit | 30c1119d3a1a5b7aaa96b80cb431c5b34eeb23b5 (patch) | |
tree | 0edca892c989e841dcf3f11fc99bbb1389c52311 | |
parent | cedceac0c7b64e2116b5cfd5ec9461fdff98842c (diff) | |
download | online_test-30c1119d3a1a5b7aaa96b80cb431c5b34eeb23b5.tar.gz online_test-30c1119d3a1a5b7aaa96b80cb431c5b34eeb23b5.tar.bz2 online_test-30c1119d3a1a5b7aaa96b80cb431c5b34eeb23b5.zip |
Allow student to open a quiz if status is inprogress and redirect to completion page if attempts are exceeded
-rw-r--r-- | yaksh/views.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 6c7a12e..d36a5f6 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -515,23 +515,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, |