diff options
author | prathamesh | 2017-09-05 19:42:04 +0530 |
---|---|---|
committer | prathamesh | 2017-09-05 19:42:04 +0530 |
commit | 09c00608a215df7a44782ab3f7c97cb912664bfd (patch) | |
tree | 9c267b989382bf81542650b28b0f3f179bb8b090 /yaksh/views.py | |
parent | 7aac7a18e4e393b7e267d3687be73a7fdfb7b400 (diff) | |
parent | e3a43662d2aae8688039671d3de532e48fbdfda9 (diff) | |
download | online_test-09c00608a215df7a44782ab3f7c97cb912664bfd.tar.gz online_test-09c00608a215df7a44782ab3f7c97cb912664bfd.tar.bz2 online_test-09c00608a215df7a44782ab3f7c97cb912664bfd.zip |
Merge branch 'master' of https://github.com/FOSSEE/online_test into improve-code-server
Conflicts Resolved:
yaksh/views.py
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index ba957db..0b601f2 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: - attempt_number = 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 @@ -671,6 +676,8 @@ def _update_paper(request, uid, result): return next_question, error_message, 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, |