Commit c6d6055cf314468d3a2ac71d9ef5068bbfa561dc
1 parent
31affef2
Exists in
master
and in
1 other branch
- show question grades in logs
Showing
2 changed files
with
7 additions
and
4 deletions
Show diff stats
knowledge.py
| @@ -135,6 +135,7 @@ class StudentKnowledge(object): | @@ -135,6 +135,7 @@ class StudentKnowledge(object): | ||
| 135 | logger.debug('StudentKnowledge.check_answer()') | 135 | logger.debug('StudentKnowledge.check_answer()') |
| 136 | 136 | ||
| 137 | q = self.current_question | 137 | q = self.current_question |
| 138 | + ref = q['ref'] | ||
| 138 | 139 | ||
| 139 | q['answer'] = answer | 140 | q['answer'] = answer |
| 140 | q['finish_time'] = datetime.now() | 141 | q['finish_time'] = datetime.now() |
| @@ -153,14 +154,14 @@ class StudentKnowledge(object): | @@ -153,14 +154,14 @@ class StudentKnowledge(object): | ||
| 153 | else: | 154 | else: |
| 154 | self.current_question['start_time'] = datetime.now() | 155 | self.current_question['start_time'] = datetime.now() |
| 155 | 156 | ||
| 156 | - # if answer is wrong, keep same question and add a similar one at the end | 157 | + # if wrong, keep same question and append a similar one at the end |
| 157 | else: | 158 | else: |
| 158 | self.wrong_answers += 1 | 159 | self.wrong_answers += 1 |
| 159 | factory = self.deps.node[self.current_topic]['factory'] | 160 | factory = self.deps.node[self.current_topic]['factory'] |
| 160 | self.questions.append(factory[q['ref']].generate()) | 161 | self.questions.append(factory[q['ref']].generate()) |
| 161 | 162 | ||
| 162 | # returns answered and corrected question | 163 | # returns answered and corrected question |
| 163 | - return grade | 164 | + return ref, grade |
| 164 | 165 | ||
| 165 | 166 | ||
| 166 | # ======================================================================== | 167 | # ======================================================================== |
learnapp.py
| @@ -106,7 +106,8 @@ class LearnApp(object): | @@ -106,7 +106,8 @@ class LearnApp(object): | ||
| 106 | # ------------------------------------------------------------------------ | 106 | # ------------------------------------------------------------------------ |
| 107 | def check_answer(self, uid, answer): | 107 | def check_answer(self, uid, answer): |
| 108 | knowledge = self.online[uid]['state'] | 108 | knowledge = self.online[uid]['state'] |
| 109 | - grade = knowledge.check_answer(answer) # also moves to next question | 109 | + ref, grade = knowledge.check_answer(answer) # also moves to next question |
| 110 | + logger.info(f'User "{uid}" got {grade:.2} in question "{ref}"') | ||
| 110 | 111 | ||
| 111 | if knowledge.get_current_question() is None: | 112 | if knowledge.get_current_question() is None: |
| 112 | # finished topic, save into database | 113 | # finished topic, save into database |
| @@ -144,6 +145,7 @@ class LearnApp(object): | @@ -144,6 +145,7 @@ class LearnApp(object): | ||
| 144 | topic_id=finished_topic) | 145 | topic_id=finished_topic) |
| 145 | for q in finished_questions]) | 146 | for q in finished_questions]) |
| 146 | logger.debug(f'Saved {len(finished_questions)} answers into database') | 147 | logger.debug(f'Saved {len(finished_questions)} answers into database') |
| 148 | + | ||
| 147 | return grade | 149 | return grade |
| 148 | 150 | ||
| 149 | # ------------------------------------------------------------------------ | 151 | # ------------------------------------------------------------------------ |
| @@ -159,7 +161,7 @@ class LearnApp(object): | @@ -159,7 +161,7 @@ class LearnApp(object): | ||
| 159 | if ok: | 161 | if ok: |
| 160 | logger.info(f'User "{uid}" started "{topic}"') | 162 | logger.info(f'User "{uid}" started "{topic}"') |
| 161 | else: | 163 | else: |
| 162 | - logger.warning(f'User "{uid}" denied locked "{topic}"') | 164 | + logger.warning(f'User "{uid}" restarted "{topic}"') |
| 163 | return ok | 165 | return ok |
| 164 | 166 | ||
| 165 | # ------------------------------------------------------------------------ | 167 | # ------------------------------------------------------------------------ |