Product design

Anki: recall the answer, then decide when to review it again

Anki separates review into recall, reveal, and self-assessment. Its four buttons do more than finish a question: they pass the difficulty of this recall to future scheduling. The design depends on honest feedback.

Break down the problem and try your own design and implementation first. Then explore the reasoning to check states, edge cases, trade-offs, and ways to test your approach. The guide offers a reasoning path, not a complete implementation.

01
CODE EXERCISE

Record one rating per review attempt

Implement a review module for a local flashcard trainer. Card A asks for the Chinese word for “apple”; its answer is “苹果.” The caller can start a review attempt, read the current content, reveal the answer, and submit one of Again, Hard, Good, or Easy. Initially only the question is shown; revealing adds the answer. Each attempt accepts only one successful rating.

  1. The module receives an external scheduling function. Given the card ID and rating, it returns the next review time. Call it only for a valid submission and save one record containing the ID, rating, and returned time. Reject submissions before reveal or after a successful submission, leaving existing records unchanged. Choose your own interface and state representation.
  2. Use a test scheduler that returns “tomorrow” for A with Good. Submitting Good immediately after starting must be rejected, with 0 scheduler calls. Reveal and submit: it succeeds and records A / Good / tomorrow. Submit Again: it is rejected and the call count remains 1. Starting a new attempt for A allows another normal submission.
  3. Deliver a runnable module, calls reproducing this sequence, and a brief explanation of the responsibility split. Operations are sequential and the scheduler always returns successfully. No real scheduling algorithm or storage is required.
Explore the reasoning

Decide what identifies a review attempt and what belongs to the card’s longer-term record. Do not confuse “rated this attempt” with “this card can never be rated again.” Keep submission eligibility in the module and delegate the next time to the supplied function. Use its call count to catch rejected operations reaching the scheduler.