From af9900456df1eafc14995eef385c5bd33fcd05f9 Mon Sep 17 00:00:00 2001 From: Miguel BarĂ£o Date: Tue, 30 Jan 2018 15:13:06 +0000 Subject: [PATCH] - added support for nodes of type 'chapter', that usually only have dependencies and an information "question". - fixed information and success "questions". --- knowledge.py | 3 ++- learnapp.py | 5 +++++ serve.py | 3 ++- templates/maintopics.html | 9 ++++++--- templates/question-information.html | 13 ++++++++++--- templates/question-success.html | 11 +++++++---- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/knowledge.py b/knowledge.py index 6a4e9ee..28d32c9 100644 --- a/knowledge.py +++ b/knowledge.py @@ -45,7 +45,7 @@ class StudentKnowledge(object): now = datetime.now() for s in self.state.values(): dt = now - s['date'] - s['level'] *= 0.8 ** dt.days # forgetting factor 0.95 + s['level'] *= 0.95 ** dt.days # forgetting factor 0.95 # ------------------------------------------------------------------------ @@ -178,6 +178,7 @@ class StudentKnowledge(object): def get_knowledge_state(self): return [{ 'ref': ref, + 'type': self.deps.nodes[ref]['type'], 'name': self.deps.nodes[ref]['name'], 'level': self.state[ref]['level'] if ref in self.state else None } for ref in self.topic_sequence ] diff --git a/learnapp.py b/learnapp.py index 7b331d1..9ed8e6a 100644 --- a/learnapp.py +++ b/learnapp.py @@ -246,6 +246,10 @@ class LearnApp(object): def get_topic_name(self, ref): return self.deps.node[ref]['name'] + # # ------------------------------------------------------------------------ + # def get_topic_type(self, ref): + # return self.deps.node[ref]['type'] + # ------------------------------------------------------------------------ def get_current_public_dir(self, uid): topic = self.online[uid]['state'].get_current_topic() @@ -287,6 +291,7 @@ def build_dependency_graph(config={}): tnode = g.node[ref] # current node (topic) if isinstance(attr, dict): + tnode['type'] = attr.get('type', 'topic') tnode['name'] = attr.get('name', ref) tnode['questions'] = attr.get('questions', []) g.add_edges_from((d,ref) for d in attr.get('deps', [])) diff --git a/serve.py b/serve.py index 3bca462..92e721d 100755 --- a/serve.py +++ b/serve.py @@ -117,7 +117,8 @@ class RootHandler(BaseHandler): uid=uid, name=self.learn.get_student_name(uid), state=self.learn.get_student_state(uid), - title=self.learn.get_title() + title=self.learn.get_title(), + # get_topic_type=self.learn.get_topic_type, # function ) # ---------------------------------------------------------------------------- diff --git a/templates/maintopics.html b/templates/maintopics.html index 650b562..b4d52a6 100644 --- a/templates/maintopics.html +++ b/templates/maintopics.html @@ -62,7 +62,7 @@

{{ title }}

-
+
{% for t in state %} {% if t['level'] is None %} @@ -83,12 +83,15 @@
{% if t['level'] < 0.01 %} - {% else %} + {% if t['type']=='chapter' %} + + {% else %} - {{ round(t['level']*5)*'' + round(5-t['level']*5)*'' }} + {{ round(t['level']*5)*'' + round(5-t['level']*5)*'' }} + {% end %} {% end %}
diff --git a/templates/question-information.html b/templates/question-information.html index dfe5221..5561b6d 100644 --- a/templates/question-information.html +++ b/templates/question-information.html @@ -1,5 +1,12 @@ -{% extends "question.html" %} +{% autoescape %} + +
+
+

{{ question['title'] }}

+

+ {{ md(question['text']) }} +

+
+
-{% block answer %} -{% end %} diff --git a/templates/question-success.html b/templates/question-success.html index df9fcfa..41c2be6 100644 --- a/templates/question-success.html +++ b/templates/question-success.html @@ -1,9 +1,12 @@ {% autoescape %} -

{{ question['title'] }}

- -