Persist attempts used across sessions#42
Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| if (mode === 'homework') { | ||
| updateProgress({ index: currentSentenceIndex, ok: isCorrect, revealed: false }); | ||
| if (isCorrect) { | ||
| updateProgress({ index: currentSentenceIndex, ok: true, revealed: false }); | ||
| } else { | ||
| const newAttempts = attemptsUsed + 1; | ||
| setAttemptsUsed(newAttempts); | ||
| if (progress && assignment) { | ||
| const storageKey = `ss::${assignment.id}::${studentName}`; | ||
| const newProgress = { ...progress, attemptsUsed: newAttempts }; | ||
| setProgress(newProgress); | ||
| saveProgress(storageKey, newProgress); | ||
| } | ||
| if (attemptsLimit !== null && newAttempts >= attemptsLimit) { | ||
| if (assignment?.options.revealAnswerAfterMaxAttempts) { | ||
| handleReveal(); | ||
| return; | ||
| } else { | ||
| updateProgress({ index: currentSentenceIndex, ok: false, revealed: false }); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| setFeedback({ |
There was a problem hiding this comment.
[P1] Record progress before showing Next after wrong attempt
When a homework item is answered incorrectly but the maximum attempts has not been reached, handleCheckAnswer increments attemptsUsed but never calls updateProgress. Despite that, the code still sets feedback, which switches the UI to the "Next" button. This lets a student advance to the next sentence without a Result being appended for the current one and without resetting the attempt counter, so progress summaries and the final results modal can miss sentences or carry attempts into subsequent items. Consider preventing navigation until a Result is recorded or resetting attempts when moving on.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Summary
- Added a
shouldShowFeedbackflag to delay displaying the Next button until progress is recorded, preventing students from advancing after an incorrect answer without logging a result components/GameApp.tsxL305-L350
Testing
- ✅
npm test - ✅
npm run build
Summary
Testing
npm testnpm run buildhttps://chatgpt.com/codex/tasks/task_e_68c821dac704832cbdd17782430440e7