diff options
Diffstat (limited to 'testapp/templates/exam/question.html')
-rw-r--r-- | testapp/templates/exam/question.html | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/testapp/templates/exam/question.html b/testapp/templates/exam/question.html index c74564c..8cd2599 100644 --- a/testapp/templates/exam/question.html +++ b/testapp/templates/exam/question.html @@ -11,6 +11,35 @@ {% block script %} <script src="{{ URL_ROOT }}/static/exam/js/question.js"></script> + +<script> +var time_left = {{ time_left }} +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 %} @@ -28,7 +57,6 @@ {% endblock %} {% block content %} -<input type=hidden id="time" value={{ time_left }}> <div class="topbar"> <div class="fill"> <div class="container"> |