From 9f674808a5681a0380531ff62079b94874641c1e Mon Sep 17 00:00:00 2001
From: Prabhu Ramachandran
Date: Thu, 17 Nov 2011 17:35:30 +0530
Subject: BUG/ENH: Cleaning up page templates and fixing bug
If you complete the quiz it was going into a redirect loop, this is
fixed. Also cleaned up all the page templates with proper block
contents.
---
exam/views.py | 12 ++++++------
templates/404.html | 5 +++++
templates/500.html | 7 +++++++
templates/base.html | 22 ++++++++++++++++++++++
templates/exam/complete.html | 8 ++++++++
templates/exam/index.html | 12 ------------
templates/exam/intro.html | 7 +++++++
templates/exam/login.html | 6 ++++++
templates/exam/monitor.html | 9 ++++++++-
templates/exam/question.html | 18 ++++++++++++------
templates/exam/quit.html | 6 ++++++
templates/exam/register.html | 7 +++++++
12 files changed, 94 insertions(+), 25 deletions(-)
create mode 100644 templates/404.html
create mode 100644 templates/500.html
create mode 100644 templates/base.html
delete mode 100644 templates/exam/index.html
diff --git a/exam/views.py b/exam/views.py
index ad8a04f..2437fba 100644
--- a/exam/views.py
+++ b/exam/views.py
@@ -94,8 +94,8 @@ def start(request):
return complete(request, reason=msg)
try:
old_paper = QuestionPaper.objects.get(user=user, quiz=quiz)
- p = old_paper.current_question()
- return redirect('/exam/%s'%p)
+ q = old_paper.current_question()
+ return show_question(request, q)
except QuestionPaper.DoesNotExist:
ip = request.META['REMOTE_ADDR']
key = gen_key(10)
@@ -198,11 +198,11 @@ def quit(request):
def complete(request, reason=None):
user = request.user
- yes = True
+ no = False
message = reason or 'The quiz has been completed. Thank you.'
- if request.method == 'POST':
- yes = request.POST.get('yes', None)
- if yes:
+ if request.method == 'POST' and 'no' in request.POST:
+ no = request.POST.get('no', False)
+ if not no:
# Logout the user and quit with the message given.
logout(request)
context = {'message': message}
diff --git a/templates/404.html b/templates/404.html
new file mode 100644
index 0000000..7d33dd3
--- /dev/null
+++ b/templates/404.html
@@ -0,0 +1,5 @@
+{% extends "base.html" %}
+
+{% block content %}
+The requested page does not exist.
+{% endblock %}
diff --git a/templates/500.html b/templates/500.html
new file mode 100644
index 0000000..d02721f
--- /dev/null
+++ b/templates/500.html
@@ -0,0 +1,7 @@
+{% extends "base.html" %}
+
+{% block content %}
+Internal Server error.
+This event will be reported.
+Sorry for the inconvinience.
+{% endblock %}
diff --git a/templates/base.html b/templates/base.html
new file mode 100644
index 0000000..22e9ba2
--- /dev/null
+++ b/templates/base.html
@@ -0,0 +1,22 @@
+
+
+
+
{{message}}
You may now close the browser.
+ +{% endblock content %} diff --git a/templates/exam/index.html b/templates/exam/index.html deleted file mode 100644 index 5470cf5..0000000 --- a/templates/exam/index.html +++ /dev/null @@ -1,12 +0,0 @@ -Welcome to the Examination.
-Lucky you, no questions available.
-{% endif %} diff --git a/templates/exam/intro.html b/templates/exam/intro.html index 0d673b3..75de639 100644 --- a/templates/exam/intro.html +++ b/templates/exam/intro.html @@ -1,3 +1,8 @@ +{% extends "base.html" %} + +{% block title %}Instructions and Rules {% endblock %} + +{% block content %}Welcome {{user.first_name.title}} {{user.last_name.title}}, @@ -44,3 +49,5 @@ carefully. {% csrf_token %} + +{% endblock content %} \ No newline at end of file diff --git a/templates/exam/login.html b/templates/exam/login.html index c8e27e4..b8594f4 100644 --- a/templates/exam/login.html +++ b/templates/exam/login.html @@ -1,3 +1,8 @@ +{% extends "base.html" %} + +{% block title %}Login{% endblock title %} + +{% block content %}
Welcome to the Examination. Please login to proceed.
@@ -10,3 +15,4 @@ Please login to proceed. New User Registration +{% endblock content %} \ No newline at end of file diff --git a/templates/exam/monitor.html b/templates/exam/monitor.html index f1c7779..d79bb35 100644 --- a/templates/exam/monitor.html +++ b/templates/exam/monitor.html @@ -1,6 +1,12 @@ +{% extends "base.html" %} + +{% block title %} Quiz results {% endblock title %} + +{% block meta %} {% endblock meta %} + +{% block content %}