Commit 29c8b4cb9768214b7f0bb03a19bb72b9dc100bab
1 parent
68528695
Exists in
master
and in
1 other branch
- fixed FileHandler
- fixed enter-submit issue
Showing
4 changed files
with
12 additions
and
18 deletions
Show diff stats
BUGS.md
| 1 | 1 | ||
| 2 | BUGS: | 2 | BUGS: |
| 3 | 3 | ||
| 4 | -- enter faz GET /question, que responde com json no ecran | 4 | +- aumentar espaço a seguir às tabelas no texto |
| 5 | +- guardar state cada vez que topico termina | ||
| 5 | - tabs em textarea nao funcionam correctamente (insere 1 espaco em vez de 4) | 6 | - tabs em textarea nao funcionam correctamente (insere 1 espaco em vez de 4) |
| 6 | - reportar comentarios após submeter. | 7 | - reportar comentarios após submeter. |
| 7 | -- os topicos locked devem estar inactivos no sidebar. | ||
| 8 | - textarea deve mostrar no html os valores iniciais de ans, se existir | 8 | - textarea deve mostrar no html os valores iniciais de ans, se existir |
| 9 | - detect questions in questions.yaml without ref -> error ou generate default. | 9 | - detect questions in questions.yaml without ref -> error ou generate default. |
| 10 | - error if demo.yaml has no topics | 10 | - error if demo.yaml has no topics |
| 11 | -- guardar state cada vez que topico termina | ||
| 12 | - session management. close after inactive time. | 11 | - session management. close after inactive time. |
| 13 | - implementar xsrf. Ver [http://www.tornadoweb.org/en/stable/guide/security.html#cross-site-request-forgery-protection]() | 12 | - implementar xsrf. Ver [http://www.tornadoweb.org/en/stable/guide/security.html#cross-site-request-forgery-protection]() |
| 14 | - titulos das perguntas não suportam markdown | 13 | - titulos das perguntas não suportam markdown |
| 14 | +- generators not working: bcrypt (ver blog) | ||
| 15 | 15 | ||
| 16 | TODO: | 16 | TODO: |
| 17 | 17 | ||
| 18 | - pymips: activar/desactivar instruções | 18 | - pymips: activar/desactivar instruções |
| 19 | - implementar servidor http com redirect para https. | 19 | - implementar servidor http com redirect para https. |
| 20 | - usar codemirror no textarea | 20 | - usar codemirror no textarea |
| 21 | -- generators not working: bcrypt (ver blog) | ||
| 22 | 21 | ||
| 23 | FIXED: | 22 | FIXED: |
| 24 | 23 | ||
| 24 | +- os topicos locked devem estar inactivos no sidebar. | ||
| 25 | +- enter faz GET /question, que responde com json no ecran. (solution: disabled enter) | ||
| 25 | - topicos no sidebar devem ser links para iniciar um topico acessivel. | 26 | - topicos no sidebar devem ser links para iniciar um topico acessivel. |
| 26 | - logs inicio de topico | 27 | - logs inicio de topico |
| 27 | - indicar o topico actual no sidebar | 28 | - indicar o topico actual no sidebar |
knowledge.py
| @@ -88,12 +88,9 @@ class Knowledge(object): | @@ -88,12 +88,9 @@ class Knowledge(object): | ||
| 88 | # new question if answer is correct | 88 | # new question if answer is correct |
| 89 | if grade > 0.999: | 89 | if grade > 0.999: |
| 90 | self.finished_questions.append(q) | 90 | self.finished_questions.append(q) |
| 91 | - print('questions: ', self.questions) | ||
| 92 | - print('finished: ', self.finished_questions) | ||
| 93 | try: | 91 | try: |
| 94 | self.current_question = self.questions.pop(0) # FIXME empty? | 92 | self.current_question = self.questions.pop(0) # FIXME empty? |
| 95 | except IndexError: | 93 | except IndexError: |
| 96 | - print('no more questions!') | ||
| 97 | self.current_question = None | 94 | self.current_question = None |
| 98 | self.state[self.current_topic] = { | 95 | self.state[self.current_topic] = { |
| 99 | 'level': 1.0, | 96 | 'level': 1.0, |
| @@ -103,10 +100,8 @@ class Knowledge(object): | @@ -103,10 +100,8 @@ class Knowledge(object): | ||
| 103 | else: | 100 | else: |
| 104 | self.current_question['start_time'] = datetime.now() | 101 | self.current_question['start_time'] = datetime.now() |
| 105 | else: | 102 | else: |
| 106 | - # FIXME debug this | ||
| 107 | factory = self.depgraph.node[self.current_topic]['factory'] | 103 | factory = self.depgraph.node[self.current_topic]['factory'] |
| 108 | self.questions.append(factory[q['ref']].generate()) | 104 | self.questions.append(factory[q['ref']].generate()) |
| 109 | - print([q['ref'] for q in self.questions]) | ||
| 110 | 105 | ||
| 111 | return q | 106 | return q |
| 112 | 107 | ||
| @@ -135,11 +130,6 @@ class Knowledge(object): | @@ -135,11 +130,6 @@ class Knowledge(object): | ||
| 135 | if t in self.state: | 130 | if t in self.state: |
| 136 | ts.append((t, self.state[t]['level'])) # already done | 131 | ts.append((t, self.state[t]['level'])) # already done |
| 137 | else: | 132 | else: |
| 138 | - # deps = self.depgraph.predecessors(t) | ||
| 139 | - # # print(t, deps) | ||
| 140 | - # if all(d in self.state for d in deps): | ||
| 141 | - # ts.append((t, 0.0)) # unlocked not yet done | ||
| 142 | - # else: | ||
| 143 | ts.append((t, None)) # locked | 133 | ts.append((t, None)) # locked |
| 144 | return ts | 134 | return ts |
| 145 | 135 |
serve.py
| @@ -134,11 +134,14 @@ class FileHandler(BaseHandler): | @@ -134,11 +134,14 @@ class FileHandler(BaseHandler): | ||
| 134 | def get(self, filename): | 134 | def get(self, filename): |
| 135 | uid = self.current_user | 135 | uid = self.current_user |
| 136 | public_dir = self.learn.get_current_public_dir(uid) | 136 | public_dir = self.learn.get_current_public_dir(uid) |
| 137 | + filepath = os.path.expanduser(os.path.join(public_dir, filename)) | ||
| 137 | try: | 138 | try: |
| 138 | - with open(os.path.join(public_dir, filename), 'rb') as f: | ||
| 139 | - self.write(f.read()) | 139 | + f = open(filepath, 'rb') |
| 140 | except FileNotFoundError: | 140 | except FileNotFoundError: |
| 141 | raise tornado.web.HTTPError(404) | 141 | raise tornado.web.HTTPError(404) |
| 142 | + else: | ||
| 143 | + self.write(f.read()) | ||
| 144 | + f.close() | ||
| 142 | 145 | ||
| 143 | # ---------------------------------------------------------------------------- | 146 | # ---------------------------------------------------------------------------- |
| 144 | # respond to AJAX to get a JSON question | 147 | # respond to AJAX to get a JSON question |
templates/learn.html
| @@ -165,9 +165,9 @@ function updateQuestion(response){ | @@ -165,9 +165,9 @@ function updateQuestion(response){ | ||
| 165 | 165 | ||
| 166 | // enable shift+enter to submit and tab to spaces conversion | 166 | // enable shift+enter to submit and tab to spaces conversion |
| 167 | $("input:text, input:radio, input:checkbox").keydown(function (e) { | 167 | $("input:text, input:radio, input:checkbox").keydown(function (e) { |
| 168 | - if (e.keyCode == 13 && e.shiftKey) { | 168 | + if (e.keyCode == 13) { |
| 169 | e.preventDefault(); | 169 | e.preventDefault(); |
| 170 | - postQuestion(); | 170 | + if (e.shiftKey) postQuestion(); |
| 171 | return false; | 171 | return false; |
| 172 | } | 172 | } |
| 173 | }); | 173 | }); |