education-module-ai
v0.1.2
Published
AI Education Module using Agent Framework
Maintainers
Readme
Education Module for Agent Framework
This module provides educational content management, learning sessions, and user profile tracking for the Agent Framework.
Features
- Educational Content Management: Create, retrieve, and search educational content across various subjects and levels
- Learning Sessions: Interactive learning sessions with AI-powered responses and content recommendations
- User Profiles: Track user progress, learning styles, strengths, and weaknesses
- Analytics: Track usage patterns and learning progress
- Notifications: Send notifications for learning activities and achievements
- Reusable UI Components: Ready-to-use React components for quizzes, Q&A, and learning paths
Installation
npm install @agent-framework/education-moduleUsage
Backend Integration
import { initializeEducationAPI } from '@agent-framework/education-module';
// Initialize the education API
const app = await initializeEducationAPI();
// The API is now running with the following endpoints:
// - /api/educational-contents
// - /api/learning-sessions
// - /api/user-profilesFrontend Integration
Using Data Resources
import {
EducationalContentResource,
LearningSessionResource,
UserProfileResource
} from '@agent-framework/education-module';
// Fetch educational content
const fetchContent = async (subject) => {
const response = await fetch(`/api/educational-contents/subject/${subject}`);
const { data } = await response.json();
return data;
};
// Start a learning session
const startSession = async (userId, subject, level) => {
const response = await fetch('/api/learning-sessions/start', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ userId, subject, level }),
});
const { data } = await response.json();
return data;
};
// Send a message in a learning session
const sendMessage = async (sessionId, content) => {
const response = await fetch(`/api/learning-sessions/${sessionId}/message`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content }),
});
const { data } = await response.json();
return data;
};Using React Components
import React from 'react';
import {
QuizComponent,
AnswerQuestionComponent,
LearningPathComponent
} from '@agent-framework/education-module';
// In your React application
const EducationPage: React.FC = () => {
return (
<div className="education-container">
<h1>Education Portal</h1>
{/* Quiz Component */}
<QuizComponent
title="Computer Science Quiz"
description="Test your knowledge in computer science"
onComplete={(score) => console.log('Quiz completed with score:', score)}
/>
{/* Q&A Component */}
<AnswerQuestionComponent
title="Ask Your Questions"
onAnswer={(question, answer) => console.log('Question answered:', question)}
/>
{/* Learning Path Component */}
<LearningPathComponent
title="Generate Learning Path"
onGenerate={(path) => console.log('Learning path generated:', path)}
/>
</div>
);
};
export default EducationPage;UI Components
Quiz Component
The QuizComponent allows users to generate and take quizzes on any topic.
import { QuizComponent } from '@agent-framework/education-module';
<QuizComponent
title="Custom Quiz Title"
description="Custom description for this quiz generator"
onComplete={(score) => {
console.log(`Quiz completed with ${score.percentage}% correct`);
}}
className="custom-class-name"
/>Props
title: Optional custom title for the quiz componentdescription: Optional custom description textonComplete: Optional callback function that's called when a quiz is completedclassName: Optional CSS class name for styling
Answer Question Component
The AnswerQuestionComponent provides an interface for users to ask educational questions and get AI-powered answers.
import { AnswerQuestionComponent } from '@agent-framework/education-module';
<AnswerQuestionComponent
title="Custom Q&A Title"
description="Ask any question and get detailed answers"
onAnswer={(question, answer) => {
console.log(`Question: ${question}`);
console.log(`Answer: ${answer.answer}`);
}}
className="custom-class-name"
/>Props
title: Optional custom title for the Q&A componentdescription: Optional custom description textonAnswer: Optional callback function that's called when a question is answeredclassName: Optional CSS class name for styling
Learning Path Component
The LearningPathComponent generates personalized learning paths for any topic.
import { LearningPathComponent } from '@agent-framework/education-module';
<LearningPathComponent
title="Custom Learning Path Title"
description="Generate a personalized learning path for any topic"
onGenerate={(path) => {
console.log(`Learning path generated for: ${path.subject}`);
}}
className="custom-class-name"
/>Props
title: Optional custom title for the learning path componentdescription: Optional custom description textonGenerate: Optional callback function that's called when a learning path is generatedclassName: Optional CSS class name for styling
API Endpoints
Educational Content
GET /api/educational-contents: Get all educational contentGET /api/educational-contents/:id: Get content by IDPOST /api/educational-contents: Create new contentPUT /api/educational-contents/:id: Update contentDELETE /api/educational-contents/:id: Delete contentPOST /api/educational-contents/generate: Generate content using AIPOST /api/educational-contents/quiz: Generate a quizGET /api/educational-contents/search: Search for contentGET /api/educational-contents/subject/:subject: Get content by subjectGET /api/educational-contents/level/:level: Get content by level
Learning Sessions
GET /api/learning-sessions: Get all learning sessionsGET /api/learning-sessions/:id: Get session by IDPOST /api/learning-sessions/start: Start a new learning sessionPOST /api/learning-sessions/:id/end: End a learning sessionPOST /api/learning-sessions/:id/message: Send a message in a sessionGET /api/learning-sessions/user/:userId: Get all sessions for a userGET /api/learning-sessions/user/:userId/active: Get active session for a user
User Profiles
GET /api/user-profiles: Get all user profilesGET /api/user-profiles/:id: Get profile by IDPOST /api/user-profiles/initialize: Initialize a new user profilePUT /api/user-profiles/:id/learning-styles: Update learning stylesPOST /api/user-profiles/:id/subjects: Add a subject to user profileGET /api/user-profiles/:id/recommendations: Get learning recommendationsGET /api/user-profiles/:id/progress/:subject: Get subject progressPOST /api/user-profiles/:id/attributes: Add strength or weakness
Models
Educational Content
enum ContentType {
LESSON = "lesson",
EXERCISE = "exercise",
QUIZ = "quiz",
ARTICLE = "article",
VIDEO = "video",
INTERACTIVE = "interactive",
}
enum EducationalLevel {
BEGINNER = "beginner",
INTERMEDIATE = "intermediate",
ADVANCED = "advanced",
}
enum Subject {
MATHEMATICS = "mathematics",
SCIENCE = "science",
HISTORY = "history",
LANGUAGE_ARTS = "language_arts",
COMPUTER_SCIENCE = "computer_science",
ART = "art",
MUSIC = "music",
PHYSICAL_EDUCATION = "physical_education",
FOREIGN_LANGUAGE = "foreign_language",
}
interface EducationalContentResource {
id: string;
title: string;
description: string;
content: string;
type: ContentType;
subject: Subject;
level: EducationalLevel;
tags: string[];
createdAt: Date;
updatedAt: Date;
author?: string;
relatedContentIds?: string[];
}Learning Session
enum InteractionType {
QUESTION = "question",
ANSWER = "answer",
EXPLANATION = "explanation",
QUIZ_RESPONSE = "quiz_response",
FEEDBACK = "feedback",
}
interface SessionMessage {
role: "user" | "assistant";
content: string;
timestamp: Date;
interactionType: InteractionType;
relatedContentIds?: string[];
}
interface LearningSessionResource {
id: string;
userId: string;
subject: Subject;
level: EducationalLevel;
startTime: Date;
endTime?: Date;
active: boolean;
messages: SessionMessage[];
feedback?: string;
}User Profile
enum LearningStyle {
VISUAL = "visual",
AUDITORY = "auditory",
READING_WRITING = "reading_writing",
KINESTHETIC = "kinesthetic",
LOGICAL = "logical",
SOCIAL = "social",
SOLITARY = "solitary",
}
interface SubjectProgress {
level: EducationalLevel;
completedSessions: number;
lastSessionDate: Date | null;
masteredConcepts: string[];
strugglingConcepts: string[];
score: number;
}
interface UserProfileResource {
id: string;
name?: string;
email?: string;
createdAt: Date;
updatedAt: Date;
subjectProgress: Record<Subject, SubjectProgress>;
learningStyles: LearningStyle[];
strengths: string[];
weaknesses: string[];
}License
MIT
