diff --git a/static/fontawesome b/static/fontawesome index bc71d51..92d1012 120000 --- a/static/fontawesome +++ b/static/fontawesome @@ -1 +1 @@ -libs/fontawesome-free-5.5.0-web/ \ No newline at end of file +libs/fontawesome-free-5.6.1-web/ \ No newline at end of file diff --git a/static/js/topic.js b/static/js/topic.js index 126e802..4a5a51e 100644 --- a/static/js/topic.js +++ b/static/js/topic.js @@ -41,8 +41,6 @@ function updateQuestion(response) { function new_question(type, question, tries, progress) { - console.log("new_question " + type); - $("#question_div").html(question); $("#comments").html(""); $("#solution").html(""); @@ -62,27 +60,40 @@ function new_question(type, question, tries, progress) { $('#question_div').animateCSS('bounceInDown'); // enable shift+enter to submit - // $("input:text, input:radio, input:checkbox").keydown(function (e) { - // if (e.keyCode == 13) { - // e.preventDefault(); - // if (e.shiftKey) postQuestion(); - // return false; - // }}); + $("input:text, input:radio, input:checkbox").keydown(function (e) { + if (e.keyCode == 13) { + e.preventDefault(); + if (e.shiftKey) postQuestion(); + return false; + }}); } +// =========================================================================== +// Send answer and receive a response with the result of the correction. +// The response can be right, try_again or wrong. +// A new question is not loaded. To load questions a GET is required. +function postAnswer() { + if (typeof editor === 'object') + editor.save(); -function getFeedback(response) { - console.log('updateQuestion '+response["method"]); + $.ajax({ + type: "POST", + url: "/question", + data: $("#question_form").serialize(), // {'a':10,'b':20}, + dataType: "json", // expected from server + success: getFeedback, + error: function() {alert("O servidor não responde.");} + }); +} +function getFeedback(response) { var method = response["method"]; var params = response["params"]; switch (method) { case "right": - console.log(params['comments']); $('#comments').html(params['comments']); - - // MathJax.Hub.Queue(["Typeset", MathJax.Hub, "#comments"]); + MathJax.Hub.Queue(["Typeset", MathJax.Hub, "#comments"]); $("#submit").html("Continuar"); $("#submit").off(); $("#submit").click(getQuestion); @@ -112,25 +123,6 @@ function getFeedback(response) { } } -// Send answer and receive a response. -// The response can be a new_question or a shake if the answer is wrong, which -// is then passed to updateQuestion() -function postAnswer() { - console.log("postAnswer"); - - if (typeof editor === 'object') - editor.save(); - - $.ajax({ - type: "POST", - url: "/question", - data: $("#question_form").serialize(), // {'a':10,'b':20}, - dataType: "json", // expected from server - success: getFeedback, - error: function() {alert("O servidor não responde.");} - }); -} - $(document).ready(function() { getQuestion(); diff --git a/templates/comments.html b/templates/comments.html index 75c0984..c8279bf 100644 --- a/templates/comments.html +++ b/templates/comments.html @@ -1,7 +1,7 @@ {% autoescape %} {% if comments %} -