Milestone.fromMasteryTransition constructor

Milestone.fromMasteryTransition({
  1. required DateTime date,
  2. required String topicTitle,
  3. required String mastery,
})

Pick a tone heuristically from the mastery transition. Higher levels read as "forest" (deep), evaluation reads as "plum", everything else falls back to "ochre" (the streak/retention voice).

Implementation

factory Milestone.fromMasteryTransition({
  required DateTime date,
  required String topicTitle,
  required String mastery,
}) {
  final level = masteryLevelFromString(mastery);
  final tone = switch (level) {
    5 => MilestoneTone.forest,
    4 => MilestoneTone.plum,
    _ => MilestoneTone.ochre,
  };
  return Milestone(
    date: date,
    title: switch (level) {
      5 => 'Reached Mastery',
      4 => 'Advanced to Evaluation',
      3 => 'Advanced to Application',
      2 => 'Advanced to Understanding',
      1 => 'Started: Awareness',
      _ => 'Started studying',
    },
    detail: topicTitle,
    tone: tone,
  );
}