diff options
author | prathamesh | 2017-08-14 12:10:42 +0530 |
---|---|---|
committer | prathamesh | 2017-08-14 12:10:42 +0530 |
commit | ce995e06e3509a1340061c51dfa08a65c69eef66 (patch) | |
tree | d270ccf9792bd2dbbc833e2f08aee4b407356cb9 /yaksh/templates | |
parent | 1a6006b457a68e6db51315a83a97ec0d9eb631d4 (diff) | |
download | online_test-ce995e06e3509a1340061c51dfa08a65c69eef66.tar.gz online_test-ce995e06e3509a1340061c51dfa08a65c69eef66.tar.bz2 online_test-ce995e06e3509a1340061c51dfa08a65c69eef66.zip |
Front-end modification for improved code server
Added JQuery to handle request.
Sends ajax request and gets json as response.
json contains token i.e uid which is answer id.
Using uid, an ajax request is sent after every 2 secs till the server
gives the desire result.
If the code result has error then html is written on the document.
If the result has correct answer then next question is displayed.
*includes function for string will not work for older browers.
Will substitute with a different function in next commit.
Diffstat (limited to 'yaksh/templates')
-rw-r--r-- | yaksh/templates/yaksh/question.html | 51 |
1 files changed, 6 insertions, 45 deletions
diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index ee33523..9df2fef 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -15,7 +15,7 @@ {% endblock %} {% block script %} -<script src="{{ URL_ROOT }}/static/yaksh/js/question.js"></script> +<script src="{{ URL_ROOT }}/static/yaksh/js/requesthandler.js"></script> <script src="{{ URL_ROOT }}/static/yaksh/js/codemirror/lib/codemirror.js"></script> <script src="{{ URL_ROOT }}/static/yaksh/js/codemirror/mode/python/python.js"></script> <script src="{{ URL_ROOT }}/static/yaksh/js/codemirror/mode/clike/clike.js"></script> @@ -79,7 +79,7 @@ function validate(){ } else { - return true; + send_request(); } } @@ -89,47 +89,8 @@ function call_skip(url) form.action = url form.submit(); } -</script> -<script> - - var init_val = '{{ last_attempt|escape_quotes|safe }}'; - var global_editor = {}; - $(document).ready(function(){ - // Codemirror object, language modes and initial content - // Get the textarea node - var textarea_node = document.querySelector('#answer'); - - var lang = "{{ question.language }}" - var mode_dict = { - 'python': 'python', - 'c': 'text/x-csrc', - 'cpp': 'text/x-c++src', - 'java': 'text/x-java', - 'bash': 'text/x-sh', - 'scilab': 'text/x-csrc' - } - - // Code mirror Options - var options = { - mode: mode_dict[lang], - gutter: true, - lineNumbers: true, - onChange: function (instance, changes) { - render(); - } - }; - - // Initialize the codemirror editor - global_editor.editor = CodeMirror.fromTextArea(textarea_node, options); - - // Setting code editors initial content - global_editor.editor.setValue(init_val); - - function reset_editor() { - global_editor.editor.setValue(init_val); - global_editor.editor.clearHistory(); - } - }); +init_val = '{{ last_attempt|escape_quotes|safe }}'; +lang = "{{ question.language }}" </script> {% endblock script %} @@ -239,13 +200,13 @@ function call_skip(url) <div class="from-group"> {% if question.type == "mcq" or "mcc" or "integer" or "float" or "string" %} - <br><button class="btn btn-primary" type="submit" name="check" id="check">Submit Answer</button> <br/> + <br><button class="btn btn-primary" type="submit" name="check" id="check" >Submit Answer</button> <br/> {% elif question.type == "upload" %} <br><button class="btn btn-primary" type="submit" name="check" id="check" onClick="return validate();">Upload</button> {% else %} {% if question in paper.get_questions_unanswered %} - <button class="btn btn-primary" type="submit" name="check" id="check" onClick="submitCode();">Check Answer <span class="glyphicon glyphicon-cog"></span></button> + <button class="btn btn-primary" type="submit" name="check" id="check" >Check Answer <span class="glyphicon glyphicon-cog"></span></button> {% endif %} {% endif %} |