Commit d6f778d36e70be479a7f22c8f94be6f3a862b1c9
1 parent
894bdd05
Exists in
master
and in
1 other branch
- cosmetic changes, cleanup
Showing
3 changed files
with
17 additions
and
46 deletions
Show diff stats
BUGS.md
1 | BUGS: | 1 | BUGS: |
2 | 2 | ||
3 | -- generators not working: bcrypt (ver blog) | ||
4 | - implementar xsrf. Ver [http://www.tornadoweb.org/en/stable/guide/security.html#cross-site-request-forgery-protection]() | 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 | - implementar navegacao radio/checkbox. cursor cima/baixo, espaco selecciona, enter submete. | 10 | - implementar navegacao radio/checkbox. cursor cima/baixo, espaco selecciona, enter submete. |
6 | 11 | ||
7 | SOLVED: | 12 | SOLVED: |
serve.py
@@ -145,13 +145,13 @@ class QuestionHandler(BaseHandler): | @@ -145,13 +145,13 @@ class QuestionHandler(BaseHandler): | ||
145 | md=md, # function that renders markdown to html | 145 | md=md, # function that renders markdown to html |
146 | ) | 146 | ) |
147 | self.write({ | 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 | else: | 151 | else: |
152 | self.write({ | 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,14 +17,11 @@ | ||
17 | 17 | ||
18 | <!-- Bootstrap --> | 18 | <!-- Bootstrap --> |
19 | <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css"> | 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 | <!-- other --> | 21 | <!-- other --> |
23 | <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css"> | 22 | <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css"> |
24 | <link rel="stylesheet" href="/static/font-awesome/css/font-awesome.min.css"> | 23 | <link rel="stylesheet" href="/static/font-awesome/css/font-awesome.min.css"> |
25 | <link rel="stylesheet" href="/static/css/github.css"> | 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 | <link rel="stylesheet" href="/static/css/learn.css"> | 25 | <link rel="stylesheet" href="/static/css/learn.css"> |
29 | 26 | ||
30 | <script src="/static/js/jquery.min.js"></script> | 27 | <script src="/static/js/jquery.min.js"></script> |
@@ -96,24 +93,11 @@ $.fn.extend({ | @@ -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 | function updateQuestion(response){ | 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 | MathJax.Hub.Queue(["Typeset",MathJax.Hub,"question_div"]); | 101 | MathJax.Hub.Queue(["Typeset",MathJax.Hub,"question_div"]); |
118 | 102 | ||
119 | $("input:text").keypress(function (e) { | 103 | $("input:text").keypress(function (e) { |
@@ -129,32 +113,14 @@ function updateQuestion(response){ | @@ -129,32 +113,14 @@ function updateQuestion(response){ | ||
129 | } | 113 | } |
130 | }); | 114 | }); |
131 | $('#question_div').animateCSS('pulse'); | 115 | $('#question_div').animateCSS('pulse'); |
132 | - } | ||
133 | - else | 116 | + break; |
117 | + case "shake": | ||
134 | $('#question_div').animateCSS('shake'); | 118 | $('#question_div').animateCSS('shake'); |
119 | + break; | ||
120 | + } | ||
135 | } | 121 | } |
136 | 122 | ||
137 | function getQuestion() { | 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 | $.ajax({ | 124 | $.ajax({ |
159 | type: "POST", | 125 | type: "POST", |
160 | url: "/question", | 126 | url: "/question", |