diff --git a/BUGS.md b/BUGS.md index 50f887d..8832eda 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,6 +1,10 @@ # BUGS +- nos topicos learn.yaml, qd falha acrescenta no fim. nao faz sentido. +- ocorreu uma vez o sqlalchemy dar mesg erro a indicar que as threads sao diferents quando se faz o get da primeira pergunta do topico. Muitas vezes nao mostar erro, mas a pagina da erro ou fica em branco... + +- mathjax, formulas $$f(x)$$ nas opções de escolha multipla, não ficam centradas em toda a coluna mas apenas na largura do parágrafo. - mostrar feedback/solucoes quando acerta, ou excede max tries. - default prefix should be obtained from each course (yaml conf)? - tabelas nas perguntas radio/checkbox não ocupam todo o espaço como em question. diff --git a/knowledge.py b/knowledge.py index 0874b57..f880059 100644 --- a/knowledge.py +++ b/knowledge.py @@ -71,13 +71,14 @@ class StudentKnowledge(object): # questions: list of generated questions to do in the topic # current_question: the current question to be presented # ------------------------------------------------------------------------ - async def init_topic(self, topic): - logger.debug(f'StudentKnowledge.init_topic({topic})') + # FIXME async mas nao tem awaits... + async def start_topic(self, topic): + logger.debug(f'StudentKnowledge.start_topic({topic})') # do not allow locked topics if self.is_locked(topic): logger.debug(f'Topic {topic} is locked') - return + return False # starting new topic self.current_topic = topic @@ -85,7 +86,11 @@ class StudentKnowledge(object): self.wrong_answers = 0 t = self.deps.node[topic] - questions = random.sample(t['questions'], k=t['choose']) + k = t['choose'] + if t['shuffle']: + questions = random.sample(t['questions'], k=k) + else: + questions = t['questions'][:k] logger.debug(f'Questions: {", ".join(questions)}') # generate instances of questions @@ -94,6 +99,7 @@ class StudentKnowledge(object): # get first question self.next_question() + return True # ------------------------------------------------------------------------ @@ -140,8 +146,10 @@ class StudentKnowledge(object): logger.debug(f'Wrong answers = {self.wrong_answers}; Tries = {self.current_question["tries"]}') if self.current_question['tries'] <= 0: - logger.debug("Appending new instance of this question to the end") - self.questions.append(self.factory[q['ref']].generate()) + if self.current_question['append_wrong']: + logger.debug("Appending new instance of this question to the end") + self.questions.append(self.factory[q['ref']].generate()) + if self.next_question() is None: action = 'finished_topic' else: @@ -165,7 +173,8 @@ class StudentKnowledge(object): self.finish_topic() else: self.current_question['start_time'] = datetime.now() - self.current_question['tries'] = self.current_question.get('max_tries', 3) # FIXME hardcoded 3 + default_maxtries = self.deps.nodes[self.current_topic]['max_tries'] + self.current_question['tries'] = self.current_question.get('max_tries', default_maxtries) logger.debug(f'Next question is "{self.current_question["ref"]}"') return self.current_question # question or None diff --git a/learnapp.py b/learnapp.py index a84afe1..c44c921 100644 --- a/learnapp.py +++ b/learnapp.py @@ -186,7 +186,7 @@ class LearnApp(object): async def start_topic(self, uid, topic): student = self.online[uid]['state'] try: - await student.init_topic(topic) + await student.start_topic(topic) except KeyError as e: logger.warning(f'User "{uid}" tried to open nonexistent topic: "{topic}"') raise e @@ -242,6 +242,8 @@ class LearnApp(object): default_shuffle = config.get('shuffle', True) default_choose = config.get('choose', 9999) default_forgetting_factor = config.get('forgetting_factor', 1.0) + default_maxtries = config.get('max_tries', 3) + default_append_wrong = config.get('append_wrong', True) # iterate over topics and populate graph topics = config.get('topics', {}) @@ -257,8 +259,10 @@ class LearnApp(object): t['path'] = path.join(g.graph['prefix'], tref) # prefix/topic t['file'] = attr.get('file', default_file) # questions.yaml t['shuffle'] = attr.get('shuffle', default_shuffle) + t['max_tries'] = attr.get('max_tries', default_maxtries) t['forgetting_factor'] = attr.get('forgetting_factor', default_forgetting_factor) t['choose'] = attr.get('choose', default_choose) + t['append_wrong'] = attr.get('append_wrong', default_append_wrong) t['questions'] = attr.get('questions', []) logger.info(f'Loaded {g.number_of_nodes()} topics') @@ -286,6 +290,7 @@ class LearnApp(object): qref = q.get('ref', str(i)) # ref or number q['ref'] = tref + ':' + qref q['path'] = topicpath + q.setdefault('append_wrong', t['append_wrong']) # if questions are left undefined, include all. if not t['questions']: diff --git a/serve.py b/serve.py index e076e19..b1e32ac 100755 --- a/serve.py +++ b/serve.py @@ -149,6 +149,8 @@ class RootHandler(BaseHandler): # Start a given topic: /topic/... # ---------------------------------------------------------------------------- class TopicHandler(BaseHandler): + SUPPORTED_METHODS = ['GET'] + @tornado.web.authenticated async def get(self, topic): uid = self.current_user diff --git a/templates/question.html b/templates/question.html index bbf009f..595749b 100644 --- a/templates/question.html +++ b/templates/question.html @@ -1,6 +1,6 @@ {% autoescape %} -