summaryrefslogtreecommitdiff
path: root/testapp/templates/exam/question.html
diff options
context:
space:
mode:
Diffstat (limited to 'testapp/templates/exam/question.html')
-rw-r--r--testapp/templates/exam/question.html140
1 files changed, 78 insertions, 62 deletions
diff --git a/testapp/templates/exam/question.html b/testapp/templates/exam/question.html
index 8b589b6..4f65b64 100644
--- a/testapp/templates/exam/question.html
+++ b/testapp/templates/exam/question.html
@@ -1,23 +1,19 @@
{% extends "base.html" %}
+<!DOCTYPE html>
+
{% block title %} Answer question {% endblock %}
-{% block script %}
-<script type="text/javascript">
-<!--
-var time_left = {{ time_left }};
+{% block css %}
+<link rel="stylesheet" href="{{ URL_ROOT }}/static/exam/css/question.css" type="text/css" />
-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;
-}
+{% endblock %}
+{% 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);
@@ -31,61 +27,81 @@ function secs_to_time(secs)
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> Time left: " + t_str + "</strong>";
- setTimeout("update_time()", 1000);
- }
- else {
- document.forms["code"].submit();
+ 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 %}
+{% block pagetitle %}
+
+<table><h6><div>
+ <tr><td class=td1-class><h5>You have {{ paper.questions_left }} question(s) left in {{ quiz_name }} </h5>
+ <td class=td2-class><div class=time-div id="time_left">
+ </div>
+</div></h6></table>
+
+{% endblock %}
+
{% block content %}
-<h3> {{ question.summary }} </h3>
-
-<p>{{ question.description|safe }}
-<br/>
-(Marks: {{ question.points }}) </p>
-
-{% if error_message %}<p><strong>ERROR:</strong></p><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="20" cols="100" name="answer">{% if last_attempt %}{{last_attempt.strip}}{% else %}{% if question.type == "bash" %}#!/bin/bash{% else %}# Enter your answer here.{% endif %}{% endif %}</textarea>
-{% endif %}
-<br/>
-{% if question.type == "mcq" %}
-<input id="check" type="submit" name="check" value="Submit answer"/>
-{% else %}
-<input id="check" type="submit" name="check" value="Check Answer"
-onclick="submitCode();"/>
-{% endif %}
-<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 in {{ quiz_name }}.</p>
-
-<p id="time_left"> <strong> Time left: </strong> </p>
-
-<hr/>
-<form id="logout" action="{{URL_ROOT}}/exam/quit/" method="post">
-{% csrf_token %}
-<input type="submit" name="quit" value="Quit exam and logout" />
-</form>
+<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/{{ paper.question_paper.id }}/" method="post" class="pull-right">
+ {% csrf_token %}
+ <button class="btn" type="submit" name="quit">Quit Exam</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><div class="alert alert-error">{{ error_message }}</div>{% endif %}
+ <p id="status"></p>
+ <form id="code" action="{{URL_ROOT}}/exam/{{ question.id }}/check/{{ paper.question_paper.id }}/" 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 tabindex=1 rows="15" style="width:750px;margin-bottom:10px;" name="answer" id="answer" wrap="off" onkeydown="return catchTab(this,event)">{% if last_attempt %}{{last_attempt.strip}}{% else %}{% if question.type == "bash" %} #!/bin/bash{% else %}{{ question.snippet }}{% endif %}{% endif %}</textarea>
+<br>
+
+ <script type="text/javascript">
+ createTextAreaWithLines('answer');
+ </script>
+ {% 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 %}