diff options
author | hardythe1 | 2012-03-21 17:18:19 +0530 |
---|---|---|
committer | hardythe1 | 2012-03-21 17:18:19 +0530 |
commit | 8bedc83e30c80636df18b301a84c69cb6a543e53 (patch) | |
tree | 2065b5d0dd346a350f91e0b873c34e76bc3ab111 /testapp/exam | |
parent | e524bef336df95fd307d045af37c379bccf3ea14 (diff) | |
download | online_test-8bedc83e30c80636df18b301a84c69cb6a543e53.tar.gz online_test-8bedc83e30c80636df18b301a84c69cb6a543e53.tar.bz2 online_test-8bedc83e30c80636df18b301a84c69cb6a543e53.zip |
Modifications to show quizlist
Diffstat (limited to 'testapp/exam')
-rw-r--r-- | testapp/exam/urls.py | 3 | ||||
-rw-r--r-- | testapp/exam/views.py | 28 |
2 files changed, 23 insertions, 8 deletions
diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py index a8b81f7..e73ef2d 100644 --- a/testapp/exam/urls.py +++ b/testapp/exam/urls.py @@ -3,7 +3,8 @@ from django.conf.urls.defaults import patterns, include, url urlpatterns = patterns('exam.views', url(r'^$', 'index'), url(r'^login/$', 'user_login'), - url(r'^start/$', 'start'), + url(r'^quizlist/$', 'quizlist'), + url(r'^start/(?P<quiz_id>\d+)/$', 'start'), url(r'^quit/$', 'quit'), url(r'^complete/$', 'complete'), url(r'^register/$', 'user_register'), diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 0504bde..564f317 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', @@ -257,7 +257,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) @@ -266,7 +266,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, @@ -277,18 +277,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() @@ -498,6 +499,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.""" |