import React, { useState, useEffect } from 'react'; import { BookOpen, Code, Cpu, Database, Layout, Menu, X, ChevronRight, PlayCircle, FileText, CheckCircle, Shield, Globe, Smartphone, Terminal, Award, Layers, Search, ArrowRight, User, Home, Lock, Users, UploadCloud, BarChart2, Calendar, Mail, FileCheck, AlertCircle, HelpCircle, RefreshCw } from 'lucide-react'; // --- STYLE & CONFIG --- const fontStyle = ` @import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&display=swap'); body { font-family: 'Prompt', sans-serif; } `; // --- DATA: Curriculum Content (M.1 - M.3) --- const courseData = { m1: { id: 'm1', title: "วิทยาการคำนวณ ม.1", subtitle: "รากฐานแห่งการคิดและแก้ปัญหา", description: "เรียนรู้แนวคิดเชิงนามธรรม การแก้ปัญหาอย่างเป็นขั้นตอน และพื้นฐานการเขียนโปรแกรม Python/Scratch", color: "blue", icon: , progress: 30, units: [ { id: 'u1', title: "หน่วยที่ 1: แนวคิดเชิงนามธรรม", description: "Abstraction และการถ่ายทอดรายละเอียดของปัญหา", lessons: [ { id: 'l1-1', title: "แนวคิดเชิงนามธรรมคืออะไร?", type: "video", duration: "10 นาที", content: "แนวคิดเชิงนามธรรม (Abstraction) คือการคัดเลือกคุณลักษณะที่จำเป็นออกจากรายละเอียดที่ไม่จำเป็น เพื่อให้การแก้ปัญหามีความกระชับและตรงจุด", videoUrl: "https://www.youtube.com/embed/dummy-video-id" }, { id: 'l1-quiz', title: "แบบทดสอบท้ายบทที่ 1", type: "quiz", duration: "15 นาที", questions: [ { q: "ข้อใดคือความหมายของ 'แนวคิดเชิงนามธรรม'?", options: ["การวาดภาพให้สวยงาม", "การคัดเลือกเฉพาะข้อมูลที่จำเป็น", "การเขียนโปรแกรมคอมพิวเตอร์", "การรวบรวมข้อมูลให้มากที่สุด"], correct: 1 }, { q: "แผนที่รถไฟฟ้า เป็นตัวอย่างของแนวคิดใด?", options: ["Decomposition", "Pattern Recognition", "Abstraction", "Algorithm"], correct: 2 } ] } ] }, { id: 'u2', title: "หน่วยที่ 2: การออกแบบและการเขียนโปรแกรม", description: "อัลกอริทึม, Flowchart และ Python เบื้องต้น", lessons: [ { id: 'l2-1', title: "การเขียนรหัสลำลองและผังงาน", type: "article", duration: "20 นาที", content: "รหัสลำลอง (Pseudo Code) และผังงาน (Flowchart) เป็นเครื่องมือในการออกแบบอัลกอริทึมก่อนเริ่มเขียนโปรแกรมจริง" }, { id: 'l2-2', title: "ตัวแปร (Variable) ใน Python", type: "code", duration: "25 นาที", content: "ตัวแปรเปรียบเสมือนกล่องเก็บข้อมูล โดยใน Python เราสามารถกำหนดค่าได้เลย เช่น score = 10" }, { id: 'l2-quiz', title: "แบบทดสอบท้ายบทที่ 2", type: "quiz", duration: "10 นาที", questions: [ { q: "สัญลักษณ์สี่เหลี่ยมข้าวหลามตัดใน Flowchart หมายถึงอะไร?", options: ["เริ่มต้น/สิ้นสุด", "การประมวลผล", "การตัดสินใจ (เงื่อนไข)", "การรับค่าข้อมูล"], correct: 2 }, { q: "คำสั่งใดใช้แสดงผลข้อมูลใน Python?", options: ["input()", "print()", "show()", "display()"], correct: 1 } ] } ] }, { id: 'u3', title: "หน่วยที่ 3: การจัดการข้อมูลสารสนเทศ", description: "ข้อมูล, สารสนเทศ และการรวบรวมข้อมูล", lessons: [ { id: 'l3-1', title: "ข้อมูล vs สารสนเทศ", type: "video", duration: "15 นาที" } ] } ] }, m2: { id: 'm2', title: "วิทยาการคำนวณ ม.2", subtitle: "ตรรกะและเทคโนโลยีล้ำสมัย", description: "เจาะลึกการออกแบบอัลกอริทึม ตรรกะบูลีน Python ระดับกลาง และองค์ประกอบระบบคอมพิวเตอร์", color: "indigo", icon: , progress: 10, units: [ { id: 'u2-1', title: "หน่วยที่ 1: แนวคิดเชิงคำนวณ", description: "Decomposition, Pattern Recognition", lessons: [{ id: 'm2-l1', title: "การแตกปัญหาใหญ่เป็นปัญหาย่อย", type: "video", duration: "15 นาที" }] }, { id: 'u2-2', title: "หน่วยที่ 2: Python และตรรกะบูลีน", description: "Operators, Logic Gates, Functions", lessons: [ { id: 'm2-l2', title: "ตัวดำเนินการทางตรรกะ (AND, OR, NOT)", type: "code", duration: "20 นาที" }, { id: 'm2-quiz', title: "แบบทดสอบตรรกะ", type: "quiz", duration: "10 นาที", questions: [{ q: "True AND False มีค่าเท่ากับเท่าไหร่?", options: ["True", "False", "Error", "Null"], correct: 1 }] } ] }, { id: 'u2-3', title: "หน่วยที่ 3: ระบบคอมพิวเตอร์", description: "Hardware, Software, CPU, Memory", lessons: [{ id: 'm2-l3', title: "หลักการทำงานของ CPU", type: "article", duration: "15 นาที" }] } ] }, m3: { id: 'm3', title: "วิทยาการคำนวณ ม.3", subtitle: "นักพัฒนานวัตกรรมแห่งอนาคต", description: "สร้างสรรค์แอปพลิเคชัน IoT (Internet of Things) และการรู้เท่าทันสื่อดิจิทัล", color: "purple", icon: , progress: 0, units: [ { id: 'u3-1', title: "หน่วยที่ 1: การพัฒนาแอปพลิเคชัน", description: "วงจรพัฒนาระบบ (SDLC), การใช้ Trello", lessons: [{ id: 'm3-l1', title: "Software Development Life Cycle", type: "video", duration: "20 นาที" }] }, { id: 'u3-2', title: "หน่วยที่ 2: Internet of Things (IoT)", description: "Microcontroller, Sensors, KidBright", lessons: [ { id: 'm3-l2', title: "IoT และ Smart Home", type: "video", duration: "15 นาที" }, { id: 'm3-quiz', title: "Quiz: ความรู้เบื้องต้น IoT", type: "quiz", duration: "10 นาที", questions: [{ q: "อุปกรณ์ใดทำหน้าที่เปรียบเสมือนสมองของระบบ IoT?", options: ["Sensor", "Actuator", "Microcontroller", "Wi-Fi Module"], correct: 2 }] } ] }, { id: 'u3-3', title: "หน่วยที่ 3: การรู้เท่าทันสื่อ", description: "Fake News, Cyberbullying, กฎหมายคอมฯ", lessons: [{ id: 'm3-l3', title: "พ.ร.บ. คอมพิวเตอร์ฯ ที่ควรรู้", type: "article", duration: "20 นาที" }] } ] } }; // --- DATA: Mock Data for Teachers, Assignments, Grades --- const teachersData = [ { id: 1, name: "ครูสมชาย ใจดี", role: "หัวหน้ากลุ่มสาระฯ", subject: "วิทยาการคำนวณ ม.3", email: "somchai@school.ac.th", color: "blue", img: "https://api.dicebear.com/7.x/avataaars/svg?seed=Felix" }, { id: 2, name: "ครูวิภาดา รักสอน", role: "ครูผู้สอน", subject: "วิทยาการคำนวณ ม.1", email: "wipada@school.ac.th", color: "pink", img: "https://api.dicebear.com/7.x/avataaars/svg?seed=Aneka" }, { id: 3, name: "ครูเอกพล คนเก่ง", role: "ครูผู้สอน/IT Support", subject: "วิทยาการคำนวณ ม.2", email: "ekapol@school.ac.th", color: "indigo", img: "https://api.dicebear.com/7.x/avataaars/svg?seed=Jack" } ]; const assignmentsData = [ { id: 1, title: "ใบงานที่ 1.1: ออกแบบ Flowchart กิจวัตรประจำวัน", course: "วิทยาการคำนวณ ม.1", dueDate: "15 ก.พ. 67", status: "pending", score: null, max: 10 }, { id: 2, title: "โครงงาน: สิ่งประดิษฐ์สมองกล (IoT)", course: "วิทยาการคำนวณ ม.3", dueDate: "20 ก.พ. 67", status: "submitted", score: null, max: 20 }, { id: 3, title: "แบบฝึกหัด: เขียน Python คำนวณเกรด", course: "วิทยาการคำนวณ ม.2", dueDate: "10 ม.ค. 67", status: "graded", score: 18, max: 20 }, ]; const gradesData = { student: "ด.ช. รักเรียน เขียนโค้ด", id: "67010555", gpa: "3.85", terms: [ { name: "เทอม 1/2566", subject: "วิทยาการคำนวณ 1 (ว21103)", grade: 4.0, score: 85 }, { name: "เทอม 1/2566", subject: "การออกแบบเทคโนโลยี 1 (ว21104)", grade: 3.5, score: 79 }, ], current: [ { item: "เข้าเรียน/จิตพิสัย", score: 10, max: 10 }, { item: "งานมอบหมาย", score: 25, max: 30 }, { item: "สอบกลางภาค", score: 18, max: 20 }, { item: "สอบปลายภาค", score: null, max: 40, note: "รอสอบ" } ] }; // --- MAIN APPLICATION COMPONENT --- const App = () => { const [view, setView] = useState('home'); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); // LMS State const [selectedGrade, setSelectedGrade] = useState(null); const [selectedLesson, setSelectedLesson] = useState(null); const [activeUnitId, setActiveUnitId] = useState(null); // Interactive Quiz State const [quizState, setQuizState] = useState({ answers: {}, submitted: false, score: 0 }); // Assignment Upload State const [showUploadModal, setShowUploadModal] = useState(false); const [uploading, setUploading] = useState(false); // --- ACTIONS --- const handleEnterCourse = (gradeKey) => { setSelectedGrade(courseData[gradeKey]); setView('course_overview'); window.scrollTo(0,0); }; const handleStartLesson = (unit, lesson) => { setActiveUnitId(unit.id); setSelectedLesson(lesson); setQuizState({ answers: {}, submitted: false, score: 0 }); // Reset quiz setView('lesson_player'); window.scrollTo(0,0); }; const handleQuizSelect = (qIdx, optIdx) => { setQuizState(prev => ({ ...prev, answers: { ...prev.answers, [qIdx]: optIdx } })); }; const handleSubmitQuiz = (questions) => { let score = 0; questions.forEach((q, idx) => { if (quizState.answers[idx] === q.correct) score++; }); setQuizState(prev => ({ ...prev, submitted: true, score })); }; const handleUploadAssignment = (e) => { e.preventDefault(); setUploading(true); setTimeout(() => { setUploading(false); setShowUploadModal(false); alert("ส่งงานเรียบร้อยแล้ว! (จำลอง)"); }, 1500); }; // --- SUB-COMPONENTS --- const Navbar = () => ( ); const HomeView = () => (
🎓 หลักสูตรแกนกลางฯ ฉบับปรับปรุง 2560

