generateGoal static method

String generateGoal(
  1. String topicTitle,
  2. Map<String, double> subtopicAccuracy
)

Generate a session micro-goal targeting the weakest subtopic area.

subtopicAccuracy maps subtopic names to their recent accuracy (0-1). Returns the weakest subtopic name, or a generic goal if no data.

Implementation

static String generateGoal(
  String topicTitle,
  Map<String, double> subtopicAccuracy,
) {
  if (subtopicAccuracy.isEmpty) {
    return 'Practice key concepts in $topicTitle';
  }

  // Find the subtopic with lowest accuracy.
  var weakest = subtopicAccuracy.entries.first;
  for (final entry in subtopicAccuracy.entries) {
    if (entry.value < weakest.value) weakest = entry;
  }

  return 'Focus on: ${weakest.key} (accuracy: ${(weakest.value * 100).round()}%)';
}