From ae4e2dad126535cda41a7b4a05fdb247f9cdf737 Mon Sep 17 00:00:00 2001 From: mahesh Date: Thu, 23 Nov 2017 01:11:59 +0530 Subject: Render error output with django template instead of javascript --- yaksh/templates/exam.html | 16 +----- yaksh/templates/yaksh/error_template.html | 93 +++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 13 deletions(-) create mode 100644 yaksh/templates/yaksh/error_template.html (limited to 'yaksh/templates') 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 @@ {% endblock %} {% block content %} -
+

+ {% if question.type == 'code' or question.type == 'upload' %} -
-
- +
{% endif %} - 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%} + +{% endblock %} + +{% load custom_filters %} + +{% if error_message %} +
+ {% for error in error_message %} + +
+
Error No. {{ forloop.counter }}
+
+
+ {% if not error.type %} +
 {{error|safe}} 
+ + {% elif error.type == 'assertion' %} + + {% if error.test_case %} + We tried your code with the following test case: +

+

+          {{error.test_case}}
+          
+ {% endif %} +

The following error took place:

+ + + + + + + + + + + {% if error.traceback %} + + + {% endif %} + +
Exception Name: {{error.exception}}
Exception Message: {{error.message}}
Full Traceback:
{{error.traceback}}
+ + {% elif error.type == 'stdio' %} + + {% if error.given_input %} + + + + + + +
For given Input value(s):{{error.given_input}}
+ {% endif %} + + + + + + + + + + + + + {% for expected,user in error.expected_output|zip:error.user_output %} + + + + {% if forloop.counter0 in error.error_line_numbers or not expected or not user %} + + {% else %} + + {% endif %} + + {% endfor %} +
Line No.
Expected Output
User output
Status
{{forloop.counter}} {{expected|default:""}} {{user|default:""}}
+ + + + + + +
Error:{{error.error_msg}}
+ {% endif %} +
+
+
+ {% endfor %} +
+{% endif %} \ No newline at end of file -- cgit