เรียนรู้วิทยาการคำนวณ
ก้าวทันโลกอนาคต

แพลตฟอร์มการเรียนรู้อัจฉริยะ ครบครันด้วยเนื้อหา Coding, IoT, Data Science และ Digital Literacy พร้อมระบบติดตามผลการเรียนแบบ Real-time

{Object.keys(courseData).map(key => { const course = courseData[key]; return (
handleEnterCourse(key)} className="bg-white p-6 rounded-2xl shadow-xl border border-gray-100 hover:-translate-y-2 hover:shadow-2xl hover:border-blue-200 transition-all cursor-pointer group">
{course.icon}
{course.progress > 0 && (
ความคืบหน้า
{course.progress}%
)}

{course.title}

{course.description}

เข้าสู่บทเรียน
); })}
); const CourseOverview = () => (
{React.cloneElement(selectedGrade.icon, { size: 64, className: `text-${selectedGrade.color}-600` })}
ภาคเรียนที่ 1/2567

{selectedGrade.title}

{selectedGrade.description}

{selectedGrade.units.length} หน่วยการเรียนรู้
มีเกียรติบัตร

โครงสร้างรายวิชา

{selectedGrade.units.map((unit) => (

{unit.title}

{unit.description}

{unit.lessons.map((lesson) => (
handleStartLesson(unit, lesson)} className="p-4 flex items-center justify-between hover:bg-blue-50/50 cursor-pointer transition group" >
{lesson.type === 'video' && } {lesson.type === 'quiz' && } {lesson.type === 'article' && } {lesson.type === 'code' && }

{lesson.title}

{lesson.type === 'quiz' ? 'แบบทดสอบ' : 'บทเรียน'} • {lesson.duration}

))}
))}
); const LessonPlayer = () => { // Determine context for sidebar const currentUnit = selectedGrade.units.find(u => u.id === activeUnitId); return (
{/* Sidebar Navigation */}

{currentUnit.title}

33% สำเร็จ

{currentUnit.lessons.map(l => (
handleStartLesson(currentUnit, l)} className={`p-3 rounded-lg text-sm font-medium cursor-pointer flex items-center gap-3 transition ${selectedLesson.id === l.id ? 'bg-blue-50 text-blue-700 border border-blue-100' : 'text-gray-600 hover:bg-gray-50'}`} > {l.type === 'quiz' ? :
} {l.title}
))}
{/* Content Area */}
{/* Header */}
{selectedLesson.type} Lesson

