Commit c649cb416f021196e20e241854d3e2e2032417e0

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

- 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
aprendizations/learnapp.py
@@ -376,12 +376,7 @@ class LearnApp(object): @@ -376,12 +376,7 @@ class LearnApp(object):
376 for tref, attr in topics.items(): 376 for tref, attr in topics.items():
377 logger.debug(f' + {tref}') 377 logger.debug(f' + {tref}')
378 for d in attr.get('deps', []): 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 t = g.nodes[tref] # get current topic node 381 t = g.nodes[tref] # get current topic node
387 t['name'] = attr.get('name', tref) 382 t['name'] = attr.get('name', tref)
@@ -409,14 +404,20 @@ class LearnApp(object): @@ -409,14 +404,20 @@ class LearnApp(object):
409 404
410 # load questions as list of dicts 405 # load questions as list of dicts
411 topicpath: str = path.join(g.graph['prefix'], tref) 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 logger.debug(f' Loading {fullpath}') 414 logger.debug(f' Loading {fullpath}')
415 - # questions: List[QDict] = load_yaml(fullpath, default=[])  
416 try: 415 try:
417 questions: List[QDict] = load_yaml(fullpath) 416 questions: List[QDict] = load_yaml(fullpath)
418 except Exception: 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 if not isinstance(questions, list): 422 if not isinstance(questions, list):
422 msg = f'File "{fullpath}" must be a list of questions' 423 msg = f'File "{fullpath}" must be a list of questions'
aprendizations/static/mathjax
@@ -1 +0,0 @@ @@ -1 +0,0 @@
1 -../../node_modules/mathjax/  
2 \ No newline at end of file 0 \ No newline at end of file
aprendizations/templates/courses.html
@@ -58,7 +58,6 @@ @@ -58,7 +58,6 @@
58 {% for k,v in courses.items() %} 58 {% for k,v in courses.items() %}
59 <div class="card-deck col-md-4"> 59 <div class="card-deck col-md-4">
60 <a href="/course/{{k}}" class="card mb-3"> 60 <a href="/course/{{k}}" class="card mb-3">
61 - <!-- text-dark mb-3" style="width: 18rem;" -->  
62 <div class="card-body"> 61 <div class="card-body">
63 <h6 class="card-title">{{ v['title'] }}</h6> 62 <h6 class="card-title">{{ v['title'] }}</h6>
64 <p class="card-text">{{ v.get('description', '') }}</p> 63 <p class="card-text">{{ v.get('description', '') }}</p>
@@ -72,7 +71,7 @@ @@ -72,7 +71,7 @@
72 <footer class="footer"> 71 <footer class="footer">
73 <div class="container"> 72 <div class="container">
74 <small class="text-muted"> 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 &nbsp;/&nbsp; 75 &nbsp;/&nbsp;
77 <a href="mailto:mjsb@uevora.pt?subject=Sugestões">Enviar sugestões</a> 76 <a href="mailto:mjsb@uevora.pt?subject=Sugestões">Enviar sugestões</a>
78 </small> 77 </small>
@@ -106,4 +105,4 @@ @@ -106,4 +105,4 @@
106 </div><!-- /.modal --> 105 </div><!-- /.modal -->
107 </body> 106 </body>
108 107
109 -</html>  
110 \ No newline at end of file 108 \ No newline at end of file
  109 +</html>
aprendizations/templates/maintopics-table.html
@@ -96,6 +96,9 @@ @@ -96,6 +96,9 @@
96 <div class="lead"> 96 <div class="lead">
97 {{ t['name'] }} 97 {{ t['name'] }}
98 </div> 98 </div>
  99 + {% elif t['type']=='learn' %}
  100 + <i class="fas fa-book"></i>&nbsp;
  101 + {{ t['name'] }}
99 {% else %} 102 {% else %}
100 <i class="fas fa-pencil-alt"></i>&nbsp; 103 <i class="fas fa-pencil-alt"></i>&nbsp;
101 {{ t['name'] }} 104 {{ t['name'] }}
@@ -111,8 +114,8 @@ @@ -111,8 +114,8 @@
111 </div> 114 </div>
112 {% else %} 115 {% else %}
113 <div class="text-xs-right"> 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 </span> 119 </span>
117 </div> 120 </div>
118 {% end %} 121 {% end %}