Commit 8853130298aaa3ea3ec9e100ab4337c6d555b8e5

Authored by Miguel Barão
1 parent 2394fd9e
Exists in master and in 1 other branch dev

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 3 import random
4 4 from datetime import datetime
5 5 import logging
6   -import asyncio
7 6  
8 7 # third party libraries
9 8 import networkx as nx
... ... @@ -41,7 +40,7 @@ class StudentKnowledge(object):
41 40 now = datetime.now()
42 41 for tref, s in self.state.items():
43 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 46 # Unlock topics whose dependencies are satisfied (> min_level)
... ... @@ -72,12 +71,12 @@ class StudentKnowledge(object):
72 71  
73 72 if self.current_topic == topic:
74 73 logger.info('Restarting current topic is not allowed.')
75   - return False
  74 + return
76 75  
77 76 # do not allow locked topics
78 77 if self.is_locked(topic):
79 78 logger.debug(f'[start_topic] topic "{topic}" is locked')
80   - return False
  79 + return
81 80  
82 81 # starting new topic
83 82 self.current_topic = topic
... ... @@ -100,12 +99,12 @@ class StudentKnowledge(object):
100 99 self.questions = [await self.factory[ref].generate_async()
101 100 for ref in questions]
102 101  
  102 + n = len(self.questions)
  103 + logger.debug(f'[start_topic] generated {n} questions')
  104 +
103 105 # get first question
104 106 self.next_question()
105 107  
106   - logger.debug(f'[start_topic] generated {len(self.questions)} questions')
107   - return True
108   -
109 108 # ------------------------------------------------------------------------
110 109 # The topic has finished and there are no more questions.
111 110 # The topic level is updated in state and unlocks are performed.
... ...