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