summaryrefslogtreecommitdiff
path: root/testapp/exam/views.py
diff options
context:
space:
mode:
authorhardythe12012-02-20 19:51:58 +0530
committerhardythe12012-02-20 19:51:58 +0530
commitf6a90c1eb603c9f3b8178102e387025880c0a5ac (patch)
treeda20cd8a42abfa78604d8b3a09512613b9eaa24d /testapp/exam/views.py
parente8ba4ba5301a805194a555f52275407f045b91ab (diff)
downloadonline_test-f6a90c1eb603c9f3b8178102e387025880c0a5ac.tar.gz
online_test-f6a90c1eb603c9f3b8178102e387025880c0a5ac.tar.bz2
online_test-f6a90c1eb603c9f3b8178102e387025880c0a5ac.zip
changes to manage questions
Diffstat (limited to 'testapp/exam/views.py')
-rw-r--r--testapp/exam/views.py62
1 files changed, 45 insertions, 17 deletions
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index b202ff3..b8233b2 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -91,23 +91,23 @@ def user_register(request):
context_instance=RequestContext(request))
def add_question(request):
-
- if request.method == "POST":
- form = AddQuestionForm(request.POST)
- if form.is_valid():
- data = form.cleaned_data
- form.save()
- return my_redirect("/exam/manage/addquestion/")
-
- else:
- return my_render_to_response('exam/add_question.html',
- {'form':form},
- context_instance=RequestContext(request))
- else:
- form = AddQuestionForm()
- return my_render_to_response('exam/add_question.html',
- {'form':form},
- context_instance=RequestContext(request))
+
+ if request.method == "POST":
+ form = AddQuestionForm(request.POST)
+ if form.is_valid():
+ data = form.cleaned_data
+ form.save()
+ return my_redirect("/exam/manage/questions/")
+
+ else:
+ return my_render_to_response('exam/add_question.html',
+ {'form':form},
+ context_instance=RequestContext(request))
+ else:
+ form = AddQuestionForm()
+ return my_render_to_response('exam/add_question.html',
+ {'form':form},
+ context_instance=RequestContext(request))
def add_quiz(request):
if request.method == "POST":
@@ -355,6 +355,34 @@ def show_all_users(request):
print context
return my_render_to_response('exam/showusers.html',context,context_instance=RequestContext(request))
+def show_all_questions(request):
+ if request.method == 'POST':
+ data = request.POST.getlist('question')
+ if data == None:
+ questions = Question.objects.all()
+ context = {'papers': [],
+ 'question': None,
+ 'questions':questions}
+ return my_render_to_response('exam/showquestions.html', context,
+ context_instance=RequestContext(request))
+ for i in data:
+ question = Question.objects.get(id=i).delete()
+ questions = Question.objects.all()
+ context = {'papers': [],
+ 'question': None,
+ 'questions':questions}
+ return my_render_to_response('exam/showquestions.html', context,
+ context_instance=RequestContext(request))
+
+ else:
+ """Show the list of available quiz"""
+ questions = Question.objects.all()
+ context = {'papers': [],
+ 'question': None,
+ 'questions':questions}
+ return my_render_to_response('exam/showquestions.html', context,
+ context_instance=RequestContext(request))
+
def user_data(request, username):
"""Render user data."""
current_user = request.user