Commit b2e894fec100244af6fa4a7bc45836285b5bdb60
1 parent
678b6b01
Exists in
master
and in
1 other branch
- small code cleanup
Showing
6 changed files
with
21 additions
and
12 deletions
Show diff stats
BUGS.md
| 1 | 1 | |
| 2 | 2 | # BUGS |
| 3 | 3 | |
| 4 | +- se um teste tiver a mesma pergunta (ref igual) varias vezes, rebenta na correcçao. As respostas são agregadas numa lista para cada ref. Ex: | |
| 5 | + {'ref1': 'resposta1', 'ref2': ['resposta2a', 'resposta2b']} | |
| 6 | +possivelmente as referencias das perguntas deveriam ser o "testeRef:numPergunta"... é preciso ver como depois estao associadas às correcções. | |
| 7 | +- se ocorrer um erro na correcçao avisar aluno para contactar o professor. | |
| 8 | +- se directorio logs não existir no directorio actual (não perguntations) rebenta. | |
| 4 | 9 | - usar thread.Lock para aceder a variaveis de estado? |
| 5 | 10 | |
| 6 | 11 | # TODO | ... | ... |
app.py
| ... | ... | @@ -129,7 +129,7 @@ class App(object): |
| 129 | 129 | t.update_answers(ans) |
| 130 | 130 | grade = t.correct() |
| 131 | 131 | |
| 132 | - # save JSON with the test | |
| 132 | + # save test in JSON format | |
| 133 | 133 | fname = ' -- '.join((t['student']['number'], t['ref'], str(t['finish_time']))) + '.json' |
| 134 | 134 | fpath = path.abspath(path.join(t['answers_dir'], fname)) |
| 135 | 135 | t.save_json(fpath) | ... | ... |
demo/questions/questions.yaml
| ... | ... | @@ -145,13 +145,13 @@ |
| 145 | 145 | |
| 146 | 146 | ### Tabelas |
| 147 | 147 | |
| 148 | - ~~Não são perfeitas~~, é uma limitação do markdown. | |
| 148 | + Não têm um espaçamento perfeito, é uma limitação do markdown. | |
| 149 | 149 | |
| 150 | - Left | Center | Right | |
| 151 | - ------------|:-------------:|-----: | |
| 152 | - A | *hello* | $1600.00 | |
| 153 | - B | **world** | $12.50 | |
| 154 | - C | `code` | $1.99 | |
| 150 | + Left | Center | Right | |
| 151 | + -----------------|:-------------:|----------: | |
| 152 | + $\sin(x^2)$ | *hello* | $1600.00 | |
| 153 | + $\frac{1}{2\pi}$ | **world** | $12.50 | |
| 154 | + $\sqrt{\pi}$ | `code` | $1.99 | |
| 155 | 155 | |
| 156 | 156 | --- |
| 157 | 157 | ... | ... |
questions.py
| ... | ... | @@ -373,7 +373,10 @@ class QuestionTextRegex(Question): |
| 373 | 373 | def correct(self): |
| 374 | 374 | super().correct() |
| 375 | 375 | if self['answer'] is not None: |
| 376 | - self['grade'] = 1.0 if re.match(self['correct'], self['answer']) else 0.0 | |
| 376 | + try: | |
| 377 | + self['grade'] = 1.0 if re.match(self['correct'], self['answer']) else 0.0 | |
| 378 | + except TypeError: | |
| 379 | + logger.error('While matching regex {0} with answer {1}.'.format(self['correct'], self['answer'])) | |
| 377 | 380 | |
| 378 | 381 | return self['grade'] |
| 379 | 382 | ... | ... |
serve.py
| ... | ... | @@ -10,7 +10,7 @@ import json |
| 10 | 10 | |
| 11 | 11 | try: |
| 12 | 12 | import cherrypy |
| 13 | - from cherrypy.lib import auth_digest | |
| 13 | + # from cherrypy.lib import auth_digest | |
| 14 | 14 | from mako.lookup import TemplateLookup |
| 15 | 15 | except ImportError: |
| 16 | 16 | print('Some python packages are missing. See README.md for instructions.') |
| ... | ... | @@ -260,7 +260,6 @@ class Root(object): |
| 260 | 260 | # --- ADMIN -------------------------------------------------------------- |
| 261 | 261 | @cherrypy.expose |
| 262 | 262 | @require(name_is('0')) |
| 263 | - # def admin(self, **reset_pw): | |
| 264 | 263 | def admin(self): |
| 265 | 264 | return self.template['admin'].render() |
| 266 | 265 | ... | ... |
test.py
| ... | ... | @@ -21,7 +21,7 @@ import questions |
| 21 | 21 | from tools import load_yaml |
| 22 | 22 | |
| 23 | 23 | # =========================================================================== |
| 24 | -class TestFactoryException(Exception): # FIXME unused | |
| 24 | +class TestFactoryException(Exception): | |
| 25 | 25 | pass |
| 26 | 26 | |
| 27 | 27 | # =========================================================================== |
| ... | ... | @@ -135,6 +135,7 @@ class TestFactory(dict): |
| 135 | 135 | # ----------------------------------------------------------------------- |
| 136 | 136 | def normalize_questions(self): |
| 137 | 137 | |
| 138 | + # print(self['questions']) | |
| 138 | 139 | for i, q in enumerate(self['questions']): |
| 139 | 140 | # normalize question to a dict and ref to a list of references |
| 140 | 141 | if isinstance(q, str): |
| ... | ... | @@ -143,6 +144,7 @@ class TestFactory(dict): |
| 143 | 144 | q['ref'] = [q['ref']] |
| 144 | 145 | |
| 145 | 146 | self['questions'][i] = q |
| 147 | + # print(self['questions']) | |
| 146 | 148 | |
| 147 | 149 | # ----------------------------------------------------------------------- |
| 148 | 150 | # Given a dictionary with a student id {'name':'john', 'number': 123} |
| ... | ... | @@ -174,7 +176,7 @@ class TestFactory(dict): |
| 174 | 176 | 'answers_dir': self['answers_dir'], |
| 175 | 177 | |
| 176 | 178 | # FIXME which ones are required? |
| 177 | - 'practice': self['practice'], # FIXME remove? | |
| 179 | + # 'practice': self['practice'], # FIXME remove? | |
| 178 | 180 | 'show_hints': self['show_hints'], |
| 179 | 181 | 'show_points': self['show_points'], |
| 180 | 182 | 'show_ref': self['show_ref'], | ... | ... |