Generate personalized AI lesson plans for individual EduBot students. Analyzes a student's profile, topic mastery, mental model (misconceptions/gaps), and spaced repetition stats from D1, then creates a structured lesson plan with progressive difficulty. Use this whenever: creating lesson content for a specific student, designing study material based on weakness analysis, building a custom learning path, or when someone says 'make a lesson for student X' or 'what should this student learn next'.
You create personalized, data-driven lesson plans for EduBot students by analyzing their real performance data from the D1 database, then generating targeted lesson content.
Generic lesson plans waste students' time on things they already know and skip things they don't. This skill pulls actual data — what concepts the student has misconceptions about, where their accuracy is low, which topics they haven't started — and builds a plan that attacks their specific weaknesses in the right order (prerequisites first).
Query the D1 database (ID: d501b671-128e-4a45-9d90-74b22e6691ce) to build a complete picture:
-- Student profile + preferences
SELECT u.id, u.name, u.target_test, u.proficiency_level,
sp.learning_style, sp.communication_style, sp.depth_level,
sp.target_band_score, sp.study_goal, sp.confidence_score,
sp.frustration_score, sp.learning_pace, sp.consecutive_correct,
sp.longest_correct_streak, sp.total_tutor_messages
FROM users u
LEFT JOIN student_profiles sp ON u.id = sp.user_id
WHERE u.id = ?
-- Topic mastery — what they know and don't know
SELECT topic, mastery_level, exercises_attempted, exercises_correct,
accuracy_percent, current_difficulty, status
FROM topic_mastery WHERE user_id = ?
ORDER BY accuracy_percent ASC
-- Mental model — misconceptions and knowledge gaps
SELECT concept, believed_understanding, misconceptions, confidence, times_assessed
FROM student_mental_model WHERE user_id = ?
ORDER BY believed_understanding ASC
-- Recent performance (last 7 days)
SELECT section, COUNT(*) as total,
SUM(CASE WHEN is_correct = 1 THEN 1 ELSE 0 END) as correct
FROM attempt_answers aa
JOIN test_attempts ta ON aa.attempt_id = ta.id
WHERE ta.user_id = ? AND aa.submitted_at >= datetime('now', '-7 days')
AND aa.is_correct IS NOT NULL
GROUP BY section
-- Spaced repetition stats
SELECT COUNT(*) as total_items,
SUM(CASE WHEN next_review_at <= datetime('now') THEN 1 ELSE 0 END) as due_now
FROM spaced_repetition WHERE user_id = ?
Rank what to teach using this priority system:
Before teaching an advanced concept, verify prerequisites are met. The dependency tree:
If a prerequisite is weak, teach that first.
Structure the plan as 4-7 steps with progressive difficulty:
Step Types:
explanation — Socratic discovery: start with a question, give 3 examples, let them find the patternexercise — Progressive difficulty drill: easy → medium → hardquiz — Timed challenge covering multiple skills (gamified)discussion — Real-life application scenarioreflection — Key takeaways and what to practice nextAdapt to Student Preferences:
Insert the plan into the lesson_plans table:
INSERT INTO lesson_plans (user_id, title, description, plan_type, target_skills, lessons, current_step, total_steps, status, difficulty_level, estimated_minutes, progress_percent, generated_by)
VALUES (?, ?, ?, 'personalized', ?, ?, 0, ?, 'active', ?, ?, 0, 'ai')
target_skills: JSON array of skill identifierslessons: JSON array of lesson step objects with fields: index, type, title, content, skill, difficulty, expected_minutesPresent the lesson plan to the user like this:
## Lesson Plan: [Student Name] — [Title]
**Target:** [test type] | **Level:** [depth] | **Est. time:** [X] min
### Why This Plan
[2-3 sentences explaining why these specific topics were chosen based on the data]
### Steps
1. [icon] **[Title]** ([type], [X] min)
Focus: [skill] | Difficulty: [1-5]
[Brief description of what happens in this step]
2. ...
### Data Behind This Plan
- Weakest areas: [topics with accuracy]
- Misconceptions: [concepts]
- Due for review: [count] items
- Streak: [current] (best: [longest])