summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-09-05 18:40:44 +0530
committerGitHub2017-09-05 18:40:44 +0530
commite3a43662d2aae8688039671d3de532e48fbdfda9 (patch)
treec644e44b0cefa1c32e4ff02cfe6ed347dfe1e5df /yaksh/views.py
parent97a96d1678cb55b95ed14eb9a2b2790415d30abc (diff)
parent09931d64e05378143a9a1f2e634fc447f935d873 (diff)
downloadonline_test-e3a43662d2aae8688039671d3de532e48fbdfda9.tar.gz
online_test-e3a43662d2aae8688039671d3de532e48fbdfda9.tar.bz2
online_test-e3a43662d2aae8688039671d3de532e48fbdfda9.zip
Merge pull request #324 from maheshgudi/bugfix_multiple_answerpaper
Minor Bug fix (Anonymous User and Multiple Answerpaper errors)
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 8ce0c02..1c6feca 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -420,11 +420,11 @@ def start(request, questionpaper_id=None, attempt_num=None):
if is_moderator(user):
return redirect("/exam/manage")
return redirect("/exam/quizzes")
+ if not last_attempt:
+ attempt_number = 1
+ else:
+ attempt_number = last_attempt.attempt_number + 1
if attempt_num is None:
- if not last_attempt:
- attempt_number = 1
- else:
- last_attempt.attempt_number + 1
context = {
'user': user,
'questionpaper': quest_paper,
@@ -439,9 +439,14 @@ def start(request, questionpaper_id=None, attempt_num=None):
if not hasattr(user, 'profile'):
msg = 'You do not have a profile and cannot take the quiz!'
raise Http404(msg)
- new_paper = quest_paper.make_answerpaper(user, ip, attempt_num)
- return show_question(request, new_paper.current_question(), new_paper)
-
+ new_paper = quest_paper.make_answerpaper(user, ip, attempt_number)
+ if new_paper.status == 'inprogress':
+ return show_question(request, new_paper.current_question(),
+ new_paper
+ )
+ else:
+ msg = 'You have already finished the quiz!'
+ raise Http404(msg)
@login_required
@email_verified
@@ -638,7 +643,8 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
else:
return show_question(request, current_question, paper)
-
+@login_required
+@email_verified
def quit(request, reason=None, attempt_num=None, questionpaper_id=None):
"""Show the quit page when the user logs out."""
paper = AnswerPaper.objects.get(user=request.user,