RoadTripMoustache / kana_to_kanji

Simple application to learn Japanese kana (hiragana, katakana) and kanji
5 stars 1 forks source link

feat: Implement KnowledgeLevel repository and memorizing algorithm #218

Open apomalyn opened 2 months ago

apomalyn commented 2 months ago

As a developer, I want a central place to interact with the knowledge-level and memorizing algorithm

Requirements

Implement a KnowledgeLevel model using Isar and freezed. The schema can be found on https://github.com/RoadTripMoustache/kana_to_kanji_api/issues/15

Implement an enum LearningMode with the following:

Implement a KnowledgeRepository that:

Learning mode

Update the UI:

Learning order system

The learning order system determines in which order we need to learn the resources. It's divided into two parts:

The stages and levels will be built based on the JLPT. It will introduce resources from the same JLPT level and some resources from other JLPT levels.

Rules

Determine the next element to review or learn

The method should:

In general, follow this:

  1. retrieve from the database, the resource to review before tomorrow (KnowledgeLevel.next_review) limited to the learning order system
  2. Learning mode:
    • LearningMode.learn: complete with new elements from either restrain or the learning level system
    • LearningMode.review:
      • if restrain is provided go to 3., otherwise complete with any resource to review before tomorrow (including the entire KnowledgeLevel table)
  3. complete with resource ordered by additional_review_before_next_review ASC and next_review ASC, limited to restrain if provided
Flow diagram for the selection of the next elements to review or learn ![Diagrams drawio](https://github.com/RoadTripMoustache/kana_to_kanji/assets/22211097/5997565b-556c-4695-812f-29d05219ba49)

Update KnowledgeLevel

Before updating the KnowledgeLevel.gap and dates, if the current day is review day (today = next_review excluding time):

To calculate the new KnowledgeLevel.gap use the following:

new_gap = gap + (gap * memorization_coefficient * mitigation_coefficient ^ (additional_review_before_next_review))

Update KnowledgeLevel.gap and next_review based on new_cap.

Coefficients:

A resource knowledge level is considered:

Dependencies

Child of #160

Depends on:

Parent of:

Dev notes