--- a/templates/display_question.html Tue Apr 20 23:59:44 2010 +0530
+++ b/templates/display_question.html Wed Apr 21 00:51:20 2010 +0530
@@ -1,15 +1,27 @@
{% extends 'base.html' %}
{% block script %}
- <script language="javascript">
- function dipost (){
+<script language="javascript">
+ var time_left = {{question.time_limit}};
+ function dec_counter (){
+ time_left -= 1;
+ if (time_left) {
+ document.getElementById("time_left").value = "Time left: " + time_left + " secs";
+ setTimeout("dec_counter()", 1000);
+ }
+ else {
+ dopost();
+ }
+ }
+ function dopost (){
document.getElementById("queform").submit();
}
- setTimeout("dipost()", {{question.time_limit}} * 1000)
+ setTimeout("dec_counter()", 1000);
</script>
{% endblock %}
{% block content %}
<form action="" method="post" id="queform">
{{question.description}} <br />
-<textarea name="answer"></textarea>
+ <textarea name="answer"></textarea><br />
+ <input type="button" value="Time left: {{question.time_limit}} secs" id="time_left">
</form>
{% endblock %}