Enhance Spaced Repetition Algorithm with SM-2 Implementation
Description
The current spaced repetition system in src/components/study/StudyMode.tsx uses a basic implementation that updates nextReview dates based on difficulty ratings. This should be enhanced with a proper SM-2 algorithm for more effective learning scheduling.
Current Implementation
In StudyMode.tsx, the difficulty tracking updates the flashcard's nextReview field, but:
- The interval calculation is basic (not following SM-2 formula)
repetitions count is not properly utilized
- No ease factor tracking
- Failed cards are not rescheduled optimally
What Needs to Be Done
1. Implement SM-2 Algorithm
Create a utility at src/lib/utils/spaced-repetition.ts:
- Calculate intervals based on: quality (0-5), repetitions, ease factor
- Formula:
interval = previousInterval * easeFactor
- Ease factor adjustment based on response quality
- Reset to interval 1 on failure
2. Update Database Schema
Add to Prisma Flashcard model:
easeFactor (Float, default 2.5)
interval (Int, default 0)
- Update
repetitions usage
3. Update Study Mode
- Apply SM-2 calculations when user rates difficulty
- Show next review date to user
- Add "Due for Review" filter to deck view
- Display mastery level per card (based on ease factor)
4. Study Analytics
- Track study streaks
- Show retention rate over time
- Daily review count vs. due cards
- Export study statistics
Files to Create/Modify
- Create:
src/lib/utils/spaced-repetition.ts — SM-2 algorithm
- Modify:
prisma/schema.prisma — Add easeFactor, interval fields
- Modify:
src/components/study/StudyMode.tsx — Apply SM-2
- Modify:
src/app/api/study/record/route.ts — Store SM-2 data
Acceptance Criteria
Enhance Spaced Repetition Algorithm with SM-2 Implementation
Description
The current spaced repetition system in
src/components/study/StudyMode.tsxuses a basic implementation that updatesnextReviewdates based on difficulty ratings. This should be enhanced with a proper SM-2 algorithm for more effective learning scheduling.Current Implementation
In
StudyMode.tsx, the difficulty tracking updates the flashcard'snextReviewfield, but:repetitionscount is not properly utilizedWhat Needs to Be Done
1. Implement SM-2 Algorithm
Create a utility at
src/lib/utils/spaced-repetition.ts:interval = previousInterval * easeFactor2. Update Database Schema
Add to Prisma
Flashcardmodel:easeFactor(Float, default 2.5)interval(Int, default 0)repetitionsusage3. Update Study Mode
4. Study Analytics
Files to Create/Modify
src/lib/utils/spaced-repetition.ts— SM-2 algorithmprisma/schema.prisma— Add easeFactor, interval fieldssrc/components/study/StudyMode.tsx— Apply SM-2src/app/api/study/record/route.ts— Store SM-2 dataAcceptance Criteria