Skip to content

[Feature]: Implement Spaced Repetition System (SRS) Algorithm for Flashcard Reviews #53

@diyamajee-spec

Description

@diyamajee-spec

🚀 Problem Statement

EduFlow-AI supports flashcard generation, but currently, flashcards are presented in a linear, static format. Cognitive science shows that linear studying is highly inefficient for long-term memory retention. Students end up wasting time reviewing concepts they already know while neglecting the topics they struggle with.

💡 Proposed Solution

Implement a Spaced Repetition System (SRS)—similar to the SuperMemo-2 (SM-2) algorithm used by Anki. This algorithm will track the user's performance on individual flashcards and calculate the optimal future date for them to review that specific card again.

When a student flips a flashcard, they should be presented with self-assessment buttons:

  • 🔴 Again (Forgot it, review very soon)
  • 🟠 Hard (Remembered, but it took significant effort)
  • 🟢 Good (Remembered easily)
  • 🔵 Easy (Too easy, push review date far into the future)

🛠 Proposed Technical Implementation

  1. Database Schema Update (Supabase):
  • Alter the existing flashcards table (or create a tracking table) to include:
    • repetition_count (Integer)
    • easiness_factor (Float, default 2.5)
    • interval (Integer, days until next review)
    • next_review_date (Timestamp)
  1. Algorithm Implementation:
  • Create a utility file src/utils/srsAlgorithm.tscontaining the mathematical logic to calculate the next interval based on the chosen quality rating (0-5 scale).
  1. UI/UX Updates:
    • Add the feedback rating buttons to the active <Flashcard /> component state.
  • Create a specialized "Daily Review" widget on the dashboard that queries Supabase exclusively for flashcards where``.

Code Example Concept:

// Conceptual SM-2 Logic Implementation
export const calculateSRS = (quality: number, ef: number, rep: number, interval: number) => {
  let newEf = ef + (0.1 - (5 - quality) * (0.08 + (5 - quality) * 0.02));
  if (newEf < 1.3) newEf = 1.3;
  
  let newInterval = 1;
  let newRep = rep;

  if (quality < 3) {
    newRep = 0;
    newInterval = 1;
  } else {
    newRep += 1;
    if (rep === 0) newInterval = 1;
    else if (rep === 1) newInterval = 6;
    else newInterval = Math.round(interval * newEf);
  }
  
  return { newEf, newInterval, newRep };
};

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions