From 8548cb5b8d7e21f2046e1115a32844010a63fabe Mon Sep 17 00:00:00 2001 From: Miguel BarĂ£o Date: Sun, 2 Feb 2020 15:40:39 +0000 Subject: [PATCH] minor --- aprendizations/learnapp.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/aprendizations/learnapp.py b/aprendizations/learnapp.py index 5afa575..a974250 100644 --- a/aprendizations/learnapp.py +++ b/aprendizations/learnapp.py @@ -381,8 +381,11 @@ class LearnApp(object): def populate_graph(self, config: Dict[str, Any]) -> None: g = self.deps # dependency graph defaults = { - 'type': 'topic', - 'file': 'questions.yaml', + 'type': 'topic', # chapter + # 'file': 'questions.yaml', # deprecated + 'learn_file': 'learn.yaml', + 'practice_file': 'questions.yaml', + 'shuffle_questions': True, 'choose': 9999, 'forgetting_factor': 1.0, # no forgetting @@ -402,7 +405,7 @@ class LearnApp(object): t = g.nodes[tref] # get current topic node t['name'] = attr.get('name', tref) - t['questions'] = attr.get('questions', []) + t['questions'] = attr.get('questions', []) # FIXME unused?? for k, default in defaults.items(): t[k] = attr.get(k, default) @@ -438,9 +441,8 @@ class LearnApp(object): g = self.deps t = g.nodes[tref] # get node # load questions as list of dicts - topicpath: str = path.join(g.graph['prefix'], tref) try: - fullpath: str = path.join(topicpath, t['file']) + fullpath: str = path.join(t['path'], t['file']) except Exception: msg1 = f'Invalid topic "{tref}"' msg2 = f'Check dependencies of: {", ".join(g.successors(tref))}' @@ -457,6 +459,7 @@ class LearnApp(object): msg = f'Failed to load "{fullpath}"' logger.error(msg) raise LearnException(msg) + if not isinstance(questions, list): msg = f'File "{fullpath}" must be a list of questions' logger.error(msg) @@ -470,12 +473,12 @@ class LearnApp(object): for i, q in enumerate(questions): qref = q.get('ref', str(i)) # ref or number if qref in localrefs: - msg = f'Duplicate ref "{qref}" in "{topicpath}"' + msg = f'Duplicate ref "{qref}" in "{t["path"]}"' raise LearnException(msg) localrefs.add(qref) q['ref'] = f'{tref}:{qref}' - q['path'] = topicpath + q['path'] = t['path'] q.setdefault('append_wrong', t['append_wrong']) # if questions are left undefined, include all. -- libgit2 0.21.2