Commit 8548cb5b8d7e21f2046e1115a32844010a63fabe
1 parent
a353168e
Exists in
master
and in
1 other branch
minor
Showing
1 changed file
with
10 additions
and
7 deletions
Show diff stats
aprendizations/learnapp.py
@@ -381,8 +381,11 @@ class LearnApp(object): | @@ -381,8 +381,11 @@ class LearnApp(object): | ||
381 | def populate_graph(self, config: Dict[str, Any]) -> None: | 381 | def populate_graph(self, config: Dict[str, Any]) -> None: |
382 | g = self.deps # dependency graph | 382 | g = self.deps # dependency graph |
383 | defaults = { | 383 | defaults = { |
384 | - 'type': 'topic', | ||
385 | - 'file': 'questions.yaml', | 384 | + 'type': 'topic', # chapter |
385 | + # 'file': 'questions.yaml', # deprecated | ||
386 | + 'learn_file': 'learn.yaml', | ||
387 | + 'practice_file': 'questions.yaml', | ||
388 | + | ||
386 | 'shuffle_questions': True, | 389 | 'shuffle_questions': True, |
387 | 'choose': 9999, | 390 | 'choose': 9999, |
388 | 'forgetting_factor': 1.0, # no forgetting | 391 | 'forgetting_factor': 1.0, # no forgetting |
@@ -402,7 +405,7 @@ class LearnApp(object): | @@ -402,7 +405,7 @@ class LearnApp(object): | ||
402 | 405 | ||
403 | t = g.nodes[tref] # get current topic node | 406 | t = g.nodes[tref] # get current topic node |
404 | t['name'] = attr.get('name', tref) | 407 | t['name'] = attr.get('name', tref) |
405 | - t['questions'] = attr.get('questions', []) | 408 | + t['questions'] = attr.get('questions', []) # FIXME unused?? |
406 | 409 | ||
407 | for k, default in defaults.items(): | 410 | for k, default in defaults.items(): |
408 | t[k] = attr.get(k, default) | 411 | t[k] = attr.get(k, default) |
@@ -438,9 +441,8 @@ class LearnApp(object): | @@ -438,9 +441,8 @@ class LearnApp(object): | ||
438 | g = self.deps | 441 | g = self.deps |
439 | t = g.nodes[tref] # get node | 442 | t = g.nodes[tref] # get node |
440 | # load questions as list of dicts | 443 | # load questions as list of dicts |
441 | - topicpath: str = path.join(g.graph['prefix'], tref) | ||
442 | try: | 444 | try: |
443 | - fullpath: str = path.join(topicpath, t['file']) | 445 | + fullpath: str = path.join(t['path'], t['file']) |
444 | except Exception: | 446 | except Exception: |
445 | msg1 = f'Invalid topic "{tref}"' | 447 | msg1 = f'Invalid topic "{tref}"' |
446 | msg2 = f'Check dependencies of: {", ".join(g.successors(tref))}' | 448 | msg2 = f'Check dependencies of: {", ".join(g.successors(tref))}' |
@@ -457,6 +459,7 @@ class LearnApp(object): | @@ -457,6 +459,7 @@ class LearnApp(object): | ||
457 | msg = f'Failed to load "{fullpath}"' | 459 | msg = f'Failed to load "{fullpath}"' |
458 | logger.error(msg) | 460 | logger.error(msg) |
459 | raise LearnException(msg) | 461 | raise LearnException(msg) |
462 | + | ||
460 | if not isinstance(questions, list): | 463 | if not isinstance(questions, list): |
461 | msg = f'File "{fullpath}" must be a list of questions' | 464 | msg = f'File "{fullpath}" must be a list of questions' |
462 | logger.error(msg) | 465 | logger.error(msg) |
@@ -470,12 +473,12 @@ class LearnApp(object): | @@ -470,12 +473,12 @@ class LearnApp(object): | ||
470 | for i, q in enumerate(questions): | 473 | for i, q in enumerate(questions): |
471 | qref = q.get('ref', str(i)) # ref or number | 474 | qref = q.get('ref', str(i)) # ref or number |
472 | if qref in localrefs: | 475 | if qref in localrefs: |
473 | - msg = f'Duplicate ref "{qref}" in "{topicpath}"' | 476 | + msg = f'Duplicate ref "{qref}" in "{t["path"]}"' |
474 | raise LearnException(msg) | 477 | raise LearnException(msg) |
475 | localrefs.add(qref) | 478 | localrefs.add(qref) |
476 | 479 | ||
477 | q['ref'] = f'{tref}:{qref}' | 480 | q['ref'] = f'{tref}:{qref}' |
478 | - q['path'] = topicpath | 481 | + q['path'] = t['path'] |
479 | q.setdefault('append_wrong', t['append_wrong']) | 482 | q.setdefault('append_wrong', t['append_wrong']) |
480 | 483 | ||
481 | # if questions are left undefined, include all. | 484 | # if questions are left undefined, include all. |