Commit 6b619adb33794a38a0419ab9879af539ad5ca93c
1 parent
8b4ac80a
Exists in
master
and in
1 other branch
- solution is always shown immediately.
- shift-enter submits
Showing
4 changed files
with
32 additions
and
78 deletions
Show diff stats
BUGS.md
1 | 1 | ||
2 | # BUGS | 2 | # BUGS |
3 | 3 | ||
4 | +- double click submits twice. | ||
4 | - nao esta a seguir o max_tries definido no ficheiro de dependencias. | 5 | - nao esta a seguir o max_tries definido no ficheiro de dependencias. |
5 | -- no curso de linear algebra, as perguntas estao shuffled, mas nao deviam estar... nao esta a obedecer a keyword shuffle. | ||
6 | - obter rankings por curso GET course=course_id | 6 | - obter rankings por curso GET course=course_id |
7 | - impedir que quando students.db não é encontrado, crie um ficheiro vazio. | 7 | - impedir que quando students.db não é encontrado, crie um ficheiro vazio. |
8 | - classificacoes so devia mostrar os que ja fizeram alguma coisa | 8 | - classificacoes so devia mostrar os que ja fizeram alguma coisa |
@@ -48,6 +48,7 @@ sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in | @@ -48,6 +48,7 @@ sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in | ||
48 | 48 | ||
49 | # FIXED | 49 | # FIXED |
50 | 50 | ||
51 | +- no curso de linear algebra, as perguntas estao shuffled, mas nao deviam estar... nao esta a obedecer a keyword shuffle. | ||
51 | - menu nao mostra as opcoes correctamente | 52 | - menu nao mostra as opcoes correctamente |
52 | - finish topic vai para a lista de cursos. devia ficar no mesmo curso. | 53 | - finish topic vai para a lista de cursos. devia ficar no mesmo curso. |
53 | - mathjax nao esta a correr sobre o titulo. | 54 | - mathjax nao esta a correr sobre o titulo. |
aprendizations/static/js/topic.js
@@ -9,27 +9,19 @@ $.fn.extend({ | @@ -9,27 +9,19 @@ $.fn.extend({ | ||
9 | }); | 9 | }); |
10 | 10 | ||
11 | function showTriesLeft(tries) { | 11 | function showTriesLeft(tries) { |
12 | - var tries_msg; | ||
13 | - | ||
14 | - switch (tries) { | ||
15 | - case 0: | ||
16 | - tries_msg = ""; | ||
17 | - break; | ||
18 | - case 1: | ||
19 | - tries_msg = "(1 tentativa)"; | ||
20 | - break; | ||
21 | - default: | ||
22 | - tries_msg = "(" + tries + " tentativas)"; | ||
23 | - } | ||
24 | - | ||
25 | - $("#tries").html(tries_msg); | 12 | + var msg; |
13 | + if (tries > 1) | ||
14 | + msg = "(" + tries + " tentativas)"; | ||
15 | + else if (tries == 1) | ||
16 | + msg = "(1 tentativa)"; | ||
17 | + else | ||
18 | + msg = ""; | ||
19 | + $("#tries").html(msg); | ||
26 | } | 20 | } |
27 | 21 | ||
28 | - | ||
29 | // Get current question | 22 | // Get current question |
30 | function getQuestion() { | 23 | function getQuestion() { |
31 | $("#submit").addClass("disabled"); | 24 | $("#submit").addClass("disabled"); |
32 | - | ||
33 | $.ajax({ | 25 | $.ajax({ |
34 | type: "GET", | 26 | type: "GET", |
35 | url: "/question", | 27 | url: "/question", |
@@ -39,14 +31,12 @@ function getQuestion() { | @@ -39,14 +31,12 @@ function getQuestion() { | ||
39 | }); | 31 | }); |
40 | } | 32 | } |
41 | 33 | ||
42 | - | ||
43 | -// updates question according to the response given by the server | 34 | +// updates question in the page according to the response given by the server |
44 | function updateQuestion(response) { | 35 | function updateQuestion(response) { |
45 | var method = response["method"]; | 36 | var method = response["method"]; |
46 | var params = response["params"]; | 37 | var params = response["params"]; |
47 | 38 | ||
48 | $("#right, #wrong").hide(); | 39 | $("#right, #wrong").hide(); |
49 | - | ||
50 | switch (method) { | 40 | switch (method) { |
51 | case "new_question": | 41 | case "new_question": |
52 | new_question(params["type"], params["question"], params["tries"], params["progress"]); | 42 | new_question(params["type"], params["question"], params["tries"], params["progress"]); |
@@ -60,12 +50,11 @@ function updateQuestion(response) { | @@ -60,12 +50,11 @@ function updateQuestion(response) { | ||
60 | } | 50 | } |
61 | } | 51 | } |
62 | 52 | ||
63 | - | ||
64 | function new_question(type, question, tries, progress) { | 53 | function new_question(type, question, tries, progress) { |
65 | window.scrollTo(0, 0); | 54 | window.scrollTo(0, 0); |
66 | $("#question_div").html(question).animateCSS('bounceInDown'); | 55 | $("#question_div").html(question).animateCSS('bounceInDown'); |
67 | showTriesLeft(tries); | 56 | showTriesLeft(tries); |
68 | - $("#comments, #solution").html(""); | 57 | + $("#comments").html("").hide(); |
69 | var btntext = (type == "information") ? "Continuar" : "Responder"; | 58 | var btntext = (type == "information") ? "Continuar" : "Responder"; |
70 | $("#submit").html(btntext).off().click(postAnswer); | 59 | $("#submit").html(btntext).off().click(postAnswer); |
71 | $('#topic_progress').css('width', (100*progress)+'%').attr('aria-valuenow', 100*progress); | 60 | $('#topic_progress').css('width', (100*progress)+'%').attr('aria-valuenow', 100*progress); |
@@ -75,24 +64,14 @@ function new_question(type, question, tries, progress) { | @@ -75,24 +64,14 @@ function new_question(type, question, tries, progress) { | ||
75 | $(".list-group-item").click(function (e) { | 64 | $(".list-group-item").click(function (e) { |
76 | var index = $(this).index(); | 65 | var index = $(this).index(); |
77 | $("div.list-group input:radio").eq(index).prop("checked", true); | 66 | $("div.list-group input:radio").eq(index).prop("checked", true); |
78 | - | ||
79 | - // $('a.list-group-item-primary').removeClass('list-group-item-primary'); | ||
80 | - // $(this).addClass('list-group-item-primary'); | ||
81 | }); | 67 | }); |
82 | } | 68 | } |
83 | - // else if (type == "checkbox") { | ||
84 | - // $(".list-group-item").click(function () { | ||
85 | - // $("input:checkbox", this).trigger("click"); | ||
86 | - // }); | ||
87 | - // } | ||
88 | - | ||
89 | - // enable shift+enter to submit | ||
90 | - $("input:text, input:radio, input:checkbox").keydown(function (e) { | ||
91 | - if (e.keyCode == 13) { | ||
92 | - e.preventDefault(); | ||
93 | - // if (e.shiftKey) { | ||
94 | - // $("#submit").click(); | ||
95 | - // } | 69 | + |
70 | + // prevent enter submit. | ||
71 | + //input:text, input:radio, input:checkbox | ||
72 | + $("body").keyup(function (e) { | ||
73 | + if (e.keyCode == 13 && e.shiftKey) { | ||
74 | + $("#submit").click(); | ||
96 | return false; | 75 | return false; |
97 | }}); | 76 | }}); |
98 | } | 77 | } |
@@ -127,43 +106,30 @@ function getFeedback(response) { | @@ -127,43 +106,30 @@ function getFeedback(response) { | ||
127 | 106 | ||
128 | switch (method) { | 107 | switch (method) { |
129 | case "right": | 108 | case "right": |
130 | - $('#right').show(); | ||
131 | - $('#wrong').hide(); | ||
132 | - $('#comments').html(params['comments']); | 109 | + $('#comments').html(params['comments']).show(); |
110 | + $('#solution_right').html(params['solution']); | ||
133 | MathJax.typeset(); | 111 | MathJax.typeset(); |
134 | - | 112 | + $('#wrong').hide(); |
113 | + $('#right').show().animateCSS('flipInX'); | ||
135 | $("#submit").html("Continuar").off().click(getQuestion); | 114 | $("#submit").html("Continuar").off().click(getQuestion); |
136 | - $("#link_solution_on_right").click(function(){ | ||
137 | - $("#right").hide(); | ||
138 | - $('#solution').html(params['solution']).animateCSS('flipInX'); | ||
139 | - // MathJax.Hub.Queue(["Typeset", MathJax.Hub, "#solution"]); | ||
140 | - MathJax.typeset(); | ||
141 | - | ||
142 | - }); | ||
143 | break; | 115 | break; |
144 | 116 | ||
145 | case "try_again": | 117 | case "try_again": |
118 | + $('#comments').html(params['comments']).show(); | ||
119 | + MathJax.typeset(); | ||
146 | $('#question_div').animateCSS('shake'); | 120 | $('#question_div').animateCSS('shake'); |
147 | $('#topic_progress').css('width', (100*params["progress"])+'%').attr('aria-valuenow', 100*params["progress"]); | 121 | $('#topic_progress').css('width', (100*params["progress"])+'%').attr('aria-valuenow', 100*params["progress"]); |
148 | showTriesLeft(params["tries"]); | 122 | showTriesLeft(params["tries"]); |
149 | - $('#comments').html(params['comments']); | ||
150 | - MathJax.typeset(); | ||
151 | break; | 123 | break; |
152 | 124 | ||
153 | case "wrong": | 125 | case "wrong": |
126 | + $('#comments').html(params['comments']).show(); | ||
127 | + $('#solution_wrong').html(params['solution']); | ||
128 | + MathJax.typeset(); | ||
154 | $('#right').hide(); | 129 | $('#right').hide(); |
155 | - $('#wrong').show(); | 130 | + $('#wrong').show().animateCSS('flipInX'); |
156 | $('#topic_progress').css('width', (100*params["progress"])+'%').attr('aria-valuenow', 100*params["progress"]); | 131 | $('#topic_progress').css('width', (100*params["progress"])+'%').attr('aria-valuenow', 100*params["progress"]); |
157 | showTriesLeft(params["tries"]); | 132 | showTriesLeft(params["tries"]); |
158 | - $('#comments').html(params['comments']); | ||
159 | - // MathJax.typeset(); | ||
160 | - MathJax.typeset(); | ||
161 | - $("#link_solution_on_wrong").click(function () { | ||
162 | - $("#wrong").hide(); | ||
163 | - $('#solution').html(params['solution']).animateCSS('flipInX'); | ||
164 | - // MathJax.Hub.Queue(["Typeset", MathJax.Hub, "#solution"]); | ||
165 | - MathJax.typeset(); | ||
166 | - }); | ||
167 | $("fieldset").attr("disabled", "disabled"); | 133 | $("fieldset").attr("disabled", "disabled"); |
168 | $("#submit").html("Continuar").off().click(getQuestion); | 134 | $("#submit").html("Continuar").off().click(getQuestion); |
169 | break; | 135 | break; |
aprendizations/templates/solution.html
aprendizations/templates/topic.html
@@ -92,30 +92,18 @@ | @@ -92,30 +92,18 @@ | ||
92 | 92 | ||
93 | <div id="wrong" style="display: none"> | 93 | <div id="wrong" style="display: none"> |
94 | <div class="alert alert-danger"> | 94 | <div class="alert alert-danger"> |
95 | - <i class="fas fa-thumbs-down fa-3x"></i> | ||
96 | - <br><br> | ||
97 | - Desta vez não acertou, mas também se aprende com os erros... | ||
98 | - <br> | ||
99 | - <div id="show_solution_on_right"> | ||
100 | - <a href="#solution" id="link_solution_on_wrong">Ver solução</a> | ||
101 | - </div> | 95 | + <h4><i class="fas fa-thumbs-down fa-3x"></i> Não acertou, mas também se aprende com os erros...</h4> |
96 | + <div id="solution_wrong"></div> | ||
102 | </div> | 97 | </div> |
103 | </div> | 98 | </div> |
104 | 99 | ||
105 | <div id="right" style="display: none"> | 100 | <div id="right" style="display: none"> |
106 | <div class="alert alert-success"> | 101 | <div class="alert alert-success"> |
107 | - <i class="fas fa-thumbs-up fa-3x"></i> | ||
108 | - <br><br> | ||
109 | - Excelente resposta! | ||
110 | - <br> | ||
111 | - <div id="show_solution_on_right"> | ||
112 | - <a href="#solution" id="link_solution_on_right">Ver solução</a> | ||
113 | - </div> | 102 | + <h4><i class="fas fa-thumbs-up fa-3x"></i> Muito bem!</h4> |
103 | + <div id="solution_right"></div> | ||
114 | </div> | 104 | </div> |
115 | </div> | 105 | </div> |
116 | 106 | ||
117 | - <div id="solution"></div> | ||
118 | - | ||
119 | <!-- reponder / continuar --> | 107 | <!-- reponder / continuar --> |
120 | <a class="btn btn-primary btn-lg btn-block my-5" id="submit" data-toggle="tooltip" data-placement="right" href="#solution"></a> | 108 | <a class="btn btn-primary btn-lg btn-block my-5" id="submit" data-toggle="tooltip" data-placement="right" href="#solution"></a> |
121 | <!-- title="Shift-Enter" --> | 109 | <!-- title="Shift-Enter" --> |