Commit c649cb416f021196e20e241854d3e2e2032417e0
1 parent
dde5be86
Exists in
master
and in
1 other branch
- fix error where dependencies could fail to load with critical error
- show book icons for topics of type "learn" - remove mathjax symbolic links - add sticky footer with link to submit bug reports and suggestions
Showing
4 changed files
with
17 additions
and
15 deletions
Show diff stats
aprendizations/learnapp.py
... | ... | @@ -376,12 +376,7 @@ class LearnApp(object): |
376 | 376 | for tref, attr in topics.items(): |
377 | 377 | logger.debug(f' + {tref}') |
378 | 378 | for d in attr.get('deps', []): |
379 | - if d not in g.nodes(): | |
380 | - logger.error(f'Topic "{tref}" depends on "{d}" but it ' | |
381 | - f'does not exist') | |
382 | - raise LearnException() | |
383 | - else: | |
384 | - g.add_edge(d, tref) | |
379 | + g.add_edge(d, tref) | |
385 | 380 | |
386 | 381 | t = g.nodes[tref] # get current topic node |
387 | 382 | t['name'] = attr.get('name', tref) |
... | ... | @@ -409,14 +404,20 @@ class LearnApp(object): |
409 | 404 | |
410 | 405 | # load questions as list of dicts |
411 | 406 | topicpath: str = path.join(g.graph['prefix'], tref) |
412 | - fullpath: str = path.join(topicpath, t['file']) | |
407 | + try: | |
408 | + fullpath: str = path.join(topicpath, t['file']) | |
409 | + except Exception: | |
410 | + msg1 = f'Invalid topic "{tref}"' | |
411 | + msg2 = f'Check dependencies of {", ".join(g.successors(tref))}' | |
412 | + raise LearnException(f'{msg1}. {msg2}') | |
413 | 413 | |
414 | 414 | logger.debug(f' Loading {fullpath}') |
415 | - # questions: List[QDict] = load_yaml(fullpath, default=[]) | |
416 | 415 | try: |
417 | 416 | questions: List[QDict] = load_yaml(fullpath) |
418 | 417 | except Exception: |
419 | - raise LearnException(f'Failed to load "{fullpath}"') | |
418 | + msg = f'Failed to load "{fullpath}"' | |
419 | + logger.error(msg) | |
420 | + raise LearnException(msg) | |
420 | 421 | |
421 | 422 | if not isinstance(questions, list): |
422 | 423 | msg = f'File "{fullpath}" must be a list of questions' | ... | ... |
aprendizations/static/mathjax
aprendizations/templates/courses.html
... | ... | @@ -58,7 +58,6 @@ |
58 | 58 | {% for k,v in courses.items() %} |
59 | 59 | <div class="card-deck col-md-4"> |
60 | 60 | <a href="/course/{{k}}" class="card mb-3"> |
61 | - <!-- text-dark mb-3" style="width: 18rem;" --> | |
62 | 61 | <div class="card-body"> |
63 | 62 | <h6 class="card-title">{{ v['title'] }}</h6> |
64 | 63 | <p class="card-text">{{ v.get('description', '') }}</p> |
... | ... | @@ -72,7 +71,7 @@ |
72 | 71 | <footer class="footer"> |
73 | 72 | <div class="container"> |
74 | 73 | <small class="text-muted"> |
75 | - <a href="mailto:mjsb@uevora.pt?subject=Encontrei um erro&body=Descreva detalhadamente a situação na qual encontrou o erro. Indique qual o curso, tópico e pergunta. No caso de problemas técnicos indique também qual o seu sistema operativo e browser.">Reportar erro</a> | |
74 | + <a href="mailto:mjsb@uevora.pt?subject=Encontrei um erro&body=Descreva detalhadamente a situação na qual encontrou o erro. Indique qual o curso, tópico e pergunta. No caso de problemas técnicos indique também qual o seu sistema operativo e browser.">Reportar erros</a> | |
76 | 75 | / |
77 | 76 | <a href="mailto:mjsb@uevora.pt?subject=Sugestões">Enviar sugestões</a> |
78 | 77 | </small> |
... | ... | @@ -106,4 +105,4 @@ |
106 | 105 | </div><!-- /.modal --> |
107 | 106 | </body> |
108 | 107 | |
109 | -</html> | |
110 | 108 | \ No newline at end of file |
109 | +</html> | ... | ... |
aprendizations/templates/maintopics-table.html
... | ... | @@ -96,6 +96,9 @@ |
96 | 96 | <div class="lead"> |
97 | 97 | {{ t['name'] }} |
98 | 98 | </div> |
99 | + {% elif t['type']=='learn' %} | |
100 | + <i class="fas fa-book"></i> | |
101 | + {{ t['name'] }} | |
99 | 102 | {% else %} |
100 | 103 | <i class="fas fa-pencil-alt"></i> |
101 | 104 | {{ t['name'] }} |
... | ... | @@ -111,8 +114,8 @@ |
111 | 114 | </div> |
112 | 115 | {% else %} |
113 | 116 | <div class="text-xs-right"> |
114 | - <span class="text-nowrap"> | |
115 | - {{ round(t['level']*5)*'<i class="fas fa-star text-warning"></i>' + (5-round(t['level']*5))*'<i class="far fa-star text-warning"></i>' }} | |
117 | + <span class="text-nowrap text-warning" data-toggle="tooltip" data-placement="bottom" title="{{round(t['level']*5, 2)}}"> | |
118 | + {{int(t['level']*5+0.25)*'<i class="fas fa-star"></i>'}}{% if int(t['level']*5+0.25) < 5 %}{{'<i class="fas fa-star-half-alt"></i>' if 0.25 <= t['level']*5-int(t['level']*5) < 0.75 else '<i class="far fa-star"></i>'}}{% end %}{{(4-int(t['level']*5+0.25))*'<i class="far fa-star"></i>' }} | |
116 | 119 | </span> |
117 | 120 | </div> |
118 | 121 | {% end %} | ... | ... |