summaryrefslogtreecommitdiff
path: root/testapp
diff options
context:
space:
mode:
authorhardythe12012-03-28 11:55:34 +0530
committerhardythe12012-03-28 11:55:34 +0530
commit64b38d3365f1d65132942fce6e29fed7da076bba (patch)
tree15c07993620743f097cbf739e90fc3da59b957b1 /testapp
parent246478f4ef75ae713e96a64d210bd3710bed3df9 (diff)
downloadonline_test-64b38d3365f1d65132942fce6e29fed7da076bba.tar.gz
online_test-64b38d3365f1d65132942fce6e29fed7da076bba.tar.bz2
online_test-64b38d3365f1d65132942fce6e29fed7da076bba.zip
minor changes
Diffstat (limited to 'testapp')
-rw-r--r--testapp/exam/urls.py4
-rw-r--r--testapp/exam/views.py21
-rw-r--r--testapp/static/exam/js/edit_quiz.js21
-rw-r--r--testapp/templates/exam/question.html40
4 files changed, 67 insertions, 19 deletions
diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py
index 1e1cd12..f435e63 100644
--- a/testapp/exam/urls.py
+++ b/testapp/exam/urls.py
@@ -3,9 +3,9 @@ from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('exam.views',
url(r'^$', 'index'),
url(r'^login/$', 'user_login'),
- url(r'^quizlist/$', 'quizlist'),
- url(r'^start/(?P<quiz_id>\d+)/$', 'start'),
+ url(r'^start/$', 'start'),
url(r'^quit/$', 'quit'),
+ url(r'^intro/$','start'),
url(r'^complete/$', 'complete'),
url(r'^register/$', 'user_register'),
url(r'^(?P<q_id>\d+)/$', 'question'),
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index dedf68c..5b980f5 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -69,7 +69,7 @@ def user_register(request):
user = request.user
if user.is_authenticated():
- return my_redirect("/exam/quizlist/")
+ return my_redirect("/exam/start/")
if request.method == "POST":
form = UserRegisterForm(request.POST)
@@ -79,7 +79,7 @@ def user_register(request):
new_user = authenticate(username = u_name, password = pwd)
login(request, new_user)
- return my_redirect("/exam/quizlist/")
+ return my_redirect("/exam/start/")
else:
return my_render_to_response('exam/register.html',
@@ -307,7 +307,7 @@ def user_login(request):
if user.is_authenticated():
if user.groups.filter(name='moderator').count() > 0 :
return my_redirect('/exam/manage/')
- return my_redirect("/exam/quizlist/")
+ return my_redirect("/exam/intro/")
if request.method == "POST":
form = UserLoginForm(request.POST)
@@ -327,14 +327,14 @@ def user_login(request):
return my_render_to_response('exam/login.html', context,
context_instance=RequestContext(request))
-def start(request,quiz_id=None):
+def start(request):
"""Check the user cedentials and if any quiz is available, start the exam."""
user = request.user
try:
# Right now the app is designed so there is only one active quiz
# at a particular time.
- quiz = Quiz.objects.get(id=quiz_id)
+ quiz = Quiz.objects.get(active=True)
except Quiz.DoesNotExist:
msg = 'Quiz not found, please contact your '\
'instructor/administrator. Please login again thereafter.'
@@ -548,17 +548,6 @@ def show_all_users(request):
context = { 'question': questionpaper }
return my_render_to_response('exam/showusers.html',context,context_instance=RequestContext(request))
-def quizlist(request):
- """Generates a list of all the quizzes that are active for the students to attempt."""
-
- quizzes = Quiz.objects.all()
- context = {'papers': [],
- 'quiz': None,
- 'quizzes':quizzes}
- return my_render_to_response('exam/quizlist.html', context,
- context_instance=RequestContext(request))
-
-
def show_all_quiz(request):
"""Generates a list of all the quizzes that are currently in the database."""
diff --git a/testapp/static/exam/js/edit_quiz.js b/testapp/static/exam/js/edit_quiz.js
new file mode 100644
index 0000000..610a438
--- /dev/null
+++ b/testapp/static/exam/js/edit_quiz.js
@@ -0,0 +1,21 @@
+function form_load()
+{
+ var tags = document.getElementsByName('tags');
+
+ for (var i=0;i<tags.length;i++)
+ {
+ tags[i].id = tags[i].id + i;
+ }
+
+ for(var i=0;i<tags.length;i++)
+ {
+ var tags_id = document.getElementById('id_tags'+i);
+ tags_id.setAttribute('class','ac_input');
+ tags_id.setAttribute('autocomplete','off');
+
+ jQuery().ready(function()
+ {
+ jQuery("#id_tags" + i).autocomplete("/taggit_autocomplete_modified/json", { multiple: true });
+ });
+ }
+}
diff --git a/testapp/templates/exam/question.html b/testapp/templates/exam/question.html
index 981af7f..87ed40d 100644
--- a/testapp/templates/exam/question.html
+++ b/testapp/templates/exam/question.html
@@ -9,7 +9,45 @@
{% endblock %}
{% block script %}
-<script src="{{ URL_ROOT }}/static/exam/js/question.js"></script>
+<script>
+ var time_left = {{ time_left }};
+ function submitCode()
+ {
+ document.forms["code"].submit();
+ var x = document.getElementById("status");
+ x.innerHTML = "<strong>Checking answer ...</strong>";
+ x = document.getElementById("check");
+ x.disabled = true;
+ x.value = "Checking Answer ...";
+ document.getElementById("skip").disabled = true;
+ }
+
+ function secs_to_time(secs)
+ {
+ var h = Math.floor(secs/3600);
+ var h_s = (h > 0) ? h+'h:' : '';
+ var m = Math.floor((secs%3600)/60);
+ var m_s = (m > 0) ? m+'m:' : '';
+ var s_s = Math.floor(secs%60) + 's';
+ return h_s + m_s + s_s;
+ }
+
+ function update_time()
+ {
+ time_left -= 1;
+ if (time_left)
+ {
+ var elem = document.getElementById("time_left");
+ var t_str = secs_to_time(time_left);
+ elem.innerHTML = "<strong>" + t_str + "</strong>";
+ setTimeout("update_time()", 1000);
+ }
+ else
+ {
+ document.forms["code"].submit();
+ }
+ }
+</script>
{% endblock script %}
{% block onload %} onload="update_time()" {% endblock onload %}