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 | # BUGS | 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 | - usar thread.Lock para aceder a variaveis de estado? | 9 | - usar thread.Lock para aceder a variaveis de estado? |
5 | 10 | ||
6 | # TODO | 11 | # TODO |
app.py
@@ -129,7 +129,7 @@ class App(object): | @@ -129,7 +129,7 @@ class App(object): | ||
129 | t.update_answers(ans) | 129 | t.update_answers(ans) |
130 | grade = t.correct() | 130 | grade = t.correct() |
131 | 131 | ||
132 | - # save JSON with the test | 132 | + # save test in JSON format |
133 | fname = ' -- '.join((t['student']['number'], t['ref'], str(t['finish_time']))) + '.json' | 133 | fname = ' -- '.join((t['student']['number'], t['ref'], str(t['finish_time']))) + '.json' |
134 | fpath = path.abspath(path.join(t['answers_dir'], fname)) | 134 | fpath = path.abspath(path.join(t['answers_dir'], fname)) |
135 | t.save_json(fpath) | 135 | t.save_json(fpath) |
demo/questions/questions.yaml
@@ -145,13 +145,13 @@ | @@ -145,13 +145,13 @@ | ||
145 | 145 | ||
146 | ### Tabelas | 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,7 +373,10 @@ class QuestionTextRegex(Question): | ||
373 | def correct(self): | 373 | def correct(self): |
374 | super().correct() | 374 | super().correct() |
375 | if self['answer'] is not None: | 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 | return self['grade'] | 381 | return self['grade'] |
379 | 382 |
serve.py
@@ -10,7 +10,7 @@ import json | @@ -10,7 +10,7 @@ import json | ||
10 | 10 | ||
11 | try: | 11 | try: |
12 | import cherrypy | 12 | import cherrypy |
13 | - from cherrypy.lib import auth_digest | 13 | + # from cherrypy.lib import auth_digest |
14 | from mako.lookup import TemplateLookup | 14 | from mako.lookup import TemplateLookup |
15 | except ImportError: | 15 | except ImportError: |
16 | print('Some python packages are missing. See README.md for instructions.') | 16 | print('Some python packages are missing. See README.md for instructions.') |
@@ -260,7 +260,6 @@ class Root(object): | @@ -260,7 +260,6 @@ class Root(object): | ||
260 | # --- ADMIN -------------------------------------------------------------- | 260 | # --- ADMIN -------------------------------------------------------------- |
261 | @cherrypy.expose | 261 | @cherrypy.expose |
262 | @require(name_is('0')) | 262 | @require(name_is('0')) |
263 | - # def admin(self, **reset_pw): | ||
264 | def admin(self): | 263 | def admin(self): |
265 | return self.template['admin'].render() | 264 | return self.template['admin'].render() |
266 | 265 |
test.py
@@ -21,7 +21,7 @@ import questions | @@ -21,7 +21,7 @@ import questions | ||
21 | from tools import load_yaml | 21 | from tools import load_yaml |
22 | 22 | ||
23 | # =========================================================================== | 23 | # =========================================================================== |
24 | -class TestFactoryException(Exception): # FIXME unused | 24 | +class TestFactoryException(Exception): |
25 | pass | 25 | pass |
26 | 26 | ||
27 | # =========================================================================== | 27 | # =========================================================================== |
@@ -135,6 +135,7 @@ class TestFactory(dict): | @@ -135,6 +135,7 @@ class TestFactory(dict): | ||
135 | # ----------------------------------------------------------------------- | 135 | # ----------------------------------------------------------------------- |
136 | def normalize_questions(self): | 136 | def normalize_questions(self): |
137 | 137 | ||
138 | + # print(self['questions']) | ||
138 | for i, q in enumerate(self['questions']): | 139 | for i, q in enumerate(self['questions']): |
139 | # normalize question to a dict and ref to a list of references | 140 | # normalize question to a dict and ref to a list of references |
140 | if isinstance(q, str): | 141 | if isinstance(q, str): |
@@ -143,6 +144,7 @@ class TestFactory(dict): | @@ -143,6 +144,7 @@ class TestFactory(dict): | ||
143 | q['ref'] = [q['ref']] | 144 | q['ref'] = [q['ref']] |
144 | 145 | ||
145 | self['questions'][i] = q | 146 | self['questions'][i] = q |
147 | + # print(self['questions']) | ||
146 | 148 | ||
147 | # ----------------------------------------------------------------------- | 149 | # ----------------------------------------------------------------------- |
148 | # Given a dictionary with a student id {'name':'john', 'number': 123} | 150 | # Given a dictionary with a student id {'name':'john', 'number': 123} |
@@ -174,7 +176,7 @@ class TestFactory(dict): | @@ -174,7 +176,7 @@ class TestFactory(dict): | ||
174 | 'answers_dir': self['answers_dir'], | 176 | 'answers_dir': self['answers_dir'], |
175 | 177 | ||
176 | # FIXME which ones are required? | 178 | # FIXME which ones are required? |
177 | - 'practice': self['practice'], # FIXME remove? | 179 | + # 'practice': self['practice'], # FIXME remove? |
178 | 'show_hints': self['show_hints'], | 180 | 'show_hints': self['show_hints'], |
179 | 'show_points': self['show_points'], | 181 | 'show_points': self['show_points'], |
180 | 'show_ref': self['show_ref'], | 182 | 'show_ref': self['show_ref'], |