summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authormaheshgudi2017-08-31 16:56:49 +0530
committermahesh2017-09-01 15:45:46 +0530
commitce21ae0cf3ea3541d588b30c0ae1c56d64c82e1d (patch)
tree6fe828536a089dbee576ca9ff6a635ee449d1692 /yaksh/views.py
parente5cd812e8627686b2cff39ff14dbd9602f6fe3f3 (diff)
downloadonline_test-ce21ae0cf3ea3541d588b30c0ae1c56d64c82e1d.tar.gz
online_test-ce21ae0cf3ea3541d588b30c0ae1c56d64c82e1d.tar.bz2
online_test-ce21ae0cf3ea3541d588b30c0ae1c56d64c82e1d.zip
User Cannot skip/jump attempt numbers. Forces incremental nature of attempt number.
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 9f70299..add791e 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -393,8 +393,8 @@ def start(request, questionpaper_id=None, attempt_num=None):
if is_moderator(user):
return redirect("/exam/manage")
return redirect("/exam/quizzes")
+ attempt_number = 1 if not last_attempt else last_attempt.attempt_number + 1
if attempt_num is None:
- attempt_number = 1 if not last_attempt else last_attempt.attempt_number +1
context = {'user': user, 'questionpaper': quest_paper,
'attempt_num': attempt_number}
if is_moderator(user):
@@ -402,24 +402,18 @@ def start(request, questionpaper_id=None, attempt_num=None):
return my_render_to_response('yaksh/intro.html', context,
context_instance=ci)
else:
- attempted_paper = AnswerPaper.objects.filter(user=user,
- question_paper=quest_paper,
- attempt_number=attempt_num
- )
- if not attempted_paper:
- ip = request.META['REMOTE_ADDR']
- 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)
+ ip = request.META['REMOTE_ADDR']
+ 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_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)
-
-
+ msg = 'You have already finished the quiz!'
+ raise Http404(msg)
@login_required
@email_verified