diff options
Diffstat (limited to 'templates/exam/question.html')
-rw-r--r-- | templates/exam/question.html | 38 |
1 files changed, 36 insertions, 2 deletions
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 |