summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNishanth Amuluru2011-11-10 20:25:03 +0530
committerNishanth Amuluru2011-11-10 20:50:26 +0530
commit5b2d3d506e277d57bae9a8b90dd348225347d486 (patch)
treeb4fb4fcff86354c3f2f4e092275e1de4a72fcbda
parentaeb50765bdcb5e94bcd07d22f2cfa8f692e13911 (diff)
downloadonline_test-5b2d3d506e277d57bae9a8b90dd348225347d486.tar.gz
online_test-5b2d3d506e277d57bae9a8b90dd348225347d486.tar.bz2
online_test-5b2d3d506e277d57bae9a8b90dd348225347d486.zip
Now the users cannot retake the test once they logout.
-rw-r--r--exam/models.py3
-rw-r--r--exam/views.py6
2 files changed, 9 insertions, 0 deletions
diff --git a/exam/models.py b/exam/models.py
index 226146a..61de093 100644
--- a/exam/models.py
+++ b/exam/models.py
@@ -51,6 +51,9 @@ class Quiz(models.Model):
user_ip = models.CharField(max_length=15)
# Unused currently.
key = models.CharField(max_length=10)
+
+ # used to allow/stop a user from retaking the quiz
+ is_active = models.BooleanField(default = True)
# The questions (a list of ids separated by '|')
questions = models.CharField(max_length=128)
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: