Skip to content

Commit 2105eef

Browse files
committed
Add debug logging to generateFeedback function
- Add detailed logging to track answer validation process - Log userAnswer, correctAnswerKey, options, and comparison results - This will help identify why correct answers are being marked as incorrect
1 parent 46f9c1a commit 2105eef

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

app/actions/progress.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ const generateFeedback = (
157157
const correctAnswerKey = fullQuizData.correctAnswer as keyof typeof fullQuizData.options | null;
158158
const allExplanations = fullQuizData.allExplanations;
159159
const options = fullQuizData.options;
160+
161+
// Debug logging to identify the issue
162+
console.log('[generateFeedback] Debug info:', {
163+
userAnswer,
164+
correctAnswerKey,
165+
options,
166+
allExplanations: allExplanations ? Object.keys(allExplanations) : null,
167+
userAnswerInOptions: typeof userAnswer === 'string' ? userAnswer in options : false,
168+
correctAnswerKeyExists: !!correctAnswerKey,
169+
allExplanationsExists: !!allExplanations,
170+
});
171+
160172
if (
161173
typeof userAnswer === 'string' &&
162174
userAnswer in options &&
@@ -165,6 +177,15 @@ const generateFeedback = (
165177
) {
166178
const chosenAnswerKey = userAnswer as keyof typeof options;
167179
const isCorrect = chosenAnswerKey === correctAnswerKey;
180+
181+
console.log('[generateFeedback] Comparison:', {
182+
chosenAnswerKey,
183+
correctAnswerKey,
184+
isCorrect,
185+
chosenAnswerText: options[chosenAnswerKey],
186+
correctAnswerText: options[correctAnswerKey],
187+
});
188+
168189
const correctExplanation = allExplanations[correctAnswerKey];
169190
const relevantText = fullQuizData.relevantText;
170191
let chosenIncorrectExplanation: string | undefined | null = null;

0 commit comments

Comments
 (0)