diff --git a/BUGS.md b/BUGS.md index 95acdf2..e961757 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,11 +1,11 @@ # BUGS +- image brand da universidade está esbatida. - generators e correct scripts que durem muito tempo podem bloquear o loop do tornado? - detect questions in questions.yaml without ref -> error ou generate default. - topicos virtuais nao deveriam aparecer. na construção da árvore os sucessores seriam ligados directamente aos predecessores. - Criar outra estrutura organizada em capítulos (conjuntos de tópicos). Permitir capítulos de capítulos, etc. talvez usar grafos de grafos... -- error if demo.yaml has no topics - session management. close after inactive time. - generators not working: bcrypt (ver blog) - tabelas nas perguntas radio/checkbox não ocupam todo o espaço como em question. @@ -16,7 +16,6 @@ - each topic only loads a sample of K questions (max) in random order. - servir imagens/ficheiros. - pertuntas tipo tristate: (sim, não, não sei -- forçar reload das perguntas sem ter de deitar abaixo o servidor. - reload das perguntas enquanto online. - tabela de progresso de todos os alunos por topico. - tabela com perguntas / quantidade de respostas certas/erradas. @@ -31,6 +30,7 @@ # FIXED +- error if demo.yaml has no topics - update de fontawesome para versão 5.0.6. - remover learn.css uma vez que nao é usado em lado nenhum? - check if user already logged in diff --git a/knowledge.py b/knowledge.py index 04b92cc..fed9d5a 100644 --- a/knowledge.py +++ b/knowledge.py @@ -32,7 +32,7 @@ class StudentKnowledge(object): now = datetime.now() for s in state.values(): dt = now - s['date'] - s['level'] *= 0.975 ** dt.days # forgetting factor + s['level'] *= 0.8 ** dt.days # forgetting factor 0.95 # compute recommended sequence of topics ['a', 'b', ...] self.topic_sequence = list(nx.topological_sort(self.deps)) @@ -45,7 +45,7 @@ class StudentKnowledge(object): def unlock_topics(self): # minimum level that the dependencies of a topic must have # for the topic to be unlocked. - min_level = 0.01 + min_level = 0.2 for topic in self.topic_sequence: if topic not in self.state: # if locked @@ -75,7 +75,6 @@ class StudentKnowledge(object): return False self.current_topic = topic - # logger.info(f'Topic set to "{topic}"') # generate question instances for current topic factory = self.deps.node[topic]['factory'] @@ -84,9 +83,14 @@ class StudentKnowledge(object): self.questions = [factory[qref].generate() for qref in questionlist] self.finished_questions = [] - self.current_question = self.questions.pop(0) # FIXME crash if empty - self.current_question['start_time'] = datetime.now() - return True + try: + self.current_question = self.questions.pop(0) # FIXME crash if empty + except IndexError: + self.finish_topic() + return False + else: + self.current_question['start_time'] = datetime.now() + return True # ------------------------------------------------------------------------ # The topic has finished and there are no more questions. diff --git a/learnapp.py b/learnapp.py index 474442c..c523cae 100644 --- a/learnapp.py +++ b/learnapp.py @@ -305,6 +305,6 @@ def build_dependency_graph(config={}): q['path'] = fullpath # fullpath added to each question tnode['factory'][q['ref']] = QFactory(q) - logger.info(f'{len(tnode["questions"]):6} from {ref}') + logger.info(f'{len(tnode["questions"]):6} {ref}') return g diff --git a/serve.py b/serve.py index 4f55f19..0fd46c8 100755 --- a/serve.py +++ b/serve.py @@ -142,6 +142,7 @@ class TopicHandler(BaseHandler): self.redirect('/') # ---------------------------------------------------------------------------- +# FIXME class FileHandler(BaseHandler): @tornado.web.authenticated def get(self, filename): @@ -176,36 +177,6 @@ class QuestionHandler(BaseHandler): # 'alert': '', FIXME } - def new_question(self, user): - question = self.learn.get_student_question(user) # Question - template = self.templates[question['type']] - question_html = self.render_string(template, question=question, md=md_to_html) - - return { - 'method': 'new_question', - 'params': { - 'question': tornado.escape.to_unicode(question_html), - 'progress': self.learn.get_student_progress(user), - } - } - - def wrong_answer(self, user): - progress = self.learn.get_student_progress(user) # in the current topic - return { - 'method': 'shake', - 'params': { - 'progress': progress, - } - } - - def finished_topic(self, user): # FIXME user unused - return { - 'method': 'finished_topic', - 'params': { # FIXME no html here please! - 'question': f'trophy' - } - } - @tornado.web.authenticated def get(self): logging.debug('QuestionHandler.get()') @@ -236,7 +207,7 @@ class QuestionHandler(BaseHandler): else: # answers returned in a list. fix depending on question type qtype = self.learn.get_student_question_type(user) - if qtype in ('success', 'information', 'info'): # FIXME danger... + if qtype in ('success', 'information', 'info'): # FIXME unused? answer = None elif qtype != 'checkbox': # radio, text, textarea, ... answer = answer[0] @@ -244,13 +215,35 @@ class QuestionHandler(BaseHandler): grade = self.learn.check_answer(user, answer) question = self.learn.get_student_question(user) - if question is None: - self.write(self.finished_topic(user)) - elif grade > 0.999: - self.write(self.new_question(user)) - else: - self.write(self.wrong_answer(user)) - + if grade <= 0.999: # wrong answer + comments_html = self.render_string('comments.html', comments=question['comments'], md=md_to_html) + self.write({ + 'method': 'shake', + 'params': { + 'progress': self.learn.get_student_progress(user), + 'comments': tornado.escape.to_unicode(comments_html), # FIXME + } + }) + else: # answer is correct + if question is None: # finished topic + finished_topic_html = self.render_string('finished_topic.html') + self.write({ + 'method': 'finished_topic', + 'params': { + 'question': tornado.escape.to_unicode(finished_topic_html) + } + }) + + else: # continue with a new question + template = self.templates[question['type']] + question_html = self.render_string(template, question=question, md=md_to_html) + self.write({ + 'method': 'new_question', + 'params': { + 'question': tornado.escape.to_unicode(question_html), + 'progress': self.learn.get_student_progress(user), + } + }) # ------------------------------------------------------------------------- # Tornado web server diff --git a/static/css/topic.css b/static/css/topic.css index 9474ca7..ef7e5f9 100644 --- a/static/css/topic.css +++ b/static/css/topic.css @@ -7,16 +7,16 @@ body { margin: 0; padding-top: 0px; - margin-bottom: 60px; /* Margin bottom by footer height */ + margin-bottom: 90px; /* Margin bottom by footer height */ } .footer { position: absolute; bottom: 0; width: 100%; - height: 40px; + height: 70px; line-height: 60px; - background-color: #f5f5f5; + /*background-color: #f5f5f5;*/ } html { diff --git a/static/js/maintopics.js b/static/js/maintopics.js index 284120c..f7c6fe0 100644 --- a/static/js/maintopics.js +++ b/static/js/maintopics.js @@ -9,8 +9,6 @@ function getCookie(name) { } function change_password() { - // alert('hello'); - // notify('hello!'); var token = getCookie('_xsrf'); $.ajax({ type: "POST", diff --git a/static/js/topic.js b/static/js/topic.js index 19edbd7..c578343 100644 --- a/static/js/topic.js +++ b/static/js/topic.js @@ -12,6 +12,7 @@ function updateQuestion(response){ switch (response["method"]) { case "new_question": $("#question_div").html(response["params"]["question"]); + $("#comments").html(""); $('#topic_progress').css('width', (100*response["params"]["progress"])+'%').attr('aria-valuenow', 100*response["params"]["progress"]); MathJax.Hub.Queue(["Typeset",MathJax.Hub,"question_div"]); @@ -46,6 +47,8 @@ function updateQuestion(response){ case "shake": $('#topic_progress').css('width', (100*response["params"]["progress"])+'%').attr('aria-valuenow', 100*response["params"]["progress"]); $('#question_div').animateCSS('shake'); + $('#comments').html(response['params']['comments']); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,"#comments"]); break; case "finished_topic": diff --git a/templates/notification.html b/templates/notification.html index 1019596..60bee18 100644 --- a/templates/notification.html +++ b/templates/notification.html @@ -1,4 +1,4 @@ - -- libgit2 0.21.2