AI Educational Materials Generation System
AI system generates structured educational materials: lecture notes, presentations, worksheets, glossaries, case studies. Used in EdTech platforms, corporate training, schools and universities to scale content production.
Course Generator from Topic
from openai import AsyncOpenAI
from dataclasses import dataclass
client = AsyncOpenAI()
@dataclass
class CourseStructure:
title: str
target_audience: str
learning_objectives: list[str]
modules: list[dict] # [{title, topics, exercises, duration_min}]
assessment: dict
prerequisites: list[str]
async def generate_course_structure(
topic: str,
level: str, # beginner, intermediate, advanced
duration_hours: int = 10,
audience: str = ""
) -> CourseStructure:
response = await client.chat.completions.create(
model="gpt-4o",
messages=[{
"role": "system",
"content": f"""You are an online education methodologist.
Create course structure with Bloom's taxonomy for each objective.
Level: {level}.
Duration: {duration_hours} hours.
Break into modules of 1-2 hours.
For each module: topic, subtopics, hands-on tasks, control questions.
Return JSON."""
}, {
"role": "user",
"content": f"Topic: {topic}\nTarget audience: {audience or 'not specified'}"
}],
response_format={"type": "json_object"}
)
data = json.loads(response.choices[0].message.content)
return CourseStructure(**data)
Module Content Generation
async def generate_lesson_content(
module_title: str,
topics: list[str],
level: str,
include_examples: bool = True,
include_exercises: bool = True
) -> dict:
response = await client.chat.completions.create(
model="gpt-4o",
messages=[{
"role": "system",
"content": f"""Write educational module material.
Level: {level}.
Markdown structure:
- ## Introduction (why topic matters)
- ## Theory (H3 for each subtopic)
- {'## Examples (real use cases)' if include_examples else ''}
- {'## Exercises (hands-on tasks with solutions)' if include_exercises else ''}
- ## Key Takeaways (bullet list)
- ## Control Questions (5 questions with answers)
Style: clear, concrete, no filler."""
}, {
"role": "user",
"content": f"Module: {module_title}\nTopics: {', '.join(topics)}"
}]
)
return {
"content": response.choices[0].message.content,
"format": "markdown"
}
Worksheet and Test Generation
async def generate_worksheet(
topic: str,
exercise_types: list[str], # multiple_choice, fill_blank, open_question, case_study
difficulty: str = "medium",
num_exercises: int = 10
) -> dict:
response = await client.chat.completions.create(
model="gpt-4o",
messages=[{
"role": "system",
"content": f"""Create practice worksheet for topic reinforcement.
Exercise types: {', '.join(exercise_types)}.
Difficulty: {difficulty}.
Number of exercises: {num_exercises}.
For each exercise specify: correct answer and explanation.
Return JSON: {{exercises: [{{type, question, options, answer, explanation}}]}}"""
}, {
"role": "user",
"content": f"Topic: {topic}"
}],
response_format={"type": "json_object"}
)
return json.loads(response.choices[0].message.content)
Adaptive Material Personalization
async def adapt_material_for_learner(
base_material: str,
learner_profile: dict # {level, background, learning_style, mistakes_made}
) -> str:
response = await client.chat.completions.create(
model="gpt-4o",
messages=[{
"role": "system",
"content": f"""Adapt educational material for specific learner.
Profile: {json.dumps(learner_profile, ensure_ascii=False)}.
- Simplify concepts causing difficulty
- Add examples from familiar domain
- Emphasize areas with previous errors"""
}, {
"role": "user",
"content": base_material
}]
)
return response.choices[0].message.content
Timeline: course structure + module content generator — 2–3 weeks. Platform with personalization, progress tracking and adaptive tests — 2–3 months.







