Commit b7e0bce364b14f78fb80586db25939fab52726e5
1 parent
b5a62c5c
Exists in
master
and in
1 other branch
- fixed mathjax link
Showing
2 changed files
with
7 additions
and
5 deletions
Show diff stats
questions.py
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | # | 8 | # |
| 9 | # # read question from file | 9 | # # read question from file |
| 10 | # qdict = tools.load_yaml(filename) | 10 | # qdict = tools.load_yaml(filename) |
| 11 | -# qfactory = QFactory(question) | 11 | +# qfactory = QFactory(qdict) |
| 12 | # question = qfactory.generate() | 12 | # question = qfactory.generate() |
| 13 | # | 13 | # |
| 14 | # # experiment answering one question and correct it | 14 | # # experiment answering one question and correct it |
| @@ -102,7 +102,7 @@ class QuestionRadio(Question): | @@ -102,7 +102,7 @@ class QuestionRadio(Question): | ||
| 102 | # set defaults if missing | 102 | # set defaults if missing |
| 103 | self.set_defaults({ | 103 | self.set_defaults({ |
| 104 | 'text': '', | 104 | 'text': '', |
| 105 | - 'correct': 0, | 105 | + 'correct': 0.0, |
| 106 | 'shuffle': True, | 106 | 'shuffle': True, |
| 107 | 'discount': True, | 107 | 'discount': True, |
| 108 | }) | 108 | }) |
| @@ -234,6 +234,7 @@ class QuestionText(Question): | @@ -234,6 +234,7 @@ class QuestionText(Question): | ||
| 234 | super().correct(answer) | 234 | super().correct(answer) |
| 235 | 235 | ||
| 236 | if self['answer']: | 236 | if self['answer']: |
| 237 | + # FIXME in self['answer'][0] why [0]??? | ||
| 237 | self['grade'] = 1.0 if self['answer'][0] in self['correct'] else 0.0 | 238 | self['grade'] = 1.0 if self['answer'][0] in self['correct'] else 0.0 |
| 238 | 239 | ||
| 239 | return self['grade'] | 240 | return self['grade'] |
| @@ -263,6 +264,7 @@ class QuestionTextRegex(Question): | @@ -263,6 +264,7 @@ class QuestionTextRegex(Question): | ||
| 263 | super().correct(answer) | 264 | super().correct(answer) |
| 264 | if self['answer']: | 265 | if self['answer']: |
| 265 | try: | 266 | try: |
| 267 | + # FIXME why [0]? | ||
| 266 | self['grade'] = 1.0 if re.match(self['correct'], self['answer'][0]) else 0.0 | 268 | self['grade'] = 1.0 if re.match(self['correct'], self['answer'][0]) else 0.0 |
| 267 | except TypeError: | 269 | except TypeError: |
| 268 | logger.error('While matching regex {0} with answer {1}.'.format(self['correct'], self['answer'][0])) | 270 | logger.error('While matching regex {0} with answer {1}.'.format(self['correct'], self['answer'][0])) |
| @@ -298,7 +300,7 @@ class QuestionTextNumeric(Question): | @@ -298,7 +300,7 @@ class QuestionTextNumeric(Question): | ||
| 298 | try: | 300 | try: |
| 299 | self['grade'] = 1.0 if lower <= float(self['answer'][0]) <= upper else 0.0 | 301 | self['grade'] = 1.0 if lower <= float(self['answer'][0]) <= upper else 0.0 |
| 300 | except TypeError: | 302 | except TypeError: |
| 301 | - logger.error('While matching regex {0} with answer {1}.'.format(self['correct'], self['answer'][0])) | 303 | + logger.error('While matching regex {0} with answer {1}.'.format(self['correct'], self['answer'][0])) # FIXME [0], regex??? |
| 302 | except ValueError: | 304 | except ValueError: |
| 303 | self['comments'] = f'A resposta "{self["answer"][0]}" não é numérica.' | 305 | self['comments'] = f'A resposta "{self["answer"][0]}" não é numérica.' |
| 304 | return self['grade'] | 306 | return self['grade'] |
| @@ -337,7 +339,7 @@ class QuestionTextArea(Question): | @@ -337,7 +339,7 @@ class QuestionTextArea(Question): | ||
| 337 | # correct answer | 339 | # correct answer |
| 338 | out = run_script( | 340 | out = run_script( |
| 339 | script=self['correct'], | 341 | script=self['correct'], |
| 340 | - stdin=self['answer'][0], | 342 | + stdin=self['answer'][0],# FIXME [0] |
| 341 | timeout=self['timeout'] | 343 | timeout=self['timeout'] |
| 342 | ) | 344 | ) |
| 343 | if type(out) in (int, float): | 345 | if type(out) in (int, float): |
static/mathjax