summaryrefslogtreecommitdiff
path: root/testapp/templates/exam/question.html
blob: d3da9fc0cfc407fcb67b68c5a4b3a08dcd0e6c5a (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{% extends "base.html" %}

<!DOCTYPE html>

{% block title %} Answer question {% endblock %}

{% block css %}
<link rel="stylesheet" href="{{ URL_ROOT }}/static/exam/css/question.css" type="text/css" />
{% endblock %}

{% block script %}
   <script type="text/javascript">
      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();
    	    }	
      }
   </script>
{% endblock script %}

{% block onload %} onload="update_time()" {% endblock onload %}

{% block pagetitle %}<br><h5>You have {{ paper.questions_left }} question(s) left in {{ quiz_name }} </h5>
<div class=time-div>
         <p id="time_left" style="color:white;"></p>
</div>
{% endblock %}

{% block content %}
<div class="topbar">
  <div class="fill">
     <div class="container">
        <h3 class="brand"><strong>Online Test</h3></strong>
        <ul>
        <li> <h5><a> Hi {{user.first_name.title}} {{user.last_name.title}} !!! </a></h5>
        </ul>
        <form id="logout" action="{{URL_ROOT}}/exam/quit/" method="post" class="pull-right">
        {% csrf_token %}
         <button class="btn" type="submit" name="quit">Quit Exam and Logout</button> </li>

        </form>
     </div>
   </div>
</div>

         
     	 <h4><u> {{ question.summary }} </u><font class=pull-right>(Marks : {{ question.points }}) </font></h4><br> 
	 <font size=3 face=arial>	{{ question.description|safe }} </font>

         {% if error_message %}<h5>ERROR:<h5><pre>{{ error_message }}</pre>{% endif %}
         <p id="status"></p>
         <form id="code" action="{{URL_ROOT}}/exam/{{ question.id }}/check/" method="post">
         {% csrf_token %}
         {% if question.type == "mcq" %}
         {% for option in question.options.strip.splitlines %}
         <input name="answer" type="radio" value="{{option}}" />{{option}} <br/>
         {% endfor %}
         {% else %}
         <textarea rows="15" style="width:700px;" name="answer">{% if last_attempt %}{{last_attempt.strip}}{% else %}{% if question.type == "bash" %} #!/bin/bash{% else %}# Enter your answer here.{% endif %}{% endif %}</textarea>
         {% endif %}

         {% if question.type == "mcq" %}
         <br><button class="btn" type="submit" name="check" id="check">Submit Answer</button>&nbsp;&nbsp;
         {% else %}
         <button class="btn" type="submit" name="check" id="check" onClick="submitCode();">Check Answer</button>&nbsp;&nbsp;
         {% endif %}
         <button class="btn" type="submit" name="skip" id="skip">Skip Question</button>
         </form>
         
      
{% endblock content %}