Commit e831c259b6512c1f24f6f3c231a86f35408ce227

Authored by Miguel Barão
1 parent 065611f7
Exists in master and in 1 other branch dev

- links in the sidebar start new topic

BUGS.md
1 1  
2 2 BUGS:
3 3  
4   -- topicos no sidebar devem ser links para iniciar um topico acessivel. os inacessiveis devem estar inactivos.
5 4 - tabs em textarea nao funcionam correctamente (insere 1 espaco em vez de 4)
6 5 - reportar comentarios após submeter.
  6 +- os topicos locked devem estar inactivos no sidebar.
7 7 - textarea deve mostrar no html os valores iniciais de ans, se existir
8 8 - detect questions in questions.yaml without ref -> error ou generate default.
9 9 - error if demo.yaml has no topics
... ... @@ -21,6 +21,7 @@ TODO:
21 21  
22 22 FIXED:
23 23  
  24 +- topicos no sidebar devem ser links para iniciar um topico acessivel.
24 25 - logs inicio de topico
25 26 - indicar o topico actual no sidebar
26 27 - reload da página rebenta o estado.
... ...
app.py
... ... @@ -141,6 +141,11 @@ class LearnApp(object):
141 141  
142 142 return q['grade']
143 143  
  144 + # ------------------------------------------------------------------------
  145 + # Start new topic
  146 + # ------------------------------------------------------------------------
  147 + def start_topic(self, uid, topic):
  148 + self.online[uid]['state'].start_topic(topic)
144 149  
145 150 # ------------------------------------------------------------------------
146 151 # Fill db table 'Topic' with topics from the graph if not already there.
... ...
knowledge.py
... ... @@ -39,13 +39,15 @@ class Knowledge(object):
39 39 # Start a new topic. If not provided, selects the first with level < 0.8
40 40 # If all levels > 0.8, will stay in the last one forever...
41 41 # ------------------------------------------------------------------------
42   - def start_topic(self, topic=None):
43   - if topic is None:
  42 + def start_topic(self, topic=''):
  43 + print(f'knowledge.start_topic "{topic}"')
  44 + if not topic:
44 45 for topic in self.topic_sequence:
45 46 unlocked = topic in self.state
46 47 needs_work = unlocked and self.state[topic]['level'] < 0.8
47 48 factory = self.depgraph.node[topic]['factory']
48   - if needs_work and factory:
  49 + print(f'{topic}, unlocked={unlocked}, needs_work={needs_work}')
  50 + if factory and (not unlocked or needs_work):
49 51 break
50 52 # logger.info(f'{self.student} skipped topic "{topic}"')
51 53 else:
... ... @@ -53,7 +55,7 @@ class Knowledge(object):
53 55 # FIXME if factory is empty???
54 56  
55 57 self.current_topic = topic
56   - logger.info(f'User "{self.student}" topic set to "{topic}"')
  58 + logger.info(f'User "{self.student}" topic = "{topic}"')
57 59  
58 60 # generate question instances for current topic
59 61 questionlist = self.depgraph.node[topic]['questions']
... ...
serve.py
... ... @@ -120,6 +120,8 @@ class LearnHandler(BaseHandler):
120 120 @tornado.web.authenticated
121 121 def get(self):
122 122 uid = self.current_user
  123 + topic = self.get_query_argument('topic', default='')
  124 + self.learn.start_topic(uid, topic)
123 125 self.render('learn.html',
124 126 uid=uid,
125 127 name=self.learn.get_student_name(uid),
... ... @@ -204,7 +206,7 @@ class QuestionHandler(BaseHandler):
204 206 }
205 207  
206 208 @tornado.web.authenticated
207   - def get(self):
  209 + def get(self, topic=''):
208 210 self.write(self.new_question(self.current_user))
209 211  
210 212 # handles answer posted
... ...
templates/topics.html
... ... @@ -8,14 +8,14 @@
8 8 {% if t[0] == current_topic %}
9 9 <li class="active"> <!-- class="active" class="disabled" -->
10 10  
11   - <a> {{ gettopicname(t[0]) }}<br>
  11 + <a href="#"> {{ gettopicname(t[0]) }}<br>
12 12 {{ round(t[1]*5)*'<i class="fa fa-star text-success" aria-hidden="true"></i>' + round(5-t[1]*5)*'<i class="fa fa-star-o" aria-hidden="true"></i>' }}
13 13 </a>
14 14  
15 15 {% else %}
16 16 <li> <!-- class="active" class="disabled" -->
17 17  
18   - <a href="#"> {{ gettopicname(t[0]) }}<br>
  18 + <a href="/?topic={{ t[0] }}"> {{ gettopicname(t[0]) }}<br>
19 19 {{ round(t[1]*5)*'<i class="fa fa-star text-success" aria-hidden="true"></i>' + round(5-t[1]*5)*'<i class="fa fa-star-o" aria-hidden="true"></i>' }}
20 20 </a>
21 21  
... ...