From caf153bcaa8b9a0096a4653b562198f2ba2cef9a Mon Sep 17 00:00:00 2001
From: prathamesh
Date: Tue, 24 Feb 2015 09:29:35 +0530
Subject: Question navigator implemented
Students can now move from one question to another through
the navigator window.
Also, the questions attempted will have different color then
the ones which are not attempted.
---
testapp/exam/static/exam/css/base.css | 70 ++++++++++++++++++++++++++++++-
testapp/exam/templates/exam/question.html | 24 ++++++++++-
testapp/exam/urls.py | 1 +
testapp/exam/views.py | 63 +++++++++++++++++++++++-----
4 files changed, 145 insertions(+), 13 deletions(-)
diff --git a/testapp/exam/static/exam/css/base.css b/testapp/exam/static/exam/css/base.css
index 051ba22..3570098 100644
--- a/testapp/exam/static/exam/css/base.css
+++ b/testapp/exam/static/exam/css/base.css
@@ -245,7 +245,30 @@ body {
.container:after {
clear: both;
}
-
+.container-fluid {
+ position: relative;
+ min-width: 940px;
+ padding-left: 20px;
+ padding-right: 20px;
+ zoom: 1;
+}
+.container-fluid:before, .container-fluid:after {
+ display: table;
+ content: "";
+ zoom: 1;
+}
+.container-fluid:after {
+ clear: both;
+}
+.container-fluid > .sidebar {
+ position: absolute;
+ top: 0;
+ left: 20px;
+ width: 220px;
+}
+.container-fluid > .content {
+ margin-left: 240px;
+}
a {
color: #0069d6;
text-decoration: none;
@@ -2257,3 +2280,48 @@ button.btn::-moz-focus-inner, input[type=submit].btn::-moz-focus-inner {
.tab-content > .active, .pill-content > .active {
display: block;
}
+.pagination {
+ height: 36px;
+ margin: 18px 0;
+}
+.pagination ul {
+ float: left;
+ margin: 0;
+ border: 1px solid #ddd;
+ border: 1px solid rgba(0, 0, 0, 0.15);
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+ -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+}
+.pagination li {
+ display: inline;
+}
+.pagination a {
+ float: left;
+ padding: 0 14px;
+ line-height: 34px;
+ border-right: 1px solid;
+ border-right-color: #ddd;
+ border-right-color: rgba(0, 0, 0, 0.15);
+ *border-right-color: #ddd;
+ /* IE6-7 */
+
+ text-decoration: none;
+}
+.pagination a:hover, .pagination .active a {
+ background-color: #c7eefe;
+}
+/*custom classes*/
+.pagination .done a {
+ background-color: #00CC66;
+}
+.pagination .disabled a, .pagination .disabled a:hover {
+ background-color: transparent;
+ color: #bfbfbf;
+}
+.pagination .next a {
+ border: 0;
+}
diff --git a/testapp/exam/templates/exam/question.html b/testapp/exam/templates/exam/question.html
index 03284ce..96e7bd6 100644
--- a/testapp/exam/templates/exam/question.html
+++ b/testapp/exam/templates/exam/question.html
@@ -81,10 +81,30 @@ function setSnippetHeight()
+
+
+
-
- {{ question.summary }} (Marks : {{ question.points }})
+ {{ question.summary }} (Marks : {{ question.points }})
{{ question.description|safe }}
{% if error_message %}
diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py
index f7a7c54..62fa9e1 100644
--- a/testapp/exam/urls.py
+++ b/testapp/exam/urls.py
@@ -17,6 +17,7 @@ urlpatterns = patterns('testapp.exam.views',
url(r'^(?P
\d+)/check/$', 'check'),
url(r'^(?P\d+)/check/(?P\d+)/(?P\d+)/$', 'check'),
url(r'^intro/$', 'start'),
+ url(r'^(?P\d+)/(?P\d+)/(?P\d+)/$', 'show_question'),
url(r'^manage/$', 'prof_manage'),
url(r'^manage/addquestion/$', 'add_question'),
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index f94d383..94a5ffb 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -4,7 +4,7 @@ import os
import stat
from os.path import dirname, pardir, abspath, join, exists
import datetime
-
+import collections
from django.http import HttpResponse
from django.contrib.auth import login, logout, authenticate
from django.shortcuts import render_to_response, get_object_or_404, redirect
@@ -714,15 +714,36 @@ def question(request, q_id, attempt_no, questionpaper_id, success_msg=None):
if time_left == 0:
return complete(request, reason='Your time is up!')
quiz_name = paper.question_paper.quiz.description
+ to_attempt = []
+ submitted = []
+ if paper.questions:
+ to_attempt = (paper.questions).split('|')
+ if paper.questions_answered:
+ submitted = (paper.questions_answered).split('|')
+ all_questions = []
+ if not to_attempt:
+ submitted.sort()
+ all_questions = submitted
+ if not submitted:
+ to_attempt.sort()
+ all_questions = to_attempt
+ if to_attempt and submitted:
+ q_append = to_attempt + submitted
+ q_append.sort()
+ all_questions = q_append
+ questions = {}
+ for num, value in enumerate(all_questions, 1):
+ print num, value
+ questions[value] = num
+ questions = collections.OrderedDict(sorted(questions.items()))
if success_msg is None:
- context = {'question': q, 'paper': paper, 'user': user,
- 'quiz_name': quiz_name,
- 'time_left': time_left, }
+ context = {'question': q, 'questions' : questions, 'paper': paper,
+ 'user': user, 'quiz_name': quiz_name, 'time_left': time_left,
+ 'to_attempt' : to_attempt, 'submitted': submitted}
else:
- context = {'question': q, 'paper': paper, 'user': user,
- 'quiz_name': quiz_name,
- 'time_left': time_left,
- 'success_msg': success_msg}
+ context = {'question': q, 'questions' : questions, 'paper': paper,
+ 'user': user, 'quiz_name': quiz_name, 'time_left': time_left,
+ 'success_msg': success_msg, 'to_attempt' : to_attempt, 'submitted' : submitted}
ci = RequestContext(request)
return my_render_to_response('exam/question.html', context,
context_instance=ci)
@@ -798,10 +819,32 @@ def check(request, q_id, attempt_no=None, questionpaper_id=None):
if not paper.question_paper.quiz.active:
reason = 'The quiz has been deactivated!'
return complete(request, reason, attempt_no, questionpaper_id)
- context = {'question': question, 'error_message': err_msg,
+ to_attempt = []
+ submitted = []
+ if paper.questions:
+ to_attempt = (paper.questions).split('|')
+ if paper.questions_answered:
+ submitted = (paper.questions_answered).split('|')
+ all_questions = []
+ if not to_attempt:
+ submitted.sort()
+ all_questions = submitted
+ if not submitted:
+ to_attempt.sort()
+ all_questions = to_attempt
+ if to_attempt and submitted:
+ q_append = to_attempt + submitted
+ q_append.sort()
+ all_questions = q_append
+ questions = {}
+ for num, value in enumerate(all_questions, 1):
+ questions[value] = num
+ questions = collections.OrderedDict(sorted(questions.items()))
+ context = {'question': question, 'questions': questions,
+ 'error_message': err_msg,
'paper': paper, 'last_attempt': user_code,
'quiz_name': paper.question_paper.quiz.description,
- 'time_left': time_left}
+ 'time_left': time_left, 'to_attempt' : to_attempt, 'submitted': submitted}
ci = RequestContext(request)
return my_render_to_response('exam/question.html', context,
--
cgit