feat: expand progress tracking types#38
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".
| return `Homework: ${assignment.title} (v${assignment.version}) | ||
| Student: ${student.name || 'N/A'} | ||
| Result: ${score} correct (${summary.reveals} reveals) | ||
| Result: ${score} solved (${summary.reveals} reveals, ${summary.firstTry} first try, avg ${summary.avgAttempts.toFixed(2)} attempts) |
There was a problem hiding this comment.
[P1] Handle missing avgAttempts when rendering legacy progress
Existing homework progress in localStorage was saved with the old summary shape ({correct, total, reveals}) and does not include the new avgAttempts field. loadProgress returns that JSON verbatim, so when a learner completes an old assignment and the results modal tries to render, summary.avgAttempts is undefined and calling toFixed(2) throws. Users who upgrade with saved progress will hit a runtime error as soon as the modal or share text is constructed. Consider defaulting these new fields when loading or guarding the formatting.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Summary
- Normalize legacy progress data by supplying defaults for newly added summary metrics such as
solvedWithinMaxandavgAttemptsduringloadProgress, ensuring backward compatibility utils/storage.tsL11-L29 - Prevent runtime errors when sharing results by falling back to
0before formattingavgAttemptswithtoFixedcomponents/ResultsModal.tsxL25-L31 - Add regression test confirming that
loadProgressupgrades legacy summaries to the new shape utils/tests/storage.test.tsL69-L92
Testing
- ✅
npm test - ✅
npm run build
Summary
Testing
npm testnpm run buildhttps://chatgpt.com/codex/tasks/task_e_68c821d6a338832c949b2b513b2cfd5e