Commit 80851f815e8db51c175048fa43ac7a99d110b6e2

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

- calculate stars based on the number of correct/wrong answers

Showing 2 changed files with 11 additions and 4 deletions   Show diff stats
1 1
2 BUGS: 2 BUGS:
3 3
  4 +- level depender do numero de respostas correctas
4 - pymips: activar/desactivar instruções 5 - pymips: activar/desactivar instruções
5 - tabs em textarea nao funcionam correctamente (insere 1 espaco em vez de 4) 6 - tabs em textarea nao funcionam correctamente (insere 1 espaco em vez de 4)
6 - reportar comentarios após submeter. 7 - reportar comentarios após submeter.
@@ -32,7 +32,7 @@ class Knowledge(object): @@ -32,7 +32,7 @@ class Knowledge(object):
32 if topic is None: 32 if topic is None:
33 # select the first topic that has level < 0.9 33 # select the first topic that has level < 0.9
34 for topic in self.topic_sequence: 34 for topic in self.topic_sequence:
35 - if topic not in self.state or self.state[topic]['level'] < 0.9: 35 + if topic not in self.state or self.state[topic]['level'] < 0.8:
36 break 36 break
37 logger.debug(f'Student {self.student}: new_topic({topic})') 37 logger.debug(f'Student {self.student}: new_topic({topic})')
38 38
@@ -42,6 +42,8 @@ class Knowledge(object): @@ -42,6 +42,8 @@ class Knowledge(object):
42 self.questions = self.generate_questions_for_topic(topic) 42 self.questions = self.generate_questions_for_topic(topic)
43 self.current_question = None 43 self.current_question = None
44 self.finished_questions = [] 44 self.finished_questions = []
  45 + self.correct_answers = 1
  46 + self.wrong_answers = 0
45 47
46 # ------------------------------------------------------------------------ 48 # ------------------------------------------------------------------------
47 def generate_questions_for_topic(self, topic): 49 def generate_questions_for_topic(self, topic):
@@ -85,7 +87,7 @@ class Knowledge(object): @@ -85,7 +87,7 @@ class Knowledge(object):
85 # keep going if there are no questions in the next topics 87 # keep going if there are no questions in the next topics
86 while not self.questions: 88 while not self.questions:
87 self.state[self.current_topic] = { 89 self.state[self.current_topic] = {
88 - 'level': 1.0, # FIXME depends on how many are correct 90 + 'level': self.correct_answers / (self.correct_answers + self.wrong_answers),
89 'date': datetime.now() 91 'date': datetime.now()
90 } 92 }
91 self.new_topic() 93 self.new_topic()
@@ -103,8 +105,12 @@ class Knowledge(object): @@ -103,8 +105,12 @@ class Knowledge(object):
103 question = self.current_question 105 question = self.current_question
104 if question is not None: 106 if question is not None:
105 question['finish_time'] = datetime.now() 107 question['finish_time'] = datetime.now()
106 - question.correct(answer) 108 + grade = question.correct(answer)
  109 + if grade > 0.9:
  110 + self.correct_answers += 1
  111 + else:
  112 + self.wrong_answers +=1
107 113
108 - logger.debug(f'Student {self.student}: check_answer({answer}) = {question["grade"]}') 114 + logger.debug(f'Student {self.student}: check_answer({answer}) = {grade}')
109 115
110 return question 116 return question