Commit 74635609c76e6982adc412e7eb82fa7ba23cdf2f
1 parent
729b68db
Exists in
master
and in
1 other branch
- handle JSON exception
- show file and ref both in the test and review
Showing
7 changed files
with
31 additions
and
16 deletions
Show diff stats
BUGS.md
| 1 | 1 | ||
| 2 | # BUGS | 2 | # BUGS |
| 3 | 3 | ||
| 4 | -- retornar None quando nao ha alteracoes relativamente à última vez. | ||
| 5 | -ou usar push (websockets?) | ||
| 6 | -- quando scale_max não é 20, as cores das barras continuam a reflectir a escala 0,20 | 4 | +- review does not show question refs when commandline --show-ref is used but not the test.yaml option. |
| 5 | +- em admin, quando scale_max não é 20, as cores das barras continuam a reflectir a escala 0,20. a tabela teste na DB não tem a escala desse teste. | ||
| 7 | - CRITICAL se answer for `i<n` a revisão de provas mostra apenas i (interpreta `<` como tag?) | 6 | - CRITICAL se answer for `i<n` a revisão de provas mostra apenas i (interpreta `<` como tag?) |
| 8 | - na pagina grade.html as barras estao normalizadas para os limites scale_min e max do teste actual e nao do realizado. | 7 | - na pagina grade.html as barras estao normalizadas para os limites scale_min e max do teste actual e nao do realizado. |
| 9 | - codigo `hello world` nao esta a preservar o whitespace. O renderer de markdown gera a tag <code> que não preserva whitespace. Necessario adicionar <pre>. | 8 | - codigo `hello world` nao esta a preservar o whitespace. O renderer de markdown gera a tag <code> que não preserva whitespace. Necessario adicionar <pre>. |
| @@ -17,6 +16,8 @@ ou usar push (websockets?) | @@ -17,6 +16,8 @@ ou usar push (websockets?) | ||
| 17 | 16 | ||
| 18 | # TODO | 17 | # TODO |
| 19 | 18 | ||
| 19 | +- retornar None quando nao ha alteracoes relativamente à última vez. | ||
| 20 | +ou usar push (websockets?) | ||
| 20 | - mudar ref do test para test_id (ref já é usado nas perguntas) | 21 | - mudar ref do test para test_id (ref já é usado nas perguntas) |
| 21 | - servidor ntpd no x220 para configurar a data/hora dos portateis dell | 22 | - servidor ntpd no x220 para configurar a data/hora dos portateis dell |
| 22 | - autorização dada, mas teste não disponível até que seja dada ordem para começar. | 23 | - autorização dada, mas teste não disponível até que seja dada ordem para começar. |
demo/demo.yaml
| @@ -40,6 +40,9 @@ scale: [0, 5] | @@ -40,6 +40,9 @@ scale: [0, 5] | ||
| 40 | # scale_min: 0 | 40 | # scale_min: 0 |
| 41 | # scale_points: true | 41 | # scale_points: true |
| 42 | 42 | ||
| 43 | +show_ref: true | ||
| 44 | +debug: false | ||
| 45 | + | ||
| 43 | # ---------------------------------------------------------------------------- | 46 | # ---------------------------------------------------------------------------- |
| 44 | # Base path applied to the questions files and all the scripts | 47 | # Base path applied to the questions files and all the scripts |
| 45 | # including question generators and correctors. | 48 | # including question generators and correctors. |
perguntations/serve.py
| @@ -482,14 +482,18 @@ class ReviewHandler(BaseHandler): | @@ -482,14 +482,18 @@ class ReviewHandler(BaseHandler): | ||
| 482 | raise tornado.web.HTTPError(404) # Not Found | 482 | raise tornado.web.HTTPError(404) # Not Found |
| 483 | 483 | ||
| 484 | try: | 484 | try: |
| 485 | - jsonfile = open(path.expanduser(fname)) | ||
| 486 | - except OSError: | ||
| 487 | - logging.error(f'Cannot open "{fname}" for review.') | ||
| 488 | - else: | ||
| 489 | - with jsonfile: | 485 | + with open(path.expanduser(fname)) as jsonfile: |
| 490 | test = json.load(jsonfile) | 486 | test = json.load(jsonfile) |
| 491 | - self.render('review.html', t=test, md=md_to_html, | ||
| 492 | - templ=self._templates) | 487 | + except OSError: |
| 488 | + logging.error('Cannot open "%s" for review.', fname) | ||
| 489 | + raise tornado.web.HTTPError(404) # Not Found | ||
| 490 | + except json.JSONDecodeError as exc: | ||
| 491 | + logging.error('JSON error in "%s": %s', fname, exc) | ||
| 492 | + raise tornado.web.HTTPError(404) # Not Found | ||
| 493 | + | ||
| 494 | + print(test['show_ref']) | ||
| 495 | + self.render('review.html', t=test, md=md_to_html, | ||
| 496 | + templ=self._templates) | ||
| 493 | 497 | ||
| 494 | 498 | ||
| 495 | # ---------------------------------------------------------------------------- | 499 | # ---------------------------------------------------------------------------- |
perguntations/templates/question-information.html
| @@ -19,8 +19,7 @@ | @@ -19,8 +19,7 @@ | ||
| 19 | 19 | ||
| 20 | {% if show_ref %} | 20 | {% if show_ref %} |
| 21 | <hr> | 21 | <hr> |
| 22 | - path: <code>{{ q['path'] }}</code><br> | ||
| 23 | - file: <code>{{ q['filename'] }}</code><br> | 22 | + file: <code>{{ q['path'] }}/{{ q['filename'] }}</code><br> |
| 24 | ref: <code>{{ q['ref'] }}</code> | 23 | ref: <code>{{ q['ref'] }}</code> |
| 25 | {% end %} | 24 | {% end %} |
| 26 | </div> | 25 | </div> |
| 27 | \ No newline at end of file | 26 | \ No newline at end of file |
perguntations/templates/question.html
| @@ -31,8 +31,7 @@ | @@ -31,8 +31,7 @@ | ||
| 31 | 31 | ||
| 32 | {% if show_ref %} | 32 | {% if show_ref %} |
| 33 | <div class="card-footer"> | 33 | <div class="card-footer"> |
| 34 | - path: <code>{{ q['path'] }}</code><br> | ||
| 35 | - file: <code>{{ q['filename'] }}</code><br> | 34 | + file: <code>{{ q['path'] }}/{{ q['filename'] }}</code><br> |
| 36 | ref: <code>{{ q['ref'] }}</code> | 35 | ref: <code>{{ q['ref'] }}</code> |
| 37 | </div> | 36 | </div> |
| 38 | {% end %} | 37 | {% end %} |
perguntations/templates/review-question-information.html
| @@ -16,4 +16,9 @@ | @@ -16,4 +16,9 @@ | ||
| 16 | <div id="text"> | 16 | <div id="text"> |
| 17 | {{ md(q['text']) }} | 17 | {{ md(q['text']) }} |
| 18 | </div> | 18 | </div> |
| 19 | + {% if t['show_ref'] %} | ||
| 20 | + <hr> | ||
| 21 | + File: <code>{{ q['path'] }}/{{ q['filename'] }}</code>, | ||
| 22 | + Ref: <code>{{ q['ref'] }}</code> | ||
| 23 | + {% end %} | ||
| 19 | </div> | 24 | </div> |
| 20 | \ No newline at end of file | 25 | \ No newline at end of file |
perguntations/templates/review-question.html
| @@ -65,7 +65,9 @@ | @@ -65,7 +65,9 @@ | ||
| 65 | {% end %} | 65 | {% end %} |
| 66 | 66 | ||
| 67 | {% if t['show_ref'] %} | 67 | {% if t['show_ref'] %} |
| 68 | - <code>{{q['ref']}}</code> | 68 | + <hr> |
| 69 | + File: <code>{{ q['path'] }}/{{ q['filename'] }}</code>, | ||
| 70 | + Ref: <code>{{ q['ref'] }}</code> | ||
| 69 | {% end %} | 71 | {% end %} |
| 70 | 72 | ||
| 71 | </div> <!-- card-footer --> | 73 | </div> <!-- card-footer --> |
| @@ -107,7 +109,9 @@ | @@ -107,7 +109,9 @@ | ||
| 107 | </p> | 109 | </p> |
| 108 | 110 | ||
| 109 | {% if t['show_ref'] %} | 111 | {% if t['show_ref'] %} |
| 110 | - <code>{{ q['ref'] }}</code> | 112 | + <hr> |
| 113 | + File: <code>{{ q['path'] }}/{{ q['filename'] }}</code>, | ||
| 114 | + Ref: <code>{{ q['ref'] }}</code> | ||
| 111 | {% end %} | 115 | {% end %} |
| 112 | 116 | ||
| 113 | </div> <!-- card-footer --> | 117 | </div> <!-- card-footer --> |