summaryrefslogtreecommitdiff
path: root/exam
diff options
context:
space:
mode:
Diffstat (limited to 'exam')
-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: