From 67ac8617f28cf3c5443e7af9593d0d912928612c Mon Sep 17 00:00:00 2001 From: mahesh Date: Tue, 29 Aug 2017 13:44:30 +0530 Subject: Fixes 'AnonymousUser' object is not iterable bug. --- yaksh/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 3c7df4d..3c33e50 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -579,7 +579,8 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None): 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, -- cgit From e5cd812e8627686b2cff39ff14dbd9602f6fe3f3 Mon Sep 17 00:00:00 2001 From: mahesh Date: Wed, 30 Aug 2017 18:46:49 +0530 Subject: Fixes Multiple answerpaper objects returned bug --- yaksh/views.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 3c33e50..9f70299 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -402,12 +402,23 @@ def start(request, questionpaper_id=None, attempt_num=None): return my_render_to_response('yaksh/intro.html', context, context_instance=ci) else: - 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) - return show_question(request, new_paper.current_question(), new_paper) + 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) + return show_question(request, new_paper.current_question(), + new_paper + ) + else: + msg = 'You have already finished the quiz!' + raise Http404(msg) + @login_required -- cgit From ce21ae0cf3ea3541d588b30c0ae1c56d64c82e1d Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Thu, 31 Aug 2017 16:56:49 +0530 Subject: User Cannot skip/jump attempt numbers. Forces incremental nature of attempt number. --- yaksh/views.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'yaksh/views.py') 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 -- cgit From 09931d64e05378143a9a1f2e634fc447f935d873 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Tue, 5 Sep 2017 15:27:31 +0530 Subject: Fixes minor mistake. --- yaksh/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 7898d57..1c6feca 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -423,7 +423,7 @@ def start(request, questionpaper_id=None, attempt_num=None): if not last_attempt: attempt_number = 1 else: - last_attempt.attempt_number + 1 + attempt_number = last_attempt.attempt_number + 1 if attempt_num is None: context = { 'user': user, -- cgit