Commit 6b619adb33794a38a0419ab9879af539ad5ca93c

Authored by Miguel Barão
1 parent 8b4ac80a
Exists in master and in 1 other branch dev

- solution is always shown immediately.

- shift-enter submits
BUGS.md
1 1  
2 2 # BUGS
3 3  
  4 +- double click submits twice.
4 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 6 - obter rankings por curso GET course=course_id
7 7 - impedir que quando students.db não é encontrado, crie um ficheiro vazio.
8 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 48  
49 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 52 - menu nao mostra as opcoes correctamente
52 53 - finish topic vai para a lista de cursos. devia ficar no mesmo curso.
53 54 - mathjax nao esta a correr sobre o titulo.
... ...
aprendizations/static/js/topic.js
... ... @@ -9,27 +9,19 @@ $.fn.extend({
9 9 });
10 10  
11 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 22 // Get current question
30 23 function getQuestion() {
31 24 $("#submit").addClass("disabled");
32   -
33 25 $.ajax({
34 26 type: "GET",
35 27 url: "/question",
... ... @@ -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 35 function updateQuestion(response) {
45 36 var method = response["method"];
46 37 var params = response["params"];
47 38  
48 39 $("#right, #wrong").hide();
49   -
50 40 switch (method) {
51 41 case "new_question":
52 42 new_question(params["type"], params["question"], params["tries"], params["progress"]);
... ... @@ -60,12 +50,11 @@ function updateQuestion(response) {
60 50 }
61 51 }
62 52  
63   -
64 53 function new_question(type, question, tries, progress) {
65 54 window.scrollTo(0, 0);
66 55 $("#question_div").html(question).animateCSS('bounceInDown');
67 56 showTriesLeft(tries);
68   - $("#comments, #solution").html("");
  57 + $("#comments").html("").hide();
69 58 var btntext = (type == "information") ? "Continuar" : "Responder";
70 59 $("#submit").html(btntext).off().click(postAnswer);
71 60 $('#topic_progress').css('width', (100*progress)+'%').attr('aria-valuenow', 100*progress);
... ... @@ -75,24 +64,14 @@ function new_question(type, question, tries, progress) {
75 64 $(".list-group-item").click(function (e) {
76 65 var index = $(this).index();
77 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 75 return false;
97 76 }});
98 77 }
... ... @@ -127,43 +106,30 @@ function getFeedback(response) {
127 106  
128 107 switch (method) {
129 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 111 MathJax.typeset();
134   -
  112 + $('#wrong').hide();
  113 + $('#right').show().animateCSS('flipInX');
135 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 115 break;
144 116  
145 117 case "try_again":
  118 + $('#comments').html(params['comments']).show();
  119 + MathJax.typeset();
146 120 $('#question_div').animateCSS('shake');
147 121 $('#topic_progress').css('width', (100*params["progress"])+'%').attr('aria-valuenow', 100*params["progress"]);
148 122 showTriesLeft(params["tries"]);
149   - $('#comments').html(params['comments']);
150   - MathJax.typeset();
151 123 break;
152 124  
153 125 case "wrong":
  126 + $('#comments').html(params['comments']).show();
  127 + $('#solution_wrong').html(params['solution']);
  128 + MathJax.typeset();
154 129 $('#right').hide();
155   - $('#wrong').show();
  130 + $('#wrong').show().animateCSS('flipInX');
156 131 $('#topic_progress').css('width', (100*params["progress"])+'%').attr('aria-valuenow', 100*params["progress"]);
157 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 133 $("fieldset").attr("disabled", "disabled");
168 134 $("#submit").html("Continuar").off().click(getQuestion);
169 135 break;
... ...
aprendizations/templates/solution.html
... ... @@ -3,7 +3,6 @@
3 3 {% if solution %}
4 4 <div class="card">
5 5 <div class="card-body">
6   - <h4 class="alert-heading">Solução</h4>
7 6 {{ md(solution) }}
8 7 </div>
9 8 </div>
... ...
aprendizations/templates/topic.html
... ... @@ -92,30 +92,18 @@
92 92  
93 93 <div id="wrong" style="display: none">
94 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 97 </div>
103 98 </div>
104 99  
105 100 <div id="right" style="display: none">
106 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 104 </div>
115 105 </div>
116 106  
117   - <div id="solution"></div>
118   -
119 107 <!-- reponder / continuar -->
120 108 <a class="btn btn-primary btn-lg btn-block my-5" id="submit" data-toggle="tooltip" data-placement="right" href="#solution"></a>
121 109 <!-- title="Shift-Enter" -->
... ...