{selectedLesson.title}

{/* Dynamic Content based on Type */}
{/* VIDEO PLAYER */} {selectedLesson.type === 'video' && (

Video Simulation: {selectedLesson.title}

คำอธิบายรายวิชา

{selectedLesson.content || "เนื้อหาบทเรียนวิดีโอ..."}

)} {/* ARTICLE / CODE */} {(selectedLesson.type === 'article' || selectedLesson.type === 'code') && (

บทความความรู้

อ่านเนื้อหาและทำความเข้าใจก่อนทำแบบทดสอบ

{selectedLesson.content}

{selectedLesson.type === 'code' && (
python learn_coding.py
Result: Hello World!
)}
)} {/* INTERACTIVE QUIZ */} {selectedLesson.type === 'quiz' && (
{!quizState.submitted ? (

แบบทดสอบวัดความรู้

ตอบคำถามให้ถูกต้องเพื่อผ่านด่าน

{selectedLesson.questions.map((q, qIdx) => (

{qIdx + 1}. {q.q}

{q.options.map((opt, oIdx) => ( ))}
))}
) : (

สรุปผลคะแนน

คุณทำคะแนนได้

{quizState.score} / {selectedLesson.questions.length}
)}
)}
{/* Navigation Buttons */}
{selectedLesson.type !== 'quiz' && ( )}
); }; // --- SECONDARY VIEWS --- const TeachersView = () => (

