Commit d8f5228dece8a4001c33adb5f5d18e4a9969c08c

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

- fix command line error when no test is given

- remove lost print()
- fix answers not shown in review (escape html)
- fix duration in review
- cosmetic changes in review
demo/questions/questions-tutorial.yaml
... ... @@ -288,6 +288,8 @@
288 288 * `lower` e `upper` convertem respectivamente para minúsculas e maiúsculas.
289 289 transform: ['trim', 'lower']
290 290 correct: ['azul']
  291 + solution: |
  292 + O céu é `azul`, pelo menos durante o dia e se estiver bom tempo...
291 293  
292 294 # ---------------------------------------------------------------------------
293 295 - type: text-regex
... ... @@ -329,6 +331,8 @@
329 331 situações.
330 332  
331 333 correct: '(VERDE|[Vv]erde)'
  334 + solution: |
  335 + Deveria ter escrito `VERDE` ou `Verde` ou `verde`.
332 336  
333 337 # ---------------------------------------------------------------------------
334 338 - type: numeric-interval
... ...
perguntations/main.py
... ... @@ -31,7 +31,7 @@ def parse_cmdline_arguments():
31 31 'have to be previously configured. Please read the documentation '
32 32 'included with this software before running the server.')
33 33 parser.add_argument('testfile',
34   - type=str, nargs='?',
  34 + type=str,
35 35 help='tests in YAML format')
36 36 parser.add_argument('--allow-all',
37 37 action='store_true',
... ...
perguntations/serve.py
... ... @@ -492,7 +492,6 @@ class ReviewHandler(BaseHandler):
492 492 logging.error('JSON error in "%s": %s', fname, exc)
493 493 raise tornado.web.HTTPError(404) # Not Found
494 494  
495   - print(test['show_ref'])
496 495 self.render('review.html', t=test, md=md_to_html,
497 496 templ=self._templates)
498 497  
... ...
perguntations/templates/review-question-text.html
... ... @@ -5,7 +5,7 @@
5 5  
6 6 <div class="card bg-light">
7 7 <div class="card-body">
8   - <pre>{{ q['answer'] if q['answer'] is not None else '' }}</pre>
  8 + <pre>{{ escape(q['answer']) if q['answer'] is not None else '' }}</pre>
9 9 </div>
10 10 </div>
11 11  
... ...
perguntations/templates/review-question.html
... ... @@ -37,31 +37,31 @@
37 37 <p class="text-success">
38 38 <i class="far fa-thumbs-up fa-3x" aria-hidden="true"></i>
39 39 {{ round(q['grade'] * q['points'], 2) }}
40   - pontos<br>
41   - {{ q['comments'] }}
  40 + pontos
42 41 </p>
  42 + <p class="text-success">{{ q['comments'] }}</p>
43 43 {% elif q['grade'] > 0.49 %}
44 44 <p class="text-warning">
45 45 <i class="fas fa-exclamation-triangle fa-3x" aria-hidden="true"></i>
46 46 {{ round(q['grade'] * q['points'], 2) }}
47   - pontos<br>
48   - {{ q['comments'] }}
49   - {% if 'solution' in q %}
50   - <hr>
51   - {{ md('**Solução:** \n\n' + q['solution']) }}
52   - {% end %}
  47 + pontos
53 48 </p>
  49 + <p class="text-warning">{{ q['comments'] }}</p>
  50 + {% if q.get('solution', '') %}
  51 + <hr>
  52 + {{ md('**Solução:** \n\n' + q['solution']) }}
  53 + {% end %}
54 54 {% else %}
55 55 <p class="text-danger">
56 56 <i class="far fa-thumbs-down fa-3x" aria-hidden="true"></i>
57 57 {{ round(q['grade'] * q['points'], 2) }}
58   - pontos<br>
59   - {{ q['comments'] }}
60   - {% if 'solution' in q %}
61   - <hr>
62   - {{ md('**Solução:** \n\n' + q['solution']) }}
63   - {% end %}
  58 + pontos
64 59 </p>
  60 + <p class="text-danger">{{ q['comments'] }}</p>
  61 + {% if q.get('solution', '') %}
  62 + <hr>
  63 + {{ md('**Solução:** \n\n' + q['solution']) }}
  64 + {% end %}
65 65 {% end %}
66 66  
67 67 {% if t['show_ref'] %}
... ... @@ -84,7 +84,7 @@
84 84 </div>
85 85 </h5> <!-- card-header -->
86 86  
87   - <div class="card-body text-secondary">
  87 + <div class="card-body text-secondary bg-light">
88 88 <p id="text">
89 89 {{ md(q['text']) }}
90 90 </p>
... ... @@ -102,7 +102,7 @@
102 102 <i class="fas fa-ban fa-3x" aria-hidden="true"></i>
103 103 {{ round(q['grade'] * q['points'], 2) }} pontos<br>
104 104 {{ q['comments'] }}
105   - {% if 'solution' in q %}
  105 + {% if q.get('solution', '') %}
106 106 <hr>
107 107 {{ md('**Solução:** \n\n' + q['solution']) }}
108 108 {% end %}
... ...
perguntations/templates/review.html
... ... @@ -75,7 +75,9 @@
75 75 <h5>
76 76 <div class="row">
77 77 <label for="duracao" class="col-sm-2">Duração (minutos):</label>
78   - <div class="col-sm-10" id="duracao">{{ t.get('duration', chr(8734)) }}</div>
  78 + <div class="col-sm-10" id="duracao">
  79 + {{ t.get('duration', 0) if t.get('duration', 0) > 0 else '+'+chr(8734) }}
  80 + </div>
79 81 </div>
80 82 </h5>
81 83  
... ...