Commit af9900456df1eafc14995eef385c5bd33fcd05f9
1 parent
427fa9a9
Exists in
master
and in
1 other branch
- added support for nodes of type 'chapter', that usually only have dependencies…
… and an information "question". - fixed information and success "questions".
Showing
6 changed files
with
32 additions
and
12 deletions
Show diff stats
knowledge.py
... | ... | @@ -45,7 +45,7 @@ class StudentKnowledge(object): |
45 | 45 | now = datetime.now() |
46 | 46 | for s in self.state.values(): |
47 | 47 | dt = now - s['date'] |
48 | - s['level'] *= 0.8 ** dt.days # forgetting factor 0.95 | |
48 | + s['level'] *= 0.95 ** dt.days # forgetting factor 0.95 | |
49 | 49 | |
50 | 50 | |
51 | 51 | # ------------------------------------------------------------------------ |
... | ... | @@ -178,6 +178,7 @@ class StudentKnowledge(object): |
178 | 178 | def get_knowledge_state(self): |
179 | 179 | return [{ |
180 | 180 | 'ref': ref, |
181 | + 'type': self.deps.nodes[ref]['type'], | |
181 | 182 | 'name': self.deps.nodes[ref]['name'], |
182 | 183 | 'level': self.state[ref]['level'] if ref in self.state else None |
183 | 184 | } for ref in self.topic_sequence ] | ... | ... |
learnapp.py
... | ... | @@ -246,6 +246,10 @@ class LearnApp(object): |
246 | 246 | def get_topic_name(self, ref): |
247 | 247 | return self.deps.node[ref]['name'] |
248 | 248 | |
249 | + # # ------------------------------------------------------------------------ | |
250 | + # def get_topic_type(self, ref): | |
251 | + # return self.deps.node[ref]['type'] | |
252 | + | |
249 | 253 | # ------------------------------------------------------------------------ |
250 | 254 | def get_current_public_dir(self, uid): |
251 | 255 | topic = self.online[uid]['state'].get_current_topic() |
... | ... | @@ -287,6 +291,7 @@ def build_dependency_graph(config={}): |
287 | 291 | tnode = g.node[ref] # current node (topic) |
288 | 292 | |
289 | 293 | if isinstance(attr, dict): |
294 | + tnode['type'] = attr.get('type', 'topic') | |
290 | 295 | tnode['name'] = attr.get('name', ref) |
291 | 296 | tnode['questions'] = attr.get('questions', []) |
292 | 297 | g.add_edges_from((d,ref) for d in attr.get('deps', [])) | ... | ... |
serve.py
... | ... | @@ -117,7 +117,8 @@ class RootHandler(BaseHandler): |
117 | 117 | uid=uid, |
118 | 118 | name=self.learn.get_student_name(uid), |
119 | 119 | state=self.learn.get_student_state(uid), |
120 | - title=self.learn.get_title() | |
120 | + title=self.learn.get_title(), | |
121 | + # get_topic_type=self.learn.get_topic_type, # function | |
121 | 122 | ) |
122 | 123 | |
123 | 124 | # ---------------------------------------------------------------------------- | ... | ... |
templates/maintopics.html
... | ... | @@ -62,7 +62,7 @@ |
62 | 62 | |
63 | 63 | <h4>{{ title }}</h4> |
64 | 64 | |
65 | - <div class="list-group my-3"> | |
65 | + <div class="list-group"> | |
66 | 66 | {% for t in state %} |
67 | 67 | {% if t['level'] is None %} |
68 | 68 | <a class="list-group-item list-group-item-action bg-light disabled"> |
... | ... | @@ -83,12 +83,15 @@ |
83 | 83 | </div> |
84 | 84 | <div class="ml-auto p-2"> |
85 | 85 | {% if t['level'] < 0.01 %} |
86 | - | |
87 | 86 | <i class="fas fa-lock-open text-success"></i> |
88 | 87 | {% else %} |
88 | + {% if t['type']=='chapter' %} | |
89 | + <i class="fas fa-trophy fa-lg text-warning"></i> | |
90 | + {% else %} | |
89 | 91 | <span class="text-nowrap"> |
90 | - {{ round(t['level']*5)*'<i class="fas fa-star text-warning"></i>' + round(5-t['level']*5)*'<i class="far fa-star text-muted"></i>' }} | |
92 | + {{ round(t['level']*5)*'<i class="fas fa-star text-warning"></i>' + round(5-t['level']*5)*'<i class="far fa-star text-warning"></i>' }} | |
91 | 93 | </span> |
94 | + {% end %} | |
92 | 95 | {% end %} |
93 | 96 | </div> |
94 | 97 | </div> | ... | ... |
templates/question-information.html
1 | -{% extends "question.html" %} | |
1 | +{% autoescape %} | |
2 | + | |
3 | +<div class="card border-primary mb-3"> | |
4 | + <div class="card-body text-primary"> | |
5 | + <h3 class="card-title">{{ question['title'] }}</h3> | |
6 | + <p class="card-text"> | |
7 | + {{ md(question['text']) }} | |
8 | + </p> | |
9 | + </div> | |
10 | +</div> | |
2 | 11 | |
3 | -{% block answer %} | |
4 | 12 | <input type="hidden" name="question_ref" value="{{ question['ref'] }}"> |
5 | -{% end %} | ... | ... |
templates/question-success.html
1 | 1 | {% autoescape %} |
2 | 2 | |
3 | -<h1 class="page-header">{{ question['title'] }}</h1> | |
4 | - | |
5 | -<div id="text" class="alert alert-success" role="alert"> | |
6 | - {{ md(question['text']) }} | |
3 | +<div class="card border-success mb-3"> | |
4 | + <div class="card-body text-success"> | |
5 | + <h3 class="card-title">{{ question['title'] }}</h3> | |
6 | + <p class="card-text"> | |
7 | + {{ md(question['text']) }} | |
8 | + </p> | |
9 | + </div> | |
7 | 10 | </div> |
8 | 11 | |
9 | 12 | <input type="hidden" name="question_ref" value="{{ question['ref'] }}"> | ... | ... |