Commit b9094cfbafeb440b500ce176ee003fed1b2186d6
1 parent
51a1382e
Exists in
master
and in
1 other branch
- fixed direct link to topic locked
Showing
4 changed files
with
31 additions
and
15 deletions
Show diff stats
BUGS.md
| @@ -2,13 +2,10 @@ | @@ -2,13 +2,10 @@ | ||
| 2 | BUGS: | 2 | BUGS: |
| 3 | 3 | ||
| 4 | - se refs de um topic estao invalidos, nao carrega esse topico. devia haver um error nos logs a indicar qual o ref invalido. | 4 | - se refs de um topic estao invalidos, nao carrega esse topico. devia haver um error nos logs a indicar qual o ref invalido. |
| 5 | -- templates not working: quesntion-information, question-warning (remove all informative panels??) | ||
| 6 | -- link directo para topico nao valida se topico esta unlocked. | ||
| 7 | -- reportar comentarios após submeter. | ||
| 8 | - forçar reload das perguntas sem ter de deitar abaixo o servidor. | 5 | - forçar reload das perguntas sem ter de deitar abaixo o servidor. |
| 9 | - 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. |
| 10 | - Criar outra estrutura organizada em capítulos (conjuntos de tópicos). Permitir capítulos de capítulos, etc. talvez usar grafos de grafos... | 7 | - Criar outra estrutura organizada em capítulos (conjuntos de tópicos). Permitir capítulos de capítulos, etc. talvez usar grafos de grafos... |
| 11 | -- pertuntas tipo tristate: (sim, não, não sei) | 8 | +- pertuntas tipo tristate: (sim, não, não sei |
| 12 | - detect questions in questions.yaml without ref -> error ou generate default. | 9 | - detect questions in questions.yaml without ref -> error ou generate default. |
| 13 | - error if demo.yaml has no topics | 10 | - error if demo.yaml has no topics |
| 14 | - session management. close after inactive time. | 11 | - session management. close after inactive time. |
| @@ -19,6 +16,8 @@ BUGS: | @@ -19,6 +16,8 @@ BUGS: | ||
| 19 | 16 | ||
| 20 | TODO: | 17 | TODO: |
| 21 | 18 | ||
| 19 | +- reportar comentarios após submeter. | ||
| 20 | +- each topic only loads a sample of K questions (max) in random order. | ||
| 22 | - servir imagens/ficheiros. | 21 | - servir imagens/ficheiros. |
| 23 | - update de fontawesome para versão 5. | 22 | - update de fontawesome para versão 5. |
| 24 | - reload das perguntas enquanto online. | 23 | - reload das perguntas enquanto online. |
| @@ -35,6 +34,8 @@ TODO: | @@ -35,6 +34,8 @@ TODO: | ||
| 35 | 34 | ||
| 36 | FIXED: | 35 | FIXED: |
| 37 | 36 | ||
| 37 | +- link directo para topico nao valida se topico esta unlocked. | ||
| 38 | +- templates not working: quesntion-information, question-warning (remove all informative panels??) | ||
| 38 | - enderecos errados dao internal error. | 39 | - enderecos errados dao internal error. |
| 39 | - barra de progresso nao está visível. | 40 | - barra de progresso nao está visível. |
| 40 | - tabs em textarea nao funcionam correctamente (insere 1 espaco em vez de 4) | 41 | - tabs em textarea nao funcionam correctamente (insere 1 espaco em vez de 4) |
knowledge.py
| @@ -70,6 +70,10 @@ class StudentKnowledge(object): | @@ -70,6 +70,10 @@ class StudentKnowledge(object): | ||
| 70 | if not topic: | 70 | if not topic: |
| 71 | topic = self.get_recommended_topic() | 71 | topic = self.get_recommended_topic() |
| 72 | 72 | ||
| 73 | + # check if it's unlocked | ||
| 74 | + if self.is_locked(topic): | ||
| 75 | + return False | ||
| 76 | + | ||
| 73 | self.current_topic = topic | 77 | self.current_topic = topic |
| 74 | # logger.info(f'Topic set to "{topic}"') | 78 | # logger.info(f'Topic set to "{topic}"') |
| 75 | 79 | ||
| @@ -82,6 +86,7 @@ class StudentKnowledge(object): | @@ -82,6 +86,7 @@ class StudentKnowledge(object): | ||
| 82 | 86 | ||
| 83 | self.current_question = self.questions.pop(0) # FIXME crash if empty | 87 | self.current_question = self.questions.pop(0) # FIXME crash if empty |
| 84 | self.current_question['start_time'] = datetime.now() | 88 | self.current_question['start_time'] = datetime.now() |
| 89 | + return True | ||
| 85 | 90 | ||
| 86 | # ------------------------------------------------------------------------ | 91 | # ------------------------------------------------------------------------ |
| 87 | # The topic has finished and there are no more questions. | 92 | # The topic has finished and there are no more questions. |
| @@ -148,6 +153,10 @@ class StudentKnowledge(object): | @@ -148,6 +153,10 @@ class StudentKnowledge(object): | ||
| 148 | return self.current_topic | 153 | return self.current_topic |
| 149 | 154 | ||
| 150 | # ------------------------------------------------------------------------ | 155 | # ------------------------------------------------------------------------ |
| 156 | + def is_locked(self, topic): | ||
| 157 | + return topic not in self.state | ||
| 158 | + | ||
| 159 | + # ------------------------------------------------------------------------ | ||
| 151 | # Return list of {ref: 'xpto', name: 'long name', leve: 0.5} | 160 | # Return list of {ref: 'xpto', name: 'long name', leve: 0.5} |
| 152 | # Levels are in the interval [0, 1] if unlocked or None if locked. | 161 | # Levels are in the interval [0, 1] if unlocked or None if locked. |
| 153 | # Topics unlocked but not yet done have level 0.0. | 162 | # Topics unlocked but not yet done have level 0.0. |
| @@ -176,3 +185,4 @@ class StudentKnowledge(object): | @@ -176,3 +185,4 @@ class StudentKnowledge(object): | ||
| 176 | # ------------------------------------------------------------------------ | 185 | # ------------------------------------------------------------------------ |
| 177 | def get_recommended_topic(self): # FIXME untested | 186 | def get_recommended_topic(self): # FIXME untested |
| 178 | return min(self.state.items(), key=lambda x: x[1]['level'])[0] | 187 | return min(self.state.items(), key=lambda x: x[1]['level'])[0] |
| 188 | + |
learnapp.py
| @@ -147,12 +147,16 @@ class LearnApp(object): | @@ -147,12 +147,16 @@ class LearnApp(object): | ||
| 147 | # ------------------------------------------------------------------------ | 147 | # ------------------------------------------------------------------------ |
| 148 | def start_topic(self, uid, topic): | 148 | def start_topic(self, uid, topic): |
| 149 | try: | 149 | try: |
| 150 | - self.online[uid]['state'].init_topic(topic) | 150 | + ok = self.online[uid]['state'].init_topic(topic) |
| 151 | except KeyError as e: | 151 | except KeyError as e: |
| 152 | - logger.warning(f'User "{uid}" trying to start nonexistent "{topic}"') | 152 | + logger.warning(f'User "{uid}" denied nonexistent "{topic}"') |
| 153 | raise e | 153 | raise e |
| 154 | else: | 154 | else: |
| 155 | - logger.info(f'User "{uid}" started "{topic}"') | 155 | + if ok: |
| 156 | + logger.info(f'User "{uid}" started "{topic}"') | ||
| 157 | + else: | ||
| 158 | + logger.warning(f'User "{uid}" denied locked "{topic}"') | ||
| 159 | + return ok | ||
| 156 | 160 | ||
| 157 | # ------------------------------------------------------------------------ | 161 | # ------------------------------------------------------------------------ |
| 158 | # Fill db table 'Topic' with topics from the graph if not already there. | 162 | # Fill db table 'Topic' with topics from the graph if not already there. |
serve.py
| @@ -129,16 +129,17 @@ class TopicHandler(BaseHandler): | @@ -129,16 +129,17 @@ class TopicHandler(BaseHandler): | ||
| 129 | uid = self.current_user | 129 | uid = self.current_user |
| 130 | 130 | ||
| 131 | try: | 131 | try: |
| 132 | - self.learn.start_topic(uid, topic) | 132 | + ok = self.learn.start_topic(uid, topic) |
| 133 | except KeyError: | 133 | except KeyError: |
| 134 | - self.redirect('/') | ||
| 135 | - # raise tornado.web.HTTPError(404) | 134 | + self.redirect('/') |
| 136 | else: | 135 | else: |
| 137 | - self.render('topic.html', | ||
| 138 | - uid=uid, | ||
| 139 | - name=self.learn.get_student_name(uid), | ||
| 140 | - ) | ||
| 141 | - | 136 | + if ok: |
| 137 | + self.render('topic.html', | ||
| 138 | + uid=uid, | ||
| 139 | + name=self.learn.get_student_name(uid), | ||
| 140 | + ) | ||
| 141 | + else: | ||
| 142 | + self.redirect('/') | ||
| 142 | 143 | ||
| 143 | # ---------------------------------------------------------------------------- | 144 | # ---------------------------------------------------------------------------- |
| 144 | class FileHandler(BaseHandler): | 145 | class FileHandler(BaseHandler): |