Implement Server-Side AI Question Bank Generator, Adaptive Weakness Sampling 60/40, and Curriculum Studio One-Click Generation
This commit is contained in:
@@ -165,11 +165,14 @@ class CurriculumStudio
|
||||
<h2 style="font-size: 20px; font-weight: 900; color: #FFF; margin-bottom: 4px;">رفع وتفريغ كتب المناهج الوزارية (PDF ⟵ Markdown Tree) 📑</h2>
|
||||
<p style="font-size: 12.5px; color: var(--text-secondary);" id="upload_status_desc">اختر ملف كتاب المنهاج (PDF) ليقوم الخادم والذكاء الاصطناعي بتفريغ الوحدات والدروس والمصادر كملفات Markdown حية.</p>
|
||||
</div>
|
||||
<div style="display: flex; gap: 10px; align-items: center;">
|
||||
<div style="display: flex; gap: 10px; align-items: center; flex-wrap: wrap;">
|
||||
<input type="file" id="curriculum_pdf_input" accept=".pdf" style="display: none;" onchange="handleRealPdfUpload(this)">
|
||||
<button type="button" id="btn_upload_pdf" onclick="document.getElementById('curriculum_pdf_input').click()" class="btn-primary">
|
||||
<span>📤 رفع كتاب المنهاج PDF الحقيقي</span>
|
||||
</button>
|
||||
<button type="button" onclick="generateAiQuestionBank()" class="btn-primary" style="background: linear-gradient(135deg, #0071E3, #00F5D4); color: #FFF; font-weight: 800;">
|
||||
<span>🧠 توليد وتحديث بنك الأسئلة بالذكاء الاصطناعي (50 سؤالاً)</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -226,6 +229,7 @@ class CurriculumStudio
|
||||
<div style="display: flex; gap: 8px; flex-wrap: wrap;">
|
||||
<button type="button" class="btn-primary" style="padding: 8px 14px; font-size: 12px; background: linear-gradient(135deg, #7B2CBF, #9D4EDD);" onclick="copyAiVideoPrompt()">🎬 نسخ برومبت فيديو الشرح</button>
|
||||
<button type="button" class="btn-primary" style="padding: 8px 14px; font-size: 12px;" onclick="generateAiAssets()">✨ توليد الملخص والاختبار آلياً</button>
|
||||
<button type="button" class="btn-primary" style="padding: 8px 14px; font-size: 12px; background: linear-gradient(135deg, #0071E3, #00F5D4); color: #FFF; font-weight: 700;" onclick="generateAiQuestionBank()">🧠 توليد بنك أسئلة الوحدة (Gemini)</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -572,6 +576,47 @@ class CurriculumStudio
|
||||
}
|
||||
}
|
||||
|
||||
async function generateAiQuestionBank() {
|
||||
let unitPath = 'grade_10/math_10/semester_1/unit_01';
|
||||
if (currentFilePath) {
|
||||
const parts = currentFilePath.split('/');
|
||||
if (parts.length >= 4) {
|
||||
parts.pop();
|
||||
unitPath = parts.join('/');
|
||||
}
|
||||
}
|
||||
|
||||
const btn = window.event ? window.event.currentTarget : null;
|
||||
let originalText = '';
|
||||
if (btn) {
|
||||
originalText = btn.innerHTML;
|
||||
btn.innerHTML = '🧠 جاري التوليد الذكي لـ 50 سؤالاً...';
|
||||
btn.disabled = true;
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/curriculum/generate-questions', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ unit_path: unitPath, course_id: 1, count: 50 })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok && data.status === 'success') {
|
||||
alert(`✅ ${data.message}\n\nتم تحديث بنك الأسئلة بالكامل في قاعدة البيانات، وتفعيل محرك الامتحانات التكيفية وفق نقاط الضعف.`);
|
||||
} else {
|
||||
alert('⚠️ ' + (data.message || 'فشل توليد بنك الأسئلة'));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert('⚠️ حدث خطأ في الاتصال بمحرك الذكاء الاصطناعي');
|
||||
} finally {
|
||||
if (btn) {
|
||||
btn.innerHTML = originalText;
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function saveActiveMarkdown() {
|
||||
if (!currentFilePath) return;
|
||||
const content = document.getElementById('lesson_markdown_editor').value;
|
||||
|
||||
Reference in New Issue
Block a user