feat: Update Curriculum Studio with AI Assets panel to manually generate and input NotebookLM assets

This commit is contained in:
Hamza-Ayed
2026-08-29 02:01:52 +03:00
parent 074c08fc6f
commit 135a379b32
5 changed files with 217 additions and 5 deletions
@@ -10,6 +10,12 @@ class AiLessonEnhancerService
/**
* Extracts the lively script, cheat sheet, and Socratic quiz using Gemini.
*/
public static function generateFromText(string $title, string $content): ?array
{
$prompt = self::buildPrompt($title, $content);
return self::callGemini($prompt);
}
public static function enhanceLesson(int $lessonId): bool
{
$lesson = Database::selectOne(
@@ -156,6 +156,31 @@ class CurriculumService
return "# محتوى المنهاج\nالمحتوى المعتمد للمنهاج الرسمي.";
}
public static function saveLessonAiAssets(string $relativePath, array $assets): bool
{
self::ensureStorage();
$baseName = preg_replace('/\.md$/i', '', ltrim($relativePath, '/'));
$jsonPath = self::$storagePath . '/' . $baseName . '_ai_assets.json';
$dir = dirname($jsonPath);
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
}
return file_put_contents($jsonPath, json_encode($assets, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)) !== false;
}
public static function getLessonAiAssets(string $relativePath): array
{
self::ensureStorage();
$baseName = preg_replace('/\.md$/i', '', ltrim($relativePath, '/'));
$jsonPath = self::$storagePath . '/' . $baseName . '_ai_assets.json';
if (file_exists($jsonPath)) {
return json_decode(file_get_contents($jsonPath), true) ?: [];
}
return [];
}
/**
* Fast Keyword Search across All Markdown Files
*/