diff options
author | Prabhu Ramachandran | 2011-11-17 16:40:05 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2011-11-17 16:40:05 +0530 |
commit | 78e18eae416a37fdb2e27d4dde7ed9675692ac7d (patch) | |
tree | 4c403239be513d8259dd3810326bbfcdc0adaf23 /templates/exam | |
parent | e2b3d315c3cd3eab79ad74224436b681cbf84371 (diff) | |
download | online_test-78e18eae416a37fdb2e27d4dde7ed9675692ac7d.tar.gz online_test-78e18eae416a37fdb2e27d4dde7ed9675692ac7d.tar.bz2 online_test-78e18eae416a37fdb2e27d4dde7ed9675692ac7d.zip |
ENH: Added a Quiz model and time based papers
Added a model called Quiz which allows the admin to define a quiz on a
date which can be active or deactivated. Users can take a quiz if one
is active and are given a fixed duration to complete the quiz. They may
login as many times as needed to finish it but the total time is logged.
Javascript code updates a timer on the page.
Diffstat (limited to 'templates/exam')
-rw-r--r-- | templates/exam/complete.html | 3 | ||||
-rw-r--r-- | templates/exam/question.html | 38 |
2 files changed, 38 insertions, 3 deletions
diff --git a/templates/exam/complete.html b/templates/exam/complete.html index ded38f7..bd90e6d 100644 --- a/templates/exam/complete.html +++ b/templates/exam/complete.html @@ -1,3 +1,4 @@ -<p>Exam is complete. Thank you. </p> +<h2> Good bye! </h2> +<p> {{message}} </p> <br /> <p>You may now close the browser.</p> diff --git a/templates/exam/question.html b/templates/exam/question.html index 75e5a62..2267efc 100644 --- a/templates/exam/question.html +++ b/templates/exam/question.html @@ -2,6 +2,8 @@ <script type="text/javascript"> <!-- +var time_left = {{ time_left }}; + function submitCode() { document.forms["code"].submit(); @@ -12,9 +14,36 @@ function submitCode() 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 dec_time() +{ + time_left -= 1; + if (time_left) { + var elem = document.getElementById("time_left"); + var t_str = secs_to_time(time_left); + elem.innerHTML = "<strong> Time left: " + t_str + "</strong>"; + setTimeout("dec_time()", 1000); + } + else { + document.forms["logout"].submit(); + } +} + //--> </script> +<body onload="dec_time()"> + <p>{{ question.description }} </p> {% if error_message %}<p><strong>ERROR:</strong></p><pre>{{ error_message }}</pre>{% endif %} @@ -35,10 +64,15 @@ onclick="submitCode();"/> <input id="skip" type="submit" name="skip" value="Skip question" /> </form> -<p> {{ user.first_name.title }} {{ user.last_name.title }}, you have {{ paper.questions_left }} question(s) left. </p> +<p> {{ user.first_name.title }} {{ user.last_name.title }}, +you have {{ paper.questions_left }} question(s) left in {{ quiz_name }}.</p> + +<p id="time_left"> <strong> Time left: </strong> </p> <hr/> -<form action="/exam/quit/" method="post"> +<form id="logout" action="/exam/quit/" method="post"> {% csrf_token %} <input type="submit" name="quit" value="Quit exam and logout" /> </form> + +</body>
\ No newline at end of file |