summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprathamesh2015-04-07 14:33:46 +0530
committerprathamesh2015-04-07 14:33:46 +0530
commit7eaeb90e0db758894c2cebf8e062d65c1faa2a6d (patch)
tree3e2b2f7f8f9d40ad1ed2171d3c868538a4d30162
parentd0b6afb0d73c8ed32d6ca1151f5e3c6b216c50b7 (diff)
downloadonline_test-7eaeb90e0db758894c2cebf8e062d65c1faa2a6d.tar.gz
online_test-7eaeb90e0db758894c2cebf8e062d65c1faa2a6d.tar.bz2
online_test-7eaeb90e0db758894c2cebf8e062d65c1faa2a6d.zip
Changed variable name
-rw-r--r--testapp/exam/templates/exam/intro.html2
-rw-r--r--testapp/exam/templates/exam/quit.html4
-rw-r--r--testapp/exam/urls.py8
-rw-r--r--testapp/exam/views.py48
4 files changed, 31 insertions, 31 deletions
diff --git a/testapp/exam/templates/exam/intro.html b/testapp/exam/templates/exam/intro.html
index 58068ed..592937a 100644
--- a/testapp/exam/templates/exam/intro.html
+++ b/testapp/exam/templates/exam/intro.html
@@ -27,7 +27,7 @@
</ul>
<p> We hope you enjoy taking this exam !!!</p>
- <form action="{{URL_ROOT}}/exam/start/{{ attempt_no }}/{{ paper_id }}/" method="post" align="center">
+ <form action="{{URL_ROOT}}/exam/start/{{ attempt_num }}/{{ paper_id }}/" method="post" align="center">
{% csrf_token %}
<center><button class="btn" type="submit" name="start">Start Exam!</button></center>
</form>
diff --git a/testapp/exam/templates/exam/quit.html b/testapp/exam/templates/exam/quit.html
index 2c347cb..f49b62f 100644
--- a/testapp/exam/templates/exam/quit.html
+++ b/testapp/exam/templates/exam/quit.html
@@ -7,8 +7,8 @@
<center><h4>Your current answers are saved.</h4></center>
<center><h4> Are you sure you wish to quit the exam?</h4></center>
<center><h4> Be sure, as you won't be able to restart this exam.</h4></center>
- <form action="{{URL_ROOT}}/exam/complete/{{ attempt_no }}/{{ id }}/" method="post">
+ <form action="{{URL_ROOT}}/exam/complete/{{ attempt_num }}/{{ id }}/" method="post">
{% csrf_token %}
- <center><button class="btn" type="submit" name="yes">Yes!</button>&nbsp;<button class="btn" type="button" name="no" onClick="window.location='{{ URL_ROOT }}/exam/start/{{ attempt_no }}/{{ id }}/'">No!</button></center>
+ <center><button class="btn" type="submit" name="yes">Yes!</button>&nbsp;<button class="btn" type="button" name="no" onClick="window.location='{{ URL_ROOT }}/exam/start/{{ attempt_num }}/{{ id }}/'">No!</button></center>
</form>
{% endblock content %}
diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py
index 6cd56cf..8a01a81 100644
--- a/testapp/exam/urls.py
+++ b/testapp/exam/urls.py
@@ -6,16 +6,16 @@ urlpatterns = patterns('testapp.exam.views',
url(r'^quizzes/$', 'quizlist_user'),
url(r'^results/$', 'results_user'),
url(r'^start/$', 'start'),
- url(r'^start/(?P<attempt_no>\d+)/(?P<questionpaper_id>\d+)/$', 'start'),
- url(r'^quit/(?P<attempt_no>\d+)/(?P<questionpaper_id>\d+)/$', 'quit'),
+ url(r'^start/(?P<attempt_num>\d+)/(?P<questionpaper_id>\d+)/$', 'start'),
+ url(r'^quit/(?P<attempt_num>\d+)/(?P<questionpaper_id>\d+)/$', 'quit'),
url(r'^intro/(?P<questionpaper_id>\d+)/$', 'intro'),
url(r'^complete/$', 'complete'),
- url(r'^complete/(?P<attempt_no>\d+)/(?P<questionpaper_id>\d+)/$',\
+ url(r'^complete/(?P<attempt_num>\d+)/(?P<questionpaper_id>\d+)/$',\
'complete'),
url(r'^register/$', 'user_register'),
url(r'^(?P<q_id>\d+)/$', 'question'),
url(r'^(?P<q_id>\d+)/check/$', 'check'),
- url(r'^(?P<q_id>\d+)/check/(?P<attempt_no>\d+)/(?P<questionpaper_id>\d+)/$',\
+ url(r'^(?P<q_id>\d+)/check/(?P<attempt_num>\d+)/(?P<questionpaper_id>\d+)/$',\
'check'),
url(r'^intro/$', 'start'),
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index 8222319..89b2fd7 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -186,7 +186,7 @@ def intro(request, questionpaper_id):
already_attempted = attempted_papers.count()
if already_attempted == 0:
context = {'user': user, 'paper_id': questionpaper_id,\
- 'attempt_no': already_attempted + 1}
+ 'attempt_num': already_attempted + 1}
return my_render_to_response('exam/intro.html', context,
context_instance=ci)
if already_attempted < attempt_number or attempt_number < 0:
@@ -195,7 +195,7 @@ def intro(request, questionpaper_id):
days_after_attempt = (today - previous_attempt_day).days
if days_after_attempt >= time_lag:
context = {'user': user, 'paper_id': questionpaper_id,\
- 'attempt_no': already_attempted + 1}
+ 'attempt_num': already_attempted + 1}
return my_render_to_response('exam/intro.html', context,
context_instance=ci)
else:
@@ -658,7 +658,7 @@ def user_login(request):
context_instance=ci)
-def start(request, attempt_no=None, questionpaper_id=None):
+def start(request, attempt_num=None, questionpaper_id=None):
"""Check the user cedentials and if any quiz is available,
start the exam."""
user = request.user
@@ -671,13 +671,13 @@ def start(request, attempt_no=None, questionpaper_id=None):
except QuestionPaper.DoesNotExist:
msg = 'Quiz not found, please contact your '\
'instructor/administrator. Please login again thereafter.'
- return complete(request, msg, attempt_no, questionpaper_id)
+ return complete(request, msg, attempt_num, questionpaper_id)
try:
old_paper = AnswerPaper.objects.get(
- question_paper=questionpaper, user=user, attempt_number=attempt_no)
+ question_paper=questionpaper, user=user, attempt_number=attempt_num)
q = old_paper.current_question()
- return show_question(request, q, attempt_no, questionpaper_id)
+ return show_question(request, q, attempt_num, questionpaper_id)
except AnswerPaper.DoesNotExist:
ip = request.META['REMOTE_ADDR']
key = gen_key(10)
@@ -687,13 +687,13 @@ def start(request, attempt_no=None, questionpaper_id=None):
msg = 'You do not have a profile and cannot take the quiz!'
raise Http404(msg)
- new_paper = questionpaper.make_answerpaper(user, ip, attempt_no)
+ new_paper = questionpaper.make_answerpaper(user, ip, attempt_num)
# Make user directory.
user_dir = get_user_dir(user)
- return start(request, attempt_no, questionpaper_id)
+ return start(request, attempt_num, questionpaper_id)
-def question(request, q_id, attempt_no, questionpaper_id, success_msg=None):
+def question(request, q_id, attempt_num, questionpaper_id, success_msg=None):
"""Check the credentials of the user and start the exam."""
user = request.user
@@ -703,7 +703,7 @@ def question(request, q_id, attempt_no, questionpaper_id, success_msg=None):
try:
q_paper = QuestionPaper.objects.get(id=questionpaper_id)
paper = AnswerPaper.objects.get(
- user=request.user, attempt_number=attempt_no, question_paper=q_paper)
+ user=request.user, attempt_number=attempt_num, question_paper=q_paper)
except AnswerPaper.DoesNotExist:
return my_redirect('/exam/start/')
if not paper.question_paper.quiz.active:
@@ -730,21 +730,21 @@ def question(request, q_id, attempt_no, questionpaper_id, success_msg=None):
context_instance=ci)
-def show_question(request, q_id, attempt_no, questionpaper_id, success_msg=None):
+def show_question(request, q_id, attempt_num, questionpaper_id, success_msg=None):
"""Show a question if possible."""
if len(q_id) == 0:
msg = 'Congratulations! You have successfully completed the quiz.'
- return complete(request, msg, attempt_no, questionpaper_id)
+ return complete(request, msg, attempt_num, questionpaper_id)
else:
- return question(request, q_id, attempt_no, questionpaper_id, success_msg)
+ return question(request, q_id, attempt_num, questionpaper_id, success_msg)
-def check(request, q_id, attempt_no=None, questionpaper_id=None):
+def check(request, q_id, attempt_num=None, questionpaper_id=None):
"""Checks the answers of the user for particular question"""
user = request.user
q_paper = QuestionPaper.objects.get(id=questionpaper_id)
- paper = AnswerPaper.objects.get(user=request.user, attempt_number=attempt_no,
+ paper = AnswerPaper.objects.get(user=request.user, attempt_number=attempt_num,
question_paper=q_paper)
if not user.is_authenticated() or paper.end_time < datetime.datetime.now():
return my_redirect('/exam/login/')
@@ -755,7 +755,7 @@ def check(request, q_id, attempt_no=None, questionpaper_id=None):
success = True
if skip is not None:
next_q = paper.skip()
- return show_question(request, next_q, attempt_no, questionpaper_id)
+ return show_question(request, next_q, attempt_num, questionpaper_id)
# Add the answer submitted, regardless of it being correct or not.
if question.type == 'mcq':
@@ -799,10 +799,10 @@ def check(request, q_id, attempt_no=None, questionpaper_id=None):
if not success: # Should only happen for non-mcq questions.
if time_left == 0:
reason = 'Your time is up!'
- return complete(request, reason, attempt_no, questionpaper_id)
+ return complete(request, reason, attempt_num, questionpaper_id)
if not paper.question_paper.quiz.active:
reason = 'The quiz has been deactivated!'
- return complete(request, reason, attempt_no, questionpaper_id)
+ return complete(request, reason, attempt_num, questionpaper_id)
context = {'question': question, 'error_message': err_msg,
'paper': paper, 'last_attempt': user_code,
'quiz_name': paper.question_paper.quiz.description,
@@ -814,10 +814,10 @@ def check(request, q_id, attempt_no=None, questionpaper_id=None):
else:
if time_left <= 0:
reason = 'Your time is up!'
- return complete(request, reason, attempt_no, questionpaper_id)
+ return complete(request, reason, attempt_num, questionpaper_id)
else:
next_q = paper.completed_question(question.id)
- return show_question(request, next_q, attempt_no,
+ return show_question(request, next_q, attempt_num,
questionpaper_id, success_msg)
@@ -853,15 +853,15 @@ def validate_answer(user, user_answer, question):
return correct, success, message
-def quit(request, attempt_no=None, questionpaper_id=None):
+def quit(request, attempt_num=None, questionpaper_id=None):
"""Show the quit page when the user logs out."""
context = {'id': questionpaper_id,
- 'attempt_no': attempt_no}
+ 'attempt_num': attempt_num}
return my_render_to_response('exam/quit.html', context,
context_instance=RequestContext(request))
-def complete(request, reason=None, attempt_no=None, questionpaper_id=None):
+def complete(request, reason=None, attempt_num=None, questionpaper_id=None):
"""Show a page to inform user that the quiz has been compeleted."""
user = request.user
@@ -873,7 +873,7 @@ def complete(request, reason=None, attempt_no=None, questionpaper_id=None):
else:
q_paper = QuestionPaper.objects.get(id=questionpaper_id)
paper = AnswerPaper.objects.get(user=user, question_paper=q_paper,
- attempt_number=attempt_no)
+ attempt_number=attempt_num)
paper.update_marks_obtained()
paper.update_percent()
paper.update_passed()