ทีมครูผู้สอน

{teachersData.map(t => (
{t.name}

{t.name}

{t.role}
{t.subject}
{t.email}
))}
); const AssignmentsView = () => (

ส่งงานออนไลน์

{assignmentsData.map(assign => (
{assign.course} {assign.status === 'pending' && รอส่งงาน} {assign.status === 'submitted' && รอตรวจ} {assign.status === 'graded' && ตรวจแล้ว}

{assign.title}

กำหนดส่ง: {assign.dueDate} {assign.max} คะแนน

{assign.status === 'pending' ? ( ) : assign.status === 'graded' ? (
{assign.score} คะแนนที่ได้
) : ( )}
))}
{showUploadModal && (

อัปโหลดไฟล์งาน

คลิกเพื่อเลือกไฟล์ หรือลากมาวางที่นี่

รองรับ PDF, JPG, DOCX (Max 10MB)

)}
); const GradesView = () => (

{gradesData.student}

รหัสนักเรียน: {gradesData.id}

GPA สะสม {gradesData.gpa}

ผลการเรียนเทอมปัจจุบัน (1/2567)

{gradesData.current.map((item, i) => (
{item.item} {item.score !== null ? item.score : '-'} / {item.max}
{item.score !== null ? (
) : (
)}
{item.note &&

{item.note}

}
))}

ประวัติผลการเรียน

{gradesData.terms.map((t, i) => (

{t.name}

{t.subject}

คะแนน {t.score} เกรด {t.grade}
))}
); return ( <>
{view === 'home' && } {view === 'teachers' && } {view === 'assignments' && } {view === 'grades' && } {view === 'course_overview' && selectedGrade && } {view === 'lesson_player' && selectedGrade && }
); }; export default App;