summaryrefslogtreecommitdiff
path: root/yaksh/templates
diff options
context:
space:
mode:
authormahesh2017-11-23 01:11:59 +0530
committermahesh2017-11-23 01:25:11 +0530
commitae4e2dad126535cda41a7b4a05fdb247f9cdf737 (patch)
tree4f0049a04e1645a0f5fd48e8d275d45a045aba74 /yaksh/templates
parent7e2972786599fc23c436e593fcc236defd93c88c (diff)
downloadonline_test-ae4e2dad126535cda41a7b4a05fdb247f9cdf737.tar.gz
online_test-ae4e2dad126535cda41a7b4a05fdb247f9cdf737.tar.bz2
online_test-ae4e2dad126535cda41a7b4a05fdb247f9cdf737.zip
Render error output with django template instead of javascript
Diffstat (limited to 'yaksh/templates')
-rw-r--r--yaksh/templates/exam.html16
-rw-r--r--yaksh/templates/yaksh/error_template.html93
2 files changed, 96 insertions, 13 deletions
diff --git a/yaksh/templates/exam.html b/yaksh/templates/exam.html
index f722c5f..fede185 100644
--- a/yaksh/templates/exam.html
+++ b/yaksh/templates/exam.html
@@ -33,15 +33,6 @@
</nav><!-- /.navbar -->
{% endblock %}
{% block content %}
- <script>
- $(document).ready(function() {
- var ele = document.getElementById('error_panel')
- if (ele) {
- ele.scrollIntoView(true);
- window.scrollBy(0, -15);
- }
- });
- </script>
<div class="container-fluid">
<div class="col-sm-3 col-md-2 sidebar">
<p> Question Navigator </p>
@@ -80,13 +71,12 @@
{% block main %}
{% endblock %}
</div>
+ </div>
<br/>
+ </div>
{% if question.type == 'code' or question.type == 'upload' %}
- <div class="row" id="error_panel">
- </div>
- </div>
+ <div class="row" id="error_panel"></div>
{% endif %}
- </div>
</div>
</div>
</div>
diff --git a/yaksh/templates/yaksh/error_template.html b/yaksh/templates/yaksh/error_template.html
new file mode 100644
index 0000000..d42a259
--- /dev/null
+++ b/yaksh/templates/yaksh/error_template.html
@@ -0,0 +1,93 @@
+{% block css%}
+ <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/dashboard.css" type="text/css" />
+{% endblock %}
+
+{% load custom_filters %}
+
+{% if error_message %}
+<div class="col-md-12">
+ {% for error in error_message %}
+
+ <div class="panel panel-danger">
+ <div class="panel-heading">Error No. {{ forloop.counter }}</div>
+ <div class="panel-body">
+ <div class="well well-sm">
+ {% if not error.type %}
+ <pre><code> {{error|safe}} </code></pre>
+
+ {% elif error.type == 'assertion' %}
+
+ {% if error.test_case %}
+ <strong> We tried your code with the following test case:</strong>
+ <br/></br>
+ <pre><code><strong style="color:#d9534f">
+ {{error.test_case}}
+ </strong></code></pre>
+ {% endif %}
+ <p> <b>The following error took place: </b></p>
+ <table class="table table-bordered" width="100%" id='assertion'>
+ <col width="30%">
+ <tr class = "active">
+ <td><b>Exception Name: </b></td>
+ <td><span style="color: #d9534f">{{error.exception}}</span></td>
+ </tr>
+ <tr>
+ <td><b>Exception Message: </b></td><td>{{error.message}}</td>
+ </tr>
+ <tr>
+ {% if error.traceback %}
+ <td><b>Full Traceback: </b></td>
+ <td><pre>{{error.traceback}}</pre></td>
+ {% endif %}
+ </tr>
+ </table>
+
+ {% elif error.type == 'stdio' %}
+
+ {% if error.given_input %}
+ <table class="table table-bordered">
+ <col width="30%">
+ <tr class = "active">
+ <td> For given Input value(s):</td>
+ <td>{{error.given_input}}</td>
+ </tr>
+ </table>
+ {% endif %}
+
+ <table class="table table-bordered" width="100%" id="stdio">
+ <col width="10%">
+ <col width="40%">
+ <col width="40%">
+ <col width="10%">
+ <tr class="info">
+ <th><center>Line No.</center></th>
+ <th><center>Expected Output</center></th>
+ <th><center>User output</center></th>
+ <th><center>Status</center></th>
+ </tr>
+ {% for expected,user in error.expected_output|zip:error.user_output %}
+ <td> {{forloop.counter}} </td>
+ <td>{{expected|default:""}} </td>
+ <td>{{user|default:""}}</td>
+ {% if forloop.counter0 in error.error_line_numbers or not expected or not user %}
+ <td><span class ="glyphicon glyphicon-remove text-warning"/></td>
+ {% else %}
+ <td><span class ="glyphicon glyphicon-ok text-success"/></td>
+ {% endif %}
+ </tr>
+ {% endfor %}
+ </table>
+ <table width="100%" class='table table-bordered'>
+ <col width="10">
+ <tr class = "danger">
+ <td><b>Error:</b></td>
+ <td>{{error.error_msg}}</td>
+ </tr>
+ </table>
+ {% endif %}
+ </div>
+ </div>
+ </div>
+ {% endfor %}
+ </div>
+{% endif %} \ No newline at end of file