summaryrefslogtreecommitdiff
path: root/testapp/exam
diff options
context:
space:
mode:
authorHardik Ghaghada2013-04-24 01:36:35 +0530
committerHardik Ghaghada2013-04-24 01:36:35 +0530
commit29beb24fe345e7e20919a6122ffb3e0f13371143 (patch)
treeba2546f11522fc1fb5306714ddf6e40e75d21fc2 /testapp/exam
parenta89aff61b6bab0859c9f81142aa6be5d0ccc8ba1 (diff)
downloadonline_test-29beb24fe345e7e20919a6122ffb3e0f13371143.tar.gz
online_test-29beb24fe345e7e20919a6122ffb3e0f13371143.tar.bz2
online_test-29beb24fe345e7e20919a6122ffb3e0f13371143.zip
Corrected a minor error in fetch_questions function
Diffstat (limited to 'testapp/exam')
-rw-r--r--testapp/exam/views.py34
1 files changed, 18 insertions, 16 deletions
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index 0cfc5ab..63cc312 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -77,6 +77,8 @@ def is_moderator(user):
def fetch_questions(request):
"""Fetch questions from database based on the given search conditions &
tags"""
+ set1 = set()
+ set2 = set()
first_tag = request.POST.get('first_tag')
first_condition = request.POST.get('first_condition')
second_tag = request.POST.get('second_tag')
@@ -418,8 +420,6 @@ def show_all_questionpapers(request, questionpaper_id=None):
def automatic_questionpaper(request, questionpaper_id=None):
user = request.user
- set1 = set()
- set2 = set()
if not user.is_authenticated() or not is_moderator(user):
raise Http404('You are not allowed to view this page!')
@@ -438,18 +438,18 @@ def automatic_questionpaper(request, questionpaper_id=None):
return my_redirect('/exam/manage/showquiz')
else:
no_questions = int(request.POST.get('questions'))
- fetch_questions(request)
- n = len(set2)
+ fetched_questions = fetch_questions(request)
+ n = len(fetched_questions)
msg = ''
if (no_questions < n ):
i = n - no_questions
for i in range(0, i):
- set2.pop()
+ fetched_questions.pop()
elif ( no_questions > n):
msg = 'The given Criteria does not satisfy the number\
of Questions...'
tags = Tag.objects.all()
- context = {'data': {'questions': set2, 'tags': tags,
+ context = {'data': {'questions': fetched_questions, 'tags': tags,
'msg': msg}}
return my_render_to_response\
('exam/automatic_questionpaper.html',context,
@@ -474,18 +474,18 @@ def automatic_questionpaper(request, questionpaper_id=None):
questionpaper_id)
else:
no_questions = int(request.POST.get('questions'))
- fetch_questions(request)
- n = len(set2)
+ fetched_questions = fetch_questions(request)
+ n = len(fetched_questions)
msg = ''
if (no_questions < n ):
i = n - no_questions
for i in range(0, i):
- set2.pop()
+ fetched_questions.pop()
elif ( no_questions > n):
msg = 'The given Criteria does not satisfy the number of \
Questions...'
tags = Tag.objects.all()
- context = {'data': {'questions': set2, 'tags': tags, \
+ context = {'data': {'questions': fetched_questions, 'tags': tags, \
'msg': msg}}
return my_render_to_response\
('exam/automatic_questionpaper.html', context,
@@ -519,13 +519,14 @@ def manual_questionpaper(request, questionpaper_id=None):
quest_paper.questions.add(q)
return my_redirect('/exam/manage/showquiz')
else:
- fetch_questions(request)
- n = len(set2)
+ fetched_questions = fetch_questions(request)
+ n = len(fetched_questions)
msg = ''
if (n == 0):
msg = 'No matching Question found...'
tags = Tag.objects.all()
- context = {'data': {'questions': set2, 'tags': tags,'msg': msg}}
+ context = {'data': {'questions': fetched_questions,\
+ 'tags': tags,'msg': msg}}
return my_render_to_response('exam/manual_questionpaper.html',
context,
context_instance=RequestContext\
@@ -548,13 +549,14 @@ def manual_questionpaper(request, questionpaper_id=None):
return my_redirect('/exam/manage/showquestionpapers/'+\
questionpaper_id)
else:
- fetch_questions(request)
- n = len(set2)
+ fetched_questions = fetch_questions(request)
+ n = len(fetched_questions)
msg = ''
if (n == 0):
msg = 'No matching Question found...'
tags = Tag.objects.all()
- context = {'data': {'questions': set2, 'tags': tags,'msg': msg}}
+ context = {'data': {'questions': fetched_questions,\
+ 'tags': tags,'msg': msg}}
return my_render_to_response('exam/manual_questionpaper.html',
context,
context_instance=RequestContext\