From 5b2d3d506e277d57bae9a8b90dd348225347d486 Mon Sep 17 00:00:00 2001 From: Nishanth Amuluru Date: Thu, 10 Nov 2011 20:25:03 +0530 Subject: Now the users cannot retake the test once they logout. --- exam/views.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'exam/views.py') diff --git a/exam/views.py b/exam/views.py index d8a0a45..43ac388 100644 --- a/exam/views.py +++ b/exam/views.py @@ -88,6 +88,8 @@ def start(request): user = request.user try: old_quiz = Quiz.objects.get(user=user) + if not old_quiz.is_active: + return redirect("/exam/complete/") q = old_quiz.current_question() return redirect('/exam/%s'%q) except Quiz.DoesNotExist: @@ -186,10 +188,14 @@ def quit(request): context_instance=RequestContext(request)) def complete(request): + user = request.user yes = True if request.method == 'POST': yes = request.POST.get('yes', None) if yes: + quiz = Quiz.objects.get(user=user) + quiz.is_active = False + quiz.save() logout(request) return render_to_response('exam/complete.html') else: -- cgit