Commit dda6f8384e5034d172ae6a5a2f56fc619065cfee
1 parent
79e29c38
Exists in
master
and in
1 other branch
- fixed error on empty answer for questions of type radio
Showing
4 changed files
with
18 additions
and
12 deletions
Show diff stats
BUGS.md
| 1 | 1 | ||
| 2 | BUGS: | 2 | BUGS: |
| 3 | 3 | ||
| 4 | -- indentação da primeira linha de código não funciona. | ||
| 5 | -- submeter questoes radio, da erro se nao escolher nenhuma opção. | ||
| 6 | - gravar evolucao na bd no final de cada topico. | 4 | - gravar evolucao na bd no final de cada topico. |
| 7 | - servir imagens/ficheiros. | 5 | - servir imagens/ficheiros. |
| 8 | - topicos virtuais nao deveriam aparecer. na construção da árvore os sucessores seriam ligados directamente aos predecessores. | 6 | - topicos virtuais nao deveriam aparecer. na construção da árvore os sucessores seriam ligados directamente aos predecessores. |
| 9 | 7 | ||
| 10 | 8 | ||
| 11 | - reportar comentarios após submeter. | 9 | - reportar comentarios após submeter. |
| 12 | -- cada topico tem uma pagina begin e uma end | 10 | +- cada topico tem uma pagina begin e uma end? |
| 13 | - pertuntas tipo tristate: (sim, não, não sei) | 11 | - pertuntas tipo tristate: (sim, não, não sei) |
| 14 | - animação no final de cada topico para se perceber a transição | 12 | - animação no final de cada topico para se perceber a transição |
| 15 | - aumentar espaço a seguir às tabelas no texto | 13 | - aumentar espaço a seguir às tabelas no texto |
| @@ -31,6 +29,8 @@ TODO: | @@ -31,6 +29,8 @@ TODO: | ||
| 31 | 29 | ||
| 32 | FIXED: | 30 | FIXED: |
| 33 | 31 | ||
| 32 | +- submeter questoes radio, da erro se nao escolher nenhuma opção. | ||
| 33 | +- indentação da primeira linha de código não funciona. | ||
| 34 | - markdown com o mistune. | 34 | - markdown com o mistune. |
| 35 | - change password in maintopics.html, falta menu para lançar modal | 35 | - change password in maintopics.html, falta menu para lançar modal |
| 36 | - ver documentacao de migracao para networkx 2.0 https://networkx.github.io/documentation/stable/release/migration_guide_from_1.x_to_2.0.html | 36 | - ver documentacao de migracao para networkx 2.0 https://networkx.github.io/documentation/stable/release/migration_guide_from_1.x_to_2.0.html |
knowledge.py
| @@ -113,14 +113,7 @@ class StudentKnowledge(object): | @@ -113,14 +113,7 @@ class StudentKnowledge(object): | ||
| 113 | 113 | ||
| 114 | q = self.current_question | 114 | q = self.current_question |
| 115 | 115 | ||
| 116 | - # answers are returned from tornado in a list | ||
| 117 | - if q['type'] in ('success', 'information', 'info'): # FIXME danger... | ||
| 118 | - q['answer'] = None | ||
| 119 | - elif q['type'] != 'checkbox': | ||
| 120 | - q['answer'] = answer[0] | ||
| 121 | - else: | ||
| 122 | - q['answer'] = answer | ||
| 123 | - | 116 | + q['answer'] = answer |
| 124 | q['finish_time'] = datetime.now() | 117 | q['finish_time'] = datetime.now() |
| 125 | grade = q.correct() | 118 | grade = q.correct() |
| 126 | logger.debug(f'Grade = {grade:.2} ({q["ref"]})') | 119 | logger.debug(f'Grade = {grade:.2} ({q["ref"]})') |
learnapp.py
| @@ -207,6 +207,10 @@ class LearnApp(object): | @@ -207,6 +207,10 @@ class LearnApp(object): | ||
| 207 | return self.online[uid]['state'].get_current_question() # dict | 207 | return self.online[uid]['state'].get_current_question() # dict |
| 208 | 208 | ||
| 209 | # ------------------------------------------------------------------------ | 209 | # ------------------------------------------------------------------------ |
| 210 | + def get_student_question_type(self, uid): | ||
| 211 | + return self.online[uid]['state'].get_current_question()['type'] | ||
| 212 | + | ||
| 213 | + # ------------------------------------------------------------------------ | ||
| 210 | def get_student_topic(self, uid): | 214 | def get_student_topic(self, uid): |
| 211 | return self.online[uid]['state'].get_current_topic() # str | 215 | return self.online[uid]['state'].get_current_topic() # str |
| 212 | 216 |
serve.py
| @@ -229,7 +229,16 @@ class QuestionHandler(BaseHandler): | @@ -229,7 +229,16 @@ class QuestionHandler(BaseHandler): | ||
| 229 | 229 | ||
| 230 | # check answer and get next question (same, new or None) | 230 | # check answer and get next question (same, new or None) |
| 231 | answer = self.get_body_arguments('answer') # list | 231 | answer = self.get_body_arguments('answer') # list |
| 232 | - print(answer) | 232 | + if not answer: |
| 233 | + answer = None | ||
| 234 | + else: | ||
| 235 | + # answers returned in a list. fix depending on question type | ||
| 236 | + qtype = self.learn.get_student_question_type(user) | ||
| 237 | + if qtype in ('success', 'information', 'info'): # FIXME danger... | ||
| 238 | + answer = None | ||
| 239 | + elif qtype != 'checkbox': # radio, text, textarea, ... | ||
| 240 | + answer = answer[0] | ||
| 241 | + | ||
| 233 | grade = self.learn.check_answer(user, answer) | 242 | grade = self.learn.check_answer(user, answer) |
| 234 | question = self.learn.get_student_question(user) | 243 | question = self.learn.get_student_question(user) |
| 235 | 244 |