Commit 31affef27ddc4192d9ad96ae6c42e570cb0ee962

Authored by Miguel Barão
1 parent 4f91192c
Exists in master and in 1 other branch dev

- reload page no longer regenerate questions for the topic (students were abusing it...)

Showing 3 changed files with 8 additions and 1 deletions   Show diff stats
BUGS.md
... ... @@ -29,6 +29,7 @@
29 29  
30 30 # FIXED
31 31  
  32 +- reload do topic não gera novas perguntas (alunos abusavam do reload)
32 33 - usar codemirror no textarea
33 34 - quando erra uma textarea, o comment fica na nova pergunta que se gera.
34 35 - arranjar os links para static/libs como no perguntations.
... ...
factory.py
... ... @@ -67,7 +67,7 @@ class QFactory(object):
67 67 # i.e. a question object (radio, checkbox, ...).
68 68 # -----------------------------------------------------------------------
69 69 def generate(self):
70   - logger.debug(f'Generating "{self.question["ref"]}"')
  70 + logger.debug(f'Generating "{self.question["ref"]}"...')
71 71 # Shallow copy so that script generated questions will not replace
72 72 # the original generators
73 73 q = self.question.copy()
... ...
knowledge.py
... ... @@ -31,6 +31,8 @@ class StudentKnowledge(object):
31 31 self.topic_sequence = self.recommend_topic_sequence() # ['a', 'b', ...]
32 32 self.unlock_topics()
33 33  
  34 + self.current_topic = None
  35 +
34 36 self.MAX_QUESTIONS = 6 # FIXME get from configuration file??
35 37  
36 38 # ------------------------------------------------------------------------
... ... @@ -79,6 +81,9 @@ class StudentKnowledge(object):
79 81 if self.is_locked(topic):
80 82 return False
81 83  
  84 + if self.current_topic is not None and topic == self.current_topic:
  85 + return True
  86 +
82 87 self.current_topic = topic
83 88  
84 89 # generate question instances for current topic
... ... @@ -91,6 +96,7 @@ class StudentKnowledge(object):
91 96  
92 97 size = min(self.MAX_QUESTIONS, len(questionlist)) # number of questions
93 98 questionlist = random.sample(questionlist, k=size)
  99 + logger.debug(f'Questions: {", ".join(questionlist)}')
94 100  
95 101 self.questions = [factory[qref].generate() for qref in questionlist]
96 102 logger.debug(f'Total: {len(self.questions)} questions')
... ...