Commit 51627bccef59ef1fcbc82c2a49fdff4b4bdee2b5
1 parent
775dd8eb
Exists in
master
and in
1 other branch
- changed some looks and updated to fontawesome-5.6.1
- removed commeted code
Showing
5 changed files
with
27 additions
and
46 deletions
Show diff stats
static/fontawesome
static/js/topic.js
... | ... | @@ -41,8 +41,6 @@ function updateQuestion(response) { |
41 | 41 | |
42 | 42 | |
43 | 43 | function new_question(type, question, tries, progress) { |
44 | - console.log("new_question " + type); | |
45 | - | |
46 | 44 | $("#question_div").html(question); |
47 | 45 | $("#comments").html(""); |
48 | 46 | $("#solution").html(""); |
... | ... | @@ -62,27 +60,40 @@ function new_question(type, question, tries, progress) { |
62 | 60 | $('#question_div').animateCSS('bounceInDown'); |
63 | 61 | |
64 | 62 | // enable shift+enter to submit |
65 | - // $("input:text, input:radio, input:checkbox").keydown(function (e) { | |
66 | - // if (e.keyCode == 13) { | |
67 | - // e.preventDefault(); | |
68 | - // if (e.shiftKey) postQuestion(); | |
69 | - // return false; | |
70 | - // }}); | |
63 | + $("input:text, input:radio, input:checkbox").keydown(function (e) { | |
64 | + if (e.keyCode == 13) { | |
65 | + e.preventDefault(); | |
66 | + if (e.shiftKey) postQuestion(); | |
67 | + return false; | |
68 | + }}); | |
71 | 69 | } |
72 | 70 | |
71 | +// =========================================================================== | |
72 | +// Send answer and receive a response with the result of the correction. | |
73 | +// The response can be right, try_again or wrong. | |
74 | +// A new question is not loaded. To load questions a GET is required. | |
75 | +function postAnswer() { | |
76 | + if (typeof editor === 'object') | |
77 | + editor.save(); | |
73 | 78 | |
74 | -function getFeedback(response) { | |
75 | - console.log('updateQuestion '+response["method"]); | |
79 | + $.ajax({ | |
80 | + type: "POST", | |
81 | + url: "/question", | |
82 | + data: $("#question_form").serialize(), // {'a':10,'b':20}, | |
83 | + dataType: "json", // expected from server | |
84 | + success: getFeedback, | |
85 | + error: function() {alert("O servidor não responde.");} | |
86 | + }); | |
87 | +} | |
76 | 88 | |
89 | +function getFeedback(response) { | |
77 | 90 | var method = response["method"]; |
78 | 91 | var params = response["params"]; |
79 | 92 | |
80 | 93 | switch (method) { |
81 | 94 | case "right": |
82 | - console.log(params['comments']); | |
83 | 95 | $('#comments').html(params['comments']); |
84 | - | |
85 | - // MathJax.Hub.Queue(["Typeset", MathJax.Hub, "#comments"]); | |
96 | + MathJax.Hub.Queue(["Typeset", MathJax.Hub, "#comments"]); | |
86 | 97 | $("#submit").html("Continuar"); |
87 | 98 | $("#submit").off(); |
88 | 99 | $("#submit").click(getQuestion); |
... | ... | @@ -112,25 +123,6 @@ function getFeedback(response) { |
112 | 123 | } |
113 | 124 | } |
114 | 125 | |
115 | -// Send answer and receive a response. | |
116 | -// The response can be a new_question or a shake if the answer is wrong, which | |
117 | -// is then passed to updateQuestion() | |
118 | -function postAnswer() { | |
119 | - console.log("postAnswer"); | |
120 | - | |
121 | - if (typeof editor === 'object') | |
122 | - editor.save(); | |
123 | - | |
124 | - $.ajax({ | |
125 | - type: "POST", | |
126 | - url: "/question", | |
127 | - data: $("#question_form").serialize(), // {'a':10,'b':20}, | |
128 | - dataType: "json", // expected from server | |
129 | - success: getFeedback, | |
130 | - error: function() {alert("O servidor não responde.");} | |
131 | - }); | |
132 | -} | |
133 | - | |
134 | 126 | |
135 | 127 | $(document).ready(function() { |
136 | 128 | getQuestion(); | ... | ... |
templates/comments.html
templates/solution.html
tools.py
... | ... | @@ -102,17 +102,6 @@ class HighlightRenderer(mistune.Renderer): |
102 | 102 | def image(self, src, title, alt): |
103 | 103 | alt = mistune.escape(alt, quote=True) |
104 | 104 | title = mistune.escape(title or '', quote=True) |
105 | - # if title: | |
106 | - # caption = f'<figcaption class="figure-caption">{title}</figcaption>' | |
107 | - # else: | |
108 | - # caption = '' | |
109 | - | |
110 | - # return f''' | |
111 | - # <figure class="figure"> | |
112 | - # <img src="/file/{src}" class="figure-img img-fluid rounded" alt="{alt}" title="{title}"> | |
113 | - # {caption} | |
114 | - # </figure> | |
115 | - # ''' | |
116 | 105 | return f'<img src="/file/{src}" class="img-fluid mx-auto d-block" alt="{alt}" title="{title}">' |
117 | 106 | |
118 | 107 | # Pass math through unaltered - mathjax does the rendering in the browser | ... | ... |