diff options
author | prathamesh | 2015-02-24 09:29:35 +0530 |
---|---|---|
committer | prathamesh | 2015-02-24 09:29:35 +0530 |
commit | caf153bcaa8b9a0096a4653b562198f2ba2cef9a (patch) | |
tree | 39f4fcd32d3936375a25caba7ca54c5654fac170 /testapp | |
parent | 8350eedd62176d2756aef06c13b363e552337109 (diff) | |
download | online_test-caf153bcaa8b9a0096a4653b562198f2ba2cef9a.tar.gz online_test-caf153bcaa8b9a0096a4653b562198f2ba2cef9a.tar.bz2 online_test-caf153bcaa8b9a0096a4653b562198f2ba2cef9a.zip |
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.
Diffstat (limited to 'testapp')
-rw-r--r-- | testapp/exam/static/exam/css/base.css | 70 | ||||
-rw-r--r-- | testapp/exam/templates/exam/question.html | 24 | ||||
-rw-r--r-- | testapp/exam/urls.py | 1 | ||||
-rw-r--r-- | 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 @@ -82,9 +82,29 @@ function setSnippetHeight() </div> </div> </div> +<div class = container> +<div class="sidebar"> + <p>Question Navigator </p> + <div class="pagination"> + <ul> + {% for qid, num in questions.items %} + {% if qid in to_attempt %} + {% if qid == question.id|slugify %} + <li class="active"><a href="{{ URL_ROOT }}/exam/{{ qid }}/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/">{{ num }}</a></li> + {% else %} + <li><a href="{{ URL_ROOT }}/exam/{{ qid }}/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/">{{ num }}</a></li> + {% endif %} + {% endif %} + {% if qid in submitted %} + <li class="done"><a href="#">{{ num }}</a></li> + {% endif %} + {% endfor %} + </ul> + </div> +</div> +</div> - - <h4><u> {{ question.summary }} </u><font class=pull-right>(Marks : {{ question.points }}) </font></h4><br> + <h4><u> {{ question.summary }} </u><font class=pull-right>(Marks : {{ question.points }}) </font></h4><br> <font size=3 face=arial> {{ question.description|safe }} </font> {% if error_message %} <div class="alert alert-error"> 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<q_id>\d+)/check/$', 'check'), url(r'^(?P<q_id>\d+)/check/(?P<attempt_no>\d+)/(?P<questionpaper_id>\d+)/$', 'check'), url(r'^intro/$', 'start'), + url(r'^(?P<q_id>\d+)/(?P<attempt_no>\d+)/(?P<questionpaper_id>\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, |