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 | 135 | logger.debug('StudentKnowledge.check_answer()') |
136 | 136 | |
137 | 137 | q = self.current_question |
138 | + ref = q['ref'] | |
138 | 139 | |
139 | 140 | q['answer'] = answer |
140 | 141 | q['finish_time'] = datetime.now() |
... | ... | @@ -153,14 +154,14 @@ class StudentKnowledge(object): |
153 | 154 | else: |
154 | 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 | 158 | else: |
158 | 159 | self.wrong_answers += 1 |
159 | 160 | factory = self.deps.node[self.current_topic]['factory'] |
160 | 161 | self.questions.append(factory[q['ref']].generate()) |
161 | 162 | |
162 | 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 | 106 | # ------------------------------------------------------------------------ |
107 | 107 | def check_answer(self, uid, answer): |
108 | 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 | 112 | if knowledge.get_current_question() is None: |
112 | 113 | # finished topic, save into database |
... | ... | @@ -144,6 +145,7 @@ class LearnApp(object): |
144 | 145 | topic_id=finished_topic) |
145 | 146 | for q in finished_questions]) |
146 | 147 | logger.debug(f'Saved {len(finished_questions)} answers into database') |
148 | + | |
147 | 149 | return grade |
148 | 150 | |
149 | 151 | # ------------------------------------------------------------------------ |
... | ... | @@ -159,7 +161,7 @@ class LearnApp(object): |
159 | 161 | if ok: |
160 | 162 | logger.info(f'User "{uid}" started "{topic}"') |
161 | 163 | else: |
162 | - logger.warning(f'User "{uid}" denied locked "{topic}"') | |
164 | + logger.warning(f'User "{uid}" restarted "{topic}"') | |
163 | 165 | return ok |
164 | 166 | |
165 | 167 | # ------------------------------------------------------------------------ | ... | ... |