Commit 8853130298aaa3ea3ec9e100ab4337c6d555b8e5
1 parent
2394fd9e
Exists in
master
and in
1 other branch
code cleaning in knowledge.py
Showing
1 changed file
with
6 additions
and
7 deletions
Show diff stats
aprendizations/knowledge.py
| @@ -3,7 +3,6 @@ | @@ -3,7 +3,6 @@ | ||
| 3 | import random | 3 | import random |
| 4 | from datetime import datetime | 4 | from datetime import datetime |
| 5 | import logging | 5 | import logging |
| 6 | -import asyncio | ||
| 7 | 6 | ||
| 8 | # third party libraries | 7 | # third party libraries |
| 9 | import networkx as nx | 8 | import networkx as nx |
| @@ -41,7 +40,7 @@ class StudentKnowledge(object): | @@ -41,7 +40,7 @@ class StudentKnowledge(object): | ||
| 41 | now = datetime.now() | 40 | now = datetime.now() |
| 42 | for tref, s in self.state.items(): | 41 | for tref, s in self.state.items(): |
| 43 | dt = now - s['date'] | 42 | dt = now - s['date'] |
| 44 | - s['level'] *= 0.98 ** dt.days # forgetting factor 0.95 FIXME | 43 | + s['level'] *= 0.98 ** dt.days # forgetting factor |
| 45 | 44 | ||
| 46 | # ------------------------------------------------------------------------ | 45 | # ------------------------------------------------------------------------ |
| 47 | # Unlock topics whose dependencies are satisfied (> min_level) | 46 | # Unlock topics whose dependencies are satisfied (> min_level) |
| @@ -72,12 +71,12 @@ class StudentKnowledge(object): | @@ -72,12 +71,12 @@ class StudentKnowledge(object): | ||
| 72 | 71 | ||
| 73 | if self.current_topic == topic: | 72 | if self.current_topic == topic: |
| 74 | logger.info('Restarting current topic is not allowed.') | 73 | logger.info('Restarting current topic is not allowed.') |
| 75 | - return False | 74 | + return |
| 76 | 75 | ||
| 77 | # do not allow locked topics | 76 | # do not allow locked topics |
| 78 | if self.is_locked(topic): | 77 | if self.is_locked(topic): |
| 79 | logger.debug(f'[start_topic] topic "{topic}" is locked') | 78 | logger.debug(f'[start_topic] topic "{topic}" is locked') |
| 80 | - return False | 79 | + return |
| 81 | 80 | ||
| 82 | # starting new topic | 81 | # starting new topic |
| 83 | self.current_topic = topic | 82 | self.current_topic = topic |
| @@ -100,12 +99,12 @@ class StudentKnowledge(object): | @@ -100,12 +99,12 @@ class StudentKnowledge(object): | ||
| 100 | self.questions = [await self.factory[ref].generate_async() | 99 | self.questions = [await self.factory[ref].generate_async() |
| 101 | for ref in questions] | 100 | for ref in questions] |
| 102 | 101 | ||
| 102 | + n = len(self.questions) | ||
| 103 | + logger.debug(f'[start_topic] generated {n} questions') | ||
| 104 | + | ||
| 103 | # get first question | 105 | # get first question |
| 104 | self.next_question() | 106 | self.next_question() |
| 105 | 107 | ||
| 106 | - logger.debug(f'[start_topic] generated {len(self.questions)} questions') | ||
| 107 | - return True | ||
| 108 | - | ||
| 109 | # ------------------------------------------------------------------------ | 108 | # ------------------------------------------------------------------------ |
| 110 | # The topic has finished and there are no more questions. | 109 | # The topic has finished and there are no more questions. |
| 111 | # The topic level is updated in state and unlocks are performed. | 110 | # The topic level is updated in state and unlocks are performed. |