diff --git a/BUGS.md b/BUGS.md index 8f26622..056236e 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,6 +1,7 @@ # BUGS +- botao para mostrar a solução quando se acerta. - shift-enter não está a funcionar - falha intermitent no file handler quando o browser envia 2 GET requests ao mesmo tempo (porquê?) - nos topicos learn.yaml, qd falha acrescenta no fim. nao faz sentido. diff --git a/serve.py b/serve.py index 55eaece..3a063a8 100755 --- a/serve.py +++ b/serve.py @@ -276,11 +276,14 @@ class QuestionHandler(BaseHandler): if action == 'right': # get next question in the topic comments_html = self.render_string('comments-right.html', comments=q['comments'], md=md_to_html) + solution_html = to_unicode(self.render_string('solution.html', + solution=q['solution'], md=md_to_html)) response['params'] = { 'type': q['type'], 'progress': self.learn.get_student_progress(user), 'comments': to_unicode(comments_html), + 'solution': solution_html, 'tries': q['tries'], } @@ -289,11 +292,11 @@ class QuestionHandler(BaseHandler): comments=q['comments'], md=md_to_html) response['params'] = { - 'type': q['type'], - 'progress': self.learn.get_student_progress(user), - 'comments': to_unicode(comments_html), - 'tries': q['tries'], - } + 'type': q['type'], + 'progress': self.learn.get_student_progress(user), + 'comments': to_unicode(comments_html), + 'tries': q['tries'], + } elif action == 'wrong': # no more tries comments_html = to_unicode(self.render_string('comments.html', diff --git a/static/js/topic.js b/static/js/topic.js index fd4e280..08d2ae9 100644 --- a/static/js/topic.js +++ b/static/js/topic.js @@ -24,8 +24,7 @@ function updateQuestion(response) { var method = response["method"]; var params = response["params"]; - $('#right').hide(); - $('#wrong').hide(); + $('#right, #wrong').hide(); switch (method) { case "new_question": @@ -44,8 +43,7 @@ function updateQuestion(response) { function new_question(type, question, tries, progress) { $("#question_div").html(question); - $("#comments").html(""); - $("#solution").html(""); + $("#comments, #solution").html(""); if (type == "info") { $("#submit").html("Continuar"); } @@ -55,7 +53,6 @@ function new_question(type, question, tries, progress) { $("#submit").off(); $("#submit").click(postAnswer); $("#tries").html(tries); - $('#topic_progress').css('width', (100*progress)+'%').attr('aria-valuenow', 100*progress); MathJax.Hub.Queue(["Typeset",MathJax.Hub,"question_div"]); @@ -72,6 +69,7 @@ function new_question(type, question, tries, progress) { // }}); } + // =========================================================================== // Send answer and receive a response with the result of the correction. // The response can be right, try_again or wrong. @@ -108,6 +106,12 @@ function getFeedback(response) { $("#submit").html("Continuar"); $("#submit").off(); $("#submit").click(getQuestion); + $("#link_solution_on_right").click(function(){ + $("#right").hide(); + $('#solution').html(params['solution']); + MathJax.Hub.Queue(["Typeset", MathJax.Hub, "#solution"]); + $('#solution').animateCSS('flipInX'); + }); break; case "try_again": @@ -121,14 +125,16 @@ function getFeedback(response) { case "wrong": $('#right').hide(); $('#wrong').show(); - // $('#question_div').animateCSS('shake'); $('#topic_progress').css('width', (100*params["progress"])+'%').attr('aria-valuenow', 100*params["progress"]); $("#tries").html(params["tries"]); $('#comments').html(params['comments']); MathJax.Hub.Queue(["Typeset", MathJax.Hub, "#comments"]); - $('#solution').html(params['solution']); - MathJax.Hub.Queue(["Typeset", MathJax.Hub, "#solution"]); - $('#solution').animateCSS('flipInX'); + $("#link_solution_on_wrong").click(function () { + $("#wrong").hide(); + $('#solution').html(params['solution']); + MathJax.Hub.Queue(["Typeset", MathJax.Hub, "#solution"]); + $('#solution').animateCSS('flipInX'); + }); $("fieldset").attr("disabled", "disabled"); $("#submit").html("Continuar"); $("#submit").off(); diff --git a/templates/solution.html b/templates/solution.html index 0704732..c8b1a71 100644 --- a/templates/solution.html +++ b/templates/solution.html @@ -1,8 +1,10 @@ {% autoescape %} {% if solution %} -
+
+

Solução

{{ md(solution) }} +
{% end %} diff --git a/templates/topic.html b/templates/topic.html index a1aa357..981de2e 100644 --- a/templates/topic.html +++ b/templates/topic.html @@ -76,46 +76,43 @@
- - - -
-
- {% module xsrf_form_html() %} -
-
- -
-
+
+
+ {% module xsrf_form_html() %} +
+
+ +
+
- - - - -