Commit 62e18fdcd3a42c90c072168794f3c3970abf570b
1 parent
bfdba5e3
Exists in
master
and in
1 other branch
- fixed password change notification
Showing
4 changed files
with
17 additions
and
18 deletions
Show diff stats
BUGS.md
1 | 1 | |
2 | 2 | # BUGS |
3 | 3 | |
4 | +- generators e correct scripts que durem muito tempo podem bloquear o loop do tornado? | |
4 | 5 | - detect questions in questions.yaml without ref -> error ou generate default. |
5 | 6 | - topicos virtuais nao deveriam aparecer. na construção da árvore os sucessores seriam ligados directamente aos predecessores. |
6 | 7 | - Criar outra estrutura organizada em capítulos (conjuntos de tópicos). Permitir capítulos de capítulos, etc. talvez usar grafos de grafos... |
... | ... | @@ -11,7 +12,6 @@ |
11 | 12 | |
12 | 13 | # TODO |
13 | 14 | |
14 | -- update de fontawesome para versão 5. | |
15 | 15 | - reportar comentarios após submeter. |
16 | 16 | - each topic only loads a sample of K questions (max) in random order. |
17 | 17 | - servir imagens/ficheiros. |
... | ... | @@ -31,6 +31,7 @@ |
31 | 31 | |
32 | 32 | # FIXED |
33 | 33 | |
34 | +- update de fontawesome para versão 5.0.6. | |
34 | 35 | - remover learn.css uma vez que nao é usado em lado nenhum? |
35 | 36 | - check if user already logged in |
36 | 37 | - mover javascript para ficheiros externos e carregar com script defer src | ... | ... |
learnapp.py
... | ... | @@ -267,9 +267,11 @@ class LearnApp(object): |
267 | 267 | # g.node['my/topic']['name'] name of the topic |
268 | 268 | # g.node['my/topic']['questions'] list of question refs defined in YAML |
269 | 269 | # g.node['my/topic']['factory'] dict with question factories |
270 | +# | |
271 | +# Edges are obtained from the deps defined in the YAML file for each topic. | |
270 | 272 | # ---------------------------------------------------------------------------- |
271 | 273 | def build_dependency_graph(config={}): |
272 | - logger.info('Building topic dependency graph.') | |
274 | + logger.info('Building graph and loading questions:') | |
273 | 275 | |
274 | 276 | # create graph |
275 | 277 | prefix = config.get('path', '.') |
... | ... | @@ -281,18 +283,15 @@ def build_dependency_graph(config={}): |
281 | 283 | topics = config.get('topics', {}) |
282 | 284 | for ref,attr in topics.items(): |
283 | 285 | g.add_node(ref) |
286 | + tnode = g.node[ref] # current node (topic) | |
287 | + | |
284 | 288 | if isinstance(attr, dict): |
285 | - g.node[ref]['name'] = attr.get('name', ref) | |
286 | - g.node[ref]['questions'] = attr.get('questions', []) | |
289 | + tnode['name'] = attr.get('name', ref) | |
290 | + tnode['questions'] = attr.get('questions', []) | |
287 | 291 | g.add_edges_from((d,ref) for d in attr.get('deps', [])) |
288 | 292 | |
289 | - # iterate over topics and create question factories | |
290 | - logger.info('Loading:') | |
291 | - for tref in g.nodes(): | |
292 | - tnode = g.node[tref] # current node (topic) | |
293 | - fullpath = path.expanduser(path.join(prefix, tref)) | |
293 | + fullpath = path.expanduser(path.join(prefix, ref)) | |
294 | 294 | filename = path.join(fullpath, 'questions.yaml') |
295 | - | |
296 | 295 | loaded_questions = load_yaml(filename, default=[]) # list |
297 | 296 | |
298 | 297 | # if questions not in configuration then load all, preserving order |
... | ... | @@ -303,9 +302,9 @@ def build_dependency_graph(config={}): |
303 | 302 | tnode['factory'] = {} |
304 | 303 | for q in loaded_questions: |
305 | 304 | if q['ref'] in tnode['questions']: |
306 | - q['path'] = fullpath | |
305 | + q['path'] = fullpath # fullpath added to each question | |
307 | 306 | tnode['factory'][q['ref']] = QFactory(q) |
308 | 307 | |
309 | - logger.info(f'{len(tnode["questions"]):6} from {tref}') | |
308 | + logger.info(f'{len(tnode["questions"]):6} from {ref}') | |
310 | 309 | |
311 | 310 | return g | ... | ... |
static/js/maintopics.js
1 | 1 | function notify(msg) { |
2 | 2 | $("#notifications").html(msg); |
3 | - $("#notifications").fadeIn(250).delay(5000).fadeOut(500); | |
3 | + $("#notifications").fadeIn(250).delay(3000).fadeOut(500); | |
4 | 4 | } |
5 | 5 | |
6 | 6 | function getCookie(name) { |
... | ... | @@ -9,6 +9,8 @@ function getCookie(name) { |
9 | 9 | } |
10 | 10 | |
11 | 11 | function change_password() { |
12 | + // alert('hello'); | |
13 | + // notify('hello!'); | |
12 | 14 | var token = getCookie('_xsrf'); |
13 | 15 | $.ajax({ |
14 | 16 | type: "POST", | ... | ... |
templates/notification.html
1 | - | |
2 | -<div class="alert alert-{{ type }} alert-dismissible" role="alert" id="notification" style="position:absolute; | |
3 | - top: 0px; right: 1em;"> | |
4 | - <!-- <i class="fa fa-check" aria-hidden="true"></i> --> | |
5 | - <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | |
1 | +<div class="alert alert-{{ type }} alert-dismissible" role="alert" id="notification"> | |
2 | + <i class="fas fa-key" aria-hidden="true"></i> | |
6 | 3 | {{ msg }} |
7 | 4 | </div> | ... | ... |