summaryrefslogtreecommitdiff
path: root/testapp/exam/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'testapp/exam/views.py')
-rw-r--r--testapp/exam/views.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index 7216f5b..a529983 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -70,7 +70,7 @@ def user_register(request):
user = request.user
if user.is_authenticated():
- return my_redirect("/exam/start/")
+ return my_redirect("/exam/quizlist/")
if request.method == "POST":
form = UserRegisterForm(request.POST)
@@ -80,7 +80,7 @@ def user_register(request):
new_user = authenticate(username = u_name, password = pwd)
login(request, new_user)
- return my_redirect("/exam/start/")
+ return my_redirect("/exam/quizlist/")
else:
return my_render_to_response('exam/register.html',
@@ -259,7 +259,7 @@ def user_login(request):
if user.is_authenticated():
if user.groups.filter(name='moderator').count() > 0 :
return my_redirect('/exam/manage/')
- return my_redirect("/exam/start/")
+ return my_redirect("/exam/quizlist/")
if request.method == "POST":
form = UserLoginForm(request.POST)
@@ -268,7 +268,7 @@ def user_login(request):
login(request, user)
if user.groups.filter(name='moderator').count() > 0 :
return my_redirect('/exam/manage/')
- return my_redirect('/exam/start/')
+ return my_redirect('/exam/login/')
else:
context = {"form": form}
return my_render_to_response('exam/login.html', context,
@@ -279,18 +279,19 @@ def user_login(request):
return my_render_to_response('exam/login.html', context,
context_instance=RequestContext(request))
-def start(request):
+def start(request,quiz_id=None):
"""Check the user cedentials and if any quiz is available, start the exam."""
user = request.user
try:
# Right now the app is designed so there is only one active quiz
# at a particular time.
- quiz = Quiz.objects.get(active=True)
+ quiz = Quiz.objects.get(id=quiz_id)
except Quiz.DoesNotExist:
- msg = 'No active quiz found, please contact your '\
+ msg = 'Quiz not found, please contact your '\
'instructor/administrator. Please login again thereafter.'
return complete(request, reason=msg)
+
try:
old_paper = QuestionPaper.objects.get(user=user, quiz=quiz)
q = old_paper.current_question()
@@ -500,6 +501,19 @@ def show_all_users(request):
print context
return my_render_to_response('exam/showusers.html',context,context_instance=RequestContext(request))
+def quizlist(request):
+ """Generates a list of all the quizzes that are active for the students to attempt."""
+
+ quizzes = Quiz.objects.all()
+ context = {'papers': [],
+ 'quiz': None,
+ 'quizzes':quizzes}
+ return my_render_to_response('exam/quizlist.html', context,
+ context_instance=RequestContext(request))
+
+
+
+
def show_all_quiz(request):
"""Generates a list of all the quizzes that are currently in the database."""