Commit d6f778d36e70be479a7f22c8f94be6f3a862b1c9

Authored by Miguel Barão
1 parent 894bdd05
Exists in master and in 1 other branch dev

- cosmetic changes, cleanup

Showing 3 changed files with 17 additions and 46 deletions   Show diff stats
BUGS.md
1 1 BUGS:
2 2  
3   -- generators not working: bcrypt (ver blog)
4 3 - implementar xsrf. Ver [http://www.tornadoweb.org/en/stable/guide/security.html#cross-site-request-forgery-protection]()
  4 +
  5 +TODO:
  6 +
  7 +- gravar answers -> db
  8 +- como gerar uma sequencia de perguntas?
  9 +- generators not working: bcrypt (ver blog)
5 10 - implementar navegacao radio/checkbox. cursor cima/baixo, espaco selecciona, enter submete.
6 11  
7 12 SOLVED:
... ...
serve.py
... ... @@ -145,13 +145,13 @@ class QuestionHandler(BaseHandler):
145 145 md=md, # function that renders markdown to html
146 146 )
147 147 self.write({
148   - 'html': tornado.escape.to_unicode(html_out),
149   - 'correct': True,
  148 + 'params': tornado.escape.to_unicode(html_out),
  149 + 'method': 'new_question',
150 150 })
151 151 else:
152 152 self.write({
153   - 'html': 'None',
154   - 'correct': False
  153 + 'params': 'None',
  154 + 'method': 'shake'
155 155 })
156 156  
157 157  
... ...
templates/learn.html
... ... @@ -17,14 +17,11 @@
17 17  
18 18 <!-- Bootstrap -->
19 19 <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
20   - <!-- <link rel="stylesheet" href="/static/bootstrap/css/bootstrap-theme.min.css"> -->
21 20  
22 21 <!-- other -->
23 22 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
24 23 <link rel="stylesheet" href="/static/font-awesome/css/font-awesome.min.css">
25 24 <link rel="stylesheet" href="/static/css/github.css">
26   - <!-- <link rel="stylesheet" href="/static/css/sticky-footer-navbar.css"> -->
27   - <!-- <link rel="stylesheet" href="/static/css/test.css"> -->
28 25 <link rel="stylesheet" href="/static/css/learn.css">
29 26  
30 27 <script src="/static/js/jquery.min.js"></script>
... ... @@ -96,24 +93,11 @@ $.fn.extend({
96 93 }
97 94 });
98 95  
99   -// function getCookie(name) {
100   -// var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
101   -// return r ? r[1] : undefined;
102   -// }
103   -
104   -// jQuery.postJSON = function(url, args, callback) {
105   -// args._xsrf = getCookie("_xsrf");
106   -// alert(args);
107   -// $.ajax({url: url, data: $.param(args), dataType: "text", type: "POST",
108   -// success: function(response) {
109   -// callback(eval("(" + response + ")"));
110   -// }});
111   -// }
112   -
113 96 function updateQuestion(response){
114 97  
115   - if (response["correct"]) {
116   - $("#question_div").html(response["html"]);
  98 + switch (response["method"]) {
  99 + case "new_question":
  100 + $("#question_div").html(response["params"]);
117 101 MathJax.Hub.Queue(["Typeset",MathJax.Hub,"question_div"]);
118 102  
119 103 $("input:text").keypress(function (e) {
... ... @@ -129,32 +113,14 @@ function updateQuestion(response){
129 113 }
130 114 });
131 115 $('#question_div').animateCSS('pulse');
132   - }
133   - else
  116 + break;
  117 + case "shake":
134 118 $('#question_div').animateCSS('shake');
  119 + break;
  120 + }
135 121 }
136 122  
137 123 function getQuestion() {
138   - // var data = $("#question_form").serialize();
139   - // $.postJSON('/question', data, function(response){
140   - // $("#question_div").html(response["html"]);
141   - // MathJax.Hub.Queue(["Typeset",MathJax.Hub,"question"]);
142   -
143   - // if (response["correct"]) {
144   - // $('#question_div').animateCSS('pulse');
145   - // }
146   - // else {
147   - // $('#question_div').animateCSS('shake');
148   - // }
149   -
150   - // $("input:text").bind("keypress", function (e) {
151   - // if (e.keyCode == 13) {
152   - // e.preventDefault();
153   - // getQuestion();
154   - // }
155   - // });
156   - // });
157   -
158 124 $.ajax({
159 125 type: "POST",
160 126 url: "/question",
... ...