diff options
author | hardythe1 | 2012-02-20 20:29:06 +0530 |
---|---|---|
committer | hardythe1 | 2012-02-20 20:29:06 +0530 |
commit | ddb7f4e07771f4e4ca514c253d671698e1b74020 (patch) | |
tree | 1b476a130efb9eca565ea3fa7d588bf454b98796 /testapp | |
parent | c61396a219efb3b078094d028e41fe51bc857fe3 (diff) | |
download | online_test-ddb7f4e07771f4e4ca514c253d671698e1b74020.tar.gz online_test-ddb7f4e07771f4e4ca514c253d671698e1b74020.tar.bz2 online_test-ddb7f4e07771f4e4ca514c253d671698e1b74020.zip |
changes to manage quiz
Diffstat (limited to 'testapp')
-rw-r--r-- | testapp/exam/urls.py | 2 | ||||
-rw-r--r-- | testapp/exam/views.py | 31 | ||||
-rw-r--r-- | testapp/templates/exam/add_quiz.html | 2 | ||||
-rw-r--r-- | testapp/templates/manage.html | 2 |
4 files changed, 34 insertions, 3 deletions
diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py index 504a4e6..772a2f3 100644 --- a/testapp/exam/urls.py +++ b/testapp/exam/urls.py @@ -8,6 +8,7 @@ urlpatterns = patterns('exam.views', url(r'^manage/addquiz/$', 'add_quiz'), url(r'^manage/gradeuser/$', 'show_all_users'), url(r'^manage/questions/$', 'show_all_questions'), + url(r'^manage/showquiz/$','show_all_quiz'), url(r'^register/$', 'user_register'), url(r'^start/$', 'start'), url(r'^quit/$', 'quit'), @@ -19,3 +20,4 @@ urlpatterns = patterns('exam.views', url(r'^(?P<q_id>\d+)/$', 'question'), url(r'^(?P<q_id>\d+)/check/$', 'check'), ) + diff --git a/testapp/exam/views.py b/testapp/exam/views.py index b8233b2..6dd5fb4 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -115,7 +115,7 @@ def add_quiz(request): if form.is_valid(): data = form.cleaned_data form.save() - return my_redirect("/exam/manage/addquiz") + return my_redirect("/exam/manage/showquiz") else: return my_render_to_response('exam/add_quiz.html', @@ -355,6 +355,35 @@ def show_all_users(request): print context return my_render_to_response('exam/showusers.html',context,context_instance=RequestContext(request)) +def show_all_quiz(request): + if request.method == 'POST': + data = request.POST.getlist('quiz') + if data == None: + quizzes = Quiz.objects.all() + context = {'papers': [], + 'quiz': None, + 'quizzes':quizzes} + return my_render_to_response('exam/show_quiz.html', context, + context_instance=RequestContext(request)) + for i in data: + quiz = Quiz.objects.get(id=i).delete() + quizzes = Quiz.objects.all() + context = {'papers': [], + 'quiz': None, + 'quizzes':quizzes} + return my_render_to_response('exam/show_quiz.html', context, + context_instance=RequestContext(request)) + + else: + """Show the list of available quiz""" + quizzes = Quiz.objects.all() + context = {'papers': [], + 'quiz': None, + 'quizzes':quizzes} + return my_render_to_response('exam/show_quiz.html', context, + context_instance=RequestContext(request)) + + def show_all_questions(request): if request.method == 'POST': data = request.POST.getlist('question') diff --git a/testapp/templates/exam/add_quiz.html b/testapp/templates/exam/add_quiz.html index 80a52ed..d51d129 100644 --- a/testapp/templates/exam/add_quiz.html +++ b/testapp/templates/exam/add_quiz.html @@ -23,6 +23,6 @@ table th, table td { </table> </center> <center><button class="btn" type="submit" name="save">Save</button> -<button class="btn" type="reset" name="reset">Clear</button> </center> +<button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/showquiz/");'>Cancel</button> </center> </form> {% endblock %} diff --git a/testapp/templates/manage.html b/testapp/templates/manage.html index a21e8c4..0cc47ae 100644 --- a/testapp/templates/manage.html +++ b/testapp/templates/manage.html @@ -26,7 +26,7 @@ <h5>Manage</h5> <ul> <li><a href="{{ URL_ROOT }}/exam/manage/questions">Questions</a></li> - <li><a href="{{ URL_ROOT }}/exam/manage/addquiz">Quizzes</a></li> + <li><a href="{{ URL_ROOT }}/exam/manage/showquiz">Quizzes</a></li> <li><a href="{{ URL_ROOT }}/exam/manage/gradeuser">Grade User</a></li> <li><a href="{{ URL_ROOT }}/exam/manage/monitor">Monitor</a></li> </ul> |