summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authoradityacp2018-04-06 15:01:47 +0530
committeradityacp2018-04-06 15:01:47 +0530
commitc9aeb7b7e1484229782f0f8ab397890b27cfc905 (patch)
tree2274f38792505eb9b2e2a8a75ce1acb2aa614bf1 /yaksh
parent463cd907d0e744d5bbbd5ed5f0d0dde1bd8ca162 (diff)
downloadonline_test-c9aeb7b7e1484229782f0f8ab397890b27cfc905.tar.gz
online_test-c9aeb7b7e1484229782f0f8ab397890b27cfc905.tar.bz2
online_test-c9aeb7b7e1484229782f0f8ab397890b27cfc905.zip
Highlight error line in code mirror for python
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/static/yaksh/js/requesthandler.js19
-rw-r--r--yaksh/templates/yaksh/error_template.html2
-rw-r--r--yaksh/templates/yaksh/question.html8
3 files changed, 26 insertions, 3 deletions
diff --git a/yaksh/static/yaksh/js/requesthandler.js b/yaksh/static/yaksh/js/requesthandler.js
index a215ce4..f858317 100644
--- a/yaksh/static/yaksh/js/requesthandler.js
+++ b/yaksh/static/yaksh/js/requesthandler.js
@@ -75,6 +75,22 @@ function response_handler(method_type, content_type, data, uid){
var error_output = document.getElementById("error_panel");
error_output.innerHTML = res.error;
focus_on_error(error_output);
+ err_lineno = $("#err_lineno").val();
+ if(marker){
+ marker.clear();
+ }
+ if(err_lineno){
+ var lineno = parseInt(err_lineno) - 1;
+ var editor = global_editor.editor;
+ var line_length = editor.getLine(lineno).length;
+ marker = editor.markText({line: lineno, ch: 0}, {line: lineno, ch: line_length},
+ {className: "activeline", clearOnEnter:true});
+ }
+ else{
+ if(marker){
+ marker.clear();
+ }
+ }
}
} else {
reset_values();
@@ -125,6 +141,8 @@ function ajax_check_code(url, method_type, data_type, data, uid)
var global_editor = {};
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
+var err_lineno;
+var marker;
$(document).ready(function(){
if(is_exercise == "True" && can_skip == "False"){
setTimeout(function() {show_solution();}, delay_time*1000);
@@ -148,6 +166,7 @@ $(document).ready(function(){
mode: mode_dict[lang],
gutter: true,
lineNumbers: true,
+ styleSelectedText: true,
onChange: function (instance, changes) {
render();
}
diff --git a/yaksh/templates/yaksh/error_template.html b/yaksh/templates/yaksh/error_template.html
index 61657ae..301020e 100644
--- a/yaksh/templates/yaksh/error_template.html
+++ b/yaksh/templates/yaksh/error_template.html
@@ -3,7 +3,6 @@
{% endblock %}
{% load custom_filters %}
-
{% if error_message %}
{% for error in error_message %}
@@ -35,6 +34,7 @@
</tr>
<tr>
{% if error.traceback %}
+ <input type="hidden" id="err_lineno" value="{{error.line_no}}">
<td><b>Full Traceback: </b></td>
<td><pre>{{error.traceback}}</pre></td>
{% endif %}
diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html
index b65073a..ebfe066 100644
--- a/yaksh/templates/yaksh/question.html
+++ b/yaksh/templates/yaksh/question.html
@@ -11,6 +11,10 @@
.CodeMirror{
border-style: groove;
}
+ .activeline {
+ background: #FBC2C4 !important;
+ color: #8a1f11 !important;
+ }
</style>
{% endblock %}
@@ -221,7 +225,7 @@ question_type = "{{ question.type }}"
{% if question.type == "integer" %}
Enter Integer:<br/>
- <input autofocus name="answer" type="number" id="integer" value={{ last_attempt|safe }} />
+ <input autofocus name="answer" type="number" id="integer" value="{{ last_attempt|safe }}" />
<br/><br/>
{% endif %}
@@ -233,7 +237,7 @@ question_type = "{{ question.type }}"
{% if question.type == "float" %}
Enter Decimal Value :<br/>
- <input autofocus name="answer" type="number" step="any" id="float" value={{ last_attempt|safe }} />
+ <input autofocus name="answer" type="number" step="any" id="float" value="{{ last_attempt|safe }}" />
<br/><br/>
{% endif %}