summaryrefslogtreecommitdiff
path: root/testapp/static/exam/js/question.js
blob: 554a9487dcf48a12c91aa2a2491256fe178a592e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
      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();
    	    }	
      }