diff --git a/BUGS.md b/BUGS.md index 76c7b66..c5d1437 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,6 +1,7 @@ BUGS: +- detect questions in questions.yaml without ref -> error ou generate default. - error if demo.yaml has no topics - pymips a funcionar - reload da página rebenta o estado. diff --git a/app.py b/app.py index 4b5cbd5..a62cec6 100644 --- a/app.py +++ b/app.py @@ -201,6 +201,7 @@ class LearnApp(object): g.node[ref]['name'] = attr # iterate over topics and create question factories + logger.info('Loading:') for ref in g.nodes_iter(): g.node[ref].setdefault('name', ref) fullpath = path.expanduser(path.join(prefix, ref)) @@ -210,8 +211,8 @@ class LearnApp(object): logger.error(f'build_dependency_graph: "{fullpath}" is not a directory') if path.isfile(filename): - logger.info(f'Loading questions from "{filename}"') questions = load_yaml(filename, default=[]) + logger.info(f' {len(questions)} questions from "{ref}"') for q in questions: q['path'] = fullpath g.node[ref]['factory'] = [QFactory(q) for q in questions] diff --git a/knowledge.py b/knowledge.py index 16d03be..76bde95 100644 --- a/knowledge.py +++ b/knowledge.py @@ -28,7 +28,7 @@ class Knowledge(object): # ------------------------------------------------------------------------ def new_topic(self, topic=None): - logger.debug(f'new_topic {topic}') + logger.debug(f'-> Knowledge.new_topic({topic})') if topic is None: # select the first topic that has level < 0.9 for topic in self.topic_sequence: @@ -44,6 +44,7 @@ class Knowledge(object): # ------------------------------------------------------------------------ def generate_questions_for_topic(self, topic): + logger.debug(f'-> Knowledge.generate_questions_for_topic({topic})') factory_list = self.depgraph.node[topic]['factory'] return [q.generate() for q in factory_list] @@ -57,6 +58,7 @@ class Knowledge(object): # ------------------------------------------------------------------------ def get_knowledge_state(self): + logger.debug('-> Knowledge.get_knowledge_state()') ts = [] for t in self.topic_sequence: if t in self.state: @@ -64,7 +66,6 @@ class Knowledge(object): else: ts.append((t, 0.0)) return ts - # return [(t, self.state.get(t, 0.0)) for t in self.topic_sequence] # ------------------------------------------------------------------------ def get_topic_progress(self): @@ -95,7 +96,6 @@ class Knowledge(object): return self.current_question - # --- checks answer ------------------------------------------------------ # returns current question with correction, time and comments updated def check_answer(self, answer): diff --git a/questions.py b/questions.py index 4987756..025636b 100644 --- a/questions.py +++ b/questions.py @@ -392,10 +392,12 @@ class QFactory(object): 'text_regex': QuestionTextRegex, 'text_numeric': QuestionTextNumeric, 'textarea' : QuestionTextArea, - # informative panels + # -- informative panels -- 'information': QuestionInformation, + 'info' : QuestionInformation, # same as 'information' 'warning' : QuestionInformation, 'alert' : QuestionInformation, + 'success' : QuestionInformation, } def __init__(self, question_dict): @@ -413,7 +415,7 @@ class QFactory(object): # If question is of generator type, an external program will be run # which will print a valid question in yaml format to stdout. This - # output is then converted to a dictionary and `q` becomes that dict. + # output is then yaml parsed into a dictionary `q`. if q['type'] == 'generator': logger.debug(f'Running script "{q["script"]}"...') q.setdefault('arg', '') # optional arguments will be sent to stdin diff --git a/serve.py b/serve.py index 28c294a..aa31238 100755 --- a/serve.py +++ b/serve.py @@ -108,13 +108,7 @@ class ChangePasswordHandler(BaseHandler): pw = self.get_body_arguments('new_password')[0]; if self.learn.change_password(uid, pw): - notification = tornado.escape.to_unicode( - self.render_string( - 'notification.html', - type='success', - msg='A password foi alterada!' - ) - ) + notification = tornado.escape.to_unicode(self.render_string('notification.html', type='success', msg='A password foi alterada!')) else: notification = tornado.escape.to_unicode(self.render_string('notification.html', type='danger', msg='A password não foi alterada!')) self.write({'msg': notification}) @@ -148,13 +142,15 @@ class FileHandler(BaseHandler): # respond to AJAX to get a JSON question class QuestionHandler(BaseHandler): templates = { - 'information': 'question-information.html', 'checkbox': 'question-checkbox.html', 'radio': 'question-radio.html', 'text': 'question-text.html', 'text_regex': 'question-text.html', 'text_numeric': 'question-text.html', 'textarea': 'question-textarea.html', + # -- information panels -- + 'information': 'question-information.html', + 'success': 'question-success.html', } # @tornado.web.authenticated diff --git a/templates/question-success.html b/templates/question-success.html new file mode 100644 index 0000000..df9fcfa --- /dev/null +++ b/templates/question-success.html @@ -0,0 +1,9 @@ +{% autoescape %} + +

{{ question['title'] }}

+ + + + -- libgit2 0.21.2