From 31affef27ddc4192d9ad96ae6c42e570cb0ee962 Mon Sep 17 00:00:00 2001 From: Miguel Barão Date: Wed, 2 May 2018 19:18:31 +0100 Subject: [PATCH] - reload page no longer regenerate questions for the topic (students were abusing it...) --- BUGS.md | 1 + factory.py | 2 +- knowledge.py | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/BUGS.md b/BUGS.md index 08fa941..7a28db0 100644 --- a/BUGS.md +++ b/BUGS.md @@ -29,6 +29,7 @@ # FIXED +- reload do topic não gera novas perguntas (alunos abusavam do reload) - usar codemirror no textarea - quando erra uma textarea, o comment fica na nova pergunta que se gera. - arranjar os links para static/libs como no perguntations. diff --git a/factory.py b/factory.py index 2ea3ba2..7097753 100644 --- a/factory.py +++ b/factory.py @@ -67,7 +67,7 @@ class QFactory(object): # i.e. a question object (radio, checkbox, ...). # ----------------------------------------------------------------------- def generate(self): - logger.debug(f'Generating "{self.question["ref"]}"') + logger.debug(f'Generating "{self.question["ref"]}"...') # Shallow copy so that script generated questions will not replace # the original generators q = self.question.copy() diff --git a/knowledge.py b/knowledge.py index 6f35c51..19b4c06 100644 --- a/knowledge.py +++ b/knowledge.py @@ -31,6 +31,8 @@ class StudentKnowledge(object): self.topic_sequence = self.recommend_topic_sequence() # ['a', 'b', ...] self.unlock_topics() + self.current_topic = None + self.MAX_QUESTIONS = 6 # FIXME get from configuration file?? # ------------------------------------------------------------------------ @@ -79,6 +81,9 @@ class StudentKnowledge(object): if self.is_locked(topic): return False + if self.current_topic is not None and topic == self.current_topic: + return True + self.current_topic = topic # generate question instances for current topic @@ -91,6 +96,7 @@ class StudentKnowledge(object): size = min(self.MAX_QUESTIONS, len(questionlist)) # number of questions questionlist = random.sample(questionlist, k=size) + logger.debug(f'Questions: {", ".join(questionlist)}') self.questions = [factory[qref].generate() for qref in questionlist] logger.debug(f'Total: {len(self.questions)} questions') -- libgit2 0.21.2