diff --git a/perguntations/templates/review.html b/perguntations/templates/review.html index 2a9ae8d..d4d9033 100644 --- a/perguntations/templates/review.html +++ b/perguntations/templates/review.html @@ -97,7 +97,7 @@
- {{ round(t['grade'], 1) }} valores + {{ round(t['grade'], 2) }} valores {% if t['state'] == 'QUIT' %} (DESISTÊNCIA) {% end %} diff --git a/perguntations/testfactory.py b/perguntations/testfactory.py index 20edf1d..ad92d28 100644 --- a/perguntations/testfactory.py +++ b/perguntations/testfactory.py @@ -223,24 +223,51 @@ class TestFactory(dict): ''' logger.info('Checking if questions can be generated and corrected...') for i, (qref, qfact) in enumerate(self['question_factory'].items()): - logger.info('%4d. %s:', i, qref) try: question = qfact.generate() except Exception as exc: msg = f'Failed to generate "{qref}"' raise TestFactoryException(msg) from exc else: - logger.info(' generate Ok') + logger.info('%4d. %s: Ok', i, qref) + # logger.info(' generate Ok') if question['type'] in ('code', 'textarea'): - try: - question.set_answer('') - question.correct() - except Exception as exc: - msg = f'Failed to correct "{qref}"' - raise TestFactoryException(msg) from exc + if 'tests_right' in question: + for i, right_answer in enumerate(question['tests_right']): + try: + question.set_answer(right_answer) + question.correct() + except Exception as exc: + msg = f'Failed to correct "{qref}"' + raise TestFactoryException(msg) from exc + + if question['grade'] == 1.0: + logger.info(' test %i Ok', i) + else: + logger.error(' TEST %i IS WRONG!!!', i) + elif 'tests_wrong' in question: + for i, wrong_answer in enumerate(question['tests_wrong']): + try: + question.set_answer(wrong_answer) + question.correct() + except Exception as exc: + msg = f'Failed to correct "{qref}"' + raise TestFactoryException(msg) from exc + + if question['grade'] < 1.0: + logger.info(' test %i Ok', i) + else: + logger.error(' TEST %i IS WRONG!!!', i) else: - logger.info(' correct Ok') + try: + question.set_answer('') + question.correct() + except Exception as exc: + msg = f'Failed to correct "{qref}"' + raise TestFactoryException(msg) from exc + else: + logger.info(' correct Ok but no tests to run') # ------------------------------------------------------------------------ async def generate(self): -- libgit2 0.21.2