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