openlearn-next 0.7.6 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -150
- package/dist/assets/{AcademicYearFilter-DUUGpDKt.js → AcademicYearFilter-Dm3no4Nb.js} +1 -1
- package/dist/assets/ActivityWorkspaceWidget-BXS1IamH.js +1 -0
- package/dist/assets/{AdminDirectoryView-DL9zZi-_.js → AdminDirectoryView-479SfYyD.js} +2 -2
- package/dist/assets/{AssessmentCenter-B2JzXBGe.js → AssessmentCenter-CJ-pchOQ.js} +1 -1
- package/dist/assets/{AssignmentFilePreview-Bk751Blz.js → AssignmentFilePreview-wjnrKjsp.js} +1 -1
- package/dist/assets/{BatchPickerModal-9ekXDUUj.js → BatchPickerModal-JvoD-1pF.js} +1 -1
- package/dist/assets/{ClassesView-PCt8I3MU.js → ClassesView-CB8q2kW0.js} +12 -12
- package/dist/assets/ClassroomCountdownWidget-BqzBpAvi.js +2 -0
- package/dist/assets/{CloudDriveModal-Mp59sr-C.js → CloudDriveModal-DHxOnL4m.js} +1 -1
- package/dist/assets/ComputerLabView-BEDe7WiU.js +1 -0
- package/dist/assets/CourseManagement-BjxQC6sq.js +1 -0
- package/dist/assets/{CourseWizardModal-B7-e8otR.js → CourseWizardModal-D3UPFtT_.js} +2 -2
- package/dist/assets/{CoursewareHubPanel-DLjH-UzF.js → CoursewareHubPanel-CqJqcZGs.js} +1 -1
- package/dist/assets/{Dashboard-D3LXLQNC.js → Dashboard-C3BaEHIG.js} +2 -2
- package/dist/assets/{ExportWeightModal-vd7XgaJ0.js → ExportWeightModal-iF0pVevG.js} +1 -1
- package/dist/assets/{HelpTour-BLuiS8rr.js → HelpTour-6ChRqWnB.js} +1 -1
- package/dist/assets/{HelpView-C4BHoNqR.js → HelpView-D3iYhzBz.js} +2 -2
- package/dist/assets/ImportLessonsModal-BOwj7ezj.js +1 -0
- package/dist/assets/{ImportModal-H5s5MyZY.js → ImportModal-DAHGdI9h.js} +1 -1
- package/dist/assets/{InteractiveCoursewareViewer-D9GzG28E.js → InteractiveCoursewareViewer-DX9xnk6j.js} +1 -1
- package/dist/assets/InteractiveWhiteboard-41mi9keH.js +65 -0
- package/dist/assets/LazyCourseware-DKyUHXaE.js +2 -0
- package/dist/assets/LazyWhiteboard-fXS2P44c.js +2 -0
- package/dist/assets/LessonEditorView-Dx-hOKtt.js +1 -0
- package/dist/assets/LiveClassroomView-m0hKdcVK.js +61 -0
- package/dist/assets/NotificationDetailModal-C2tg_IoJ.js +1 -0
- package/dist/assets/PluginView-BPRUpCjV.js +77 -0
- package/dist/assets/{ProcessLogsModal-_BwkmJVw.js → ProcessLogsModal-CULHzXp7.js} +1 -1
- package/dist/assets/{QuizGeneratorModal-DiItok6z.js → QuizGeneratorModal-CYxngpW9.js} +1 -1
- package/dist/assets/StudentAssignmentEvalPanel-Dfe4IOs5.js +1 -0
- package/dist/assets/{StudentAssignmentView-UK_7_MF3.js → StudentAssignmentView-IfRo3yJk.js} +1 -1
- package/dist/assets/StudentLessonView-Dw2uxBhq.js +1 -0
- package/dist/assets/StudentView-DVYUSrVU.js +2 -0
- package/dist/assets/{SystemResourceLibraryModal-dEdNKbk2.js → SystemResourceLibraryModal-BhbpfIBt.js} +1 -1
- package/dist/assets/TeacherView-CZjIejet.js +2 -0
- package/dist/assets/{TimetableView-AkReskNG.js → TimetableView-CupOIfEy.js} +1 -1
- package/dist/assets/{UTIF-4E-wdh3X.js → UTIF-BtQhea94.js} +1 -1
- package/dist/assets/index-BDFyco9S.css +1 -0
- package/dist/assets/index-BiHQqzdm.js +131 -0
- package/dist/assets/{index.es-WXdI0L-F.js → index.es-CijVATXs.js} +1 -1
- package/dist/assets/{pluginParsers-k90WUDrU.js → pluginParsers-C9W6GBVx.js} +1 -1
- package/dist/assets/{student-workspace-BDw1i4Vl.js → student-workspace-CsbA8Cs4.js} +1 -1
- package/dist/assets/{vendor-charts-SrpBsvM3.js → vendor-charts-skggaP9D.js} +1 -1
- package/dist/assets/{vendor-icons-hc6MjYFv.js → vendor-icons-DaYNfRAc.js} +2 -2
- package/dist/assets/{vendor-konva-Dne0Z-WC.js → vendor-konva-BOuJWFuE.js} +1 -1
- package/dist/assets/{vendor-pdf-By0fofA0.js → vendor-pdf-DVWGghIL.js} +3 -3
- package/dist/assets/{vendor-pptx-EjNUtdws.js → vendor-pptx-BqU7v5zS.js} +5 -5
- package/dist/assets/{vendor-react-Kv_JATwr.js → vendor-react-DHoBZpn2.js} +2 -2
- package/dist/assets/{vendor-utils-aM7aYvPP.js → vendor-utils-BxOuk3id.js} +1 -1
- package/dist/env-validation.cjs +7 -1
- package/dist/index.html +6 -6
- package/dist/server.cjs +343 -37
- package/migrations/044_students_gender.sql +8 -0
- package/migrations/README.md +1 -0
- package/migrations/schema-golden.json +3 -2
- package/package.json +2 -2
- package/dist/assets/ActivityWorkspaceWidget-0DUqiqFK.js +0 -1
- package/dist/assets/ClassroomCountdownWidget-HxelcHUp.js +0 -2
- package/dist/assets/ComputerLabView-FStILvFC.js +0 -1
- package/dist/assets/CourseManagement-BQw2idgZ.js +0 -1
- package/dist/assets/ImportLessonsModal-Y6uIIemO.js +0 -1
- package/dist/assets/InteractiveWhiteboard-DswIV-ES.js +0 -65
- package/dist/assets/LazyCourseware-BEoTTg5h.js +0 -2
- package/dist/assets/LazyWhiteboard-CMBBxnFX.js +0 -2
- package/dist/assets/LessonEditorView-BgJtG8Ks.js +0 -1
- package/dist/assets/LiveClassroomView-Czwt5WW-.js +0 -61
- package/dist/assets/NotificationDetailModal-D42vEs3S.js +0 -1
- package/dist/assets/PluginView-BcOWIjLu.js +0 -77
- package/dist/assets/StudentAssignmentEvalPanel-DHoZc3g0.js +0 -1
- package/dist/assets/StudentLessonView-C11Qkdi_.js +0 -1
- package/dist/assets/StudentView-j0hx3IOi.js +0 -2
- package/dist/assets/TeacherView-COZw2tFl.js +0 -2
- package/dist/assets/index-DN3E-Fmw.js +0 -131
- package/dist/assets/index-DPky2leG.css +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openlearn-next",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A plugin-driven Educational OS / LMS platform with AI agent teaching assistant",
|
|
6
6
|
"keywords": [
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@google/genai": "^2.4.0",
|
|
88
|
-
"@openlearn/plugin-sdk": "3.7.
|
|
88
|
+
"@openlearn/plugin-sdk": "3.7.5",
|
|
89
89
|
"bcryptjs": "^3.0.3",
|
|
90
90
|
"better-sqlite3": "^12.11.1",
|
|
91
91
|
"chokidar": "^5.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as o,j as e}from"./vendor-react-Kv_JATwr.js";import{e as D}from"./index-DN3E-Fmw.js";import{$ as q,X as H,j as J,i as Q,B as V,o as X,y as _,w as G,U as K,b1 as Y,b0 as Z,b2 as ee,e as te,P as se}from"./vendor-icons-hc6MjYFv.js";import"./vendor-utils-aM7aYvPP.js";import"./vendor-pdf-By0fofA0.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-SrpBsvM3.js";async function ie(n="all"){const a=await fetch(`/api/activities?role=${encodeURIComponent(n)}`,{headers:{Accept:"application/json"}});if(!a.ok)throw new Error(`Failed to load activities (${a.status})`);return(await a.json()).activities??[]}async function k(){const n=await fetch("/api/activities/running",{headers:{Accept:"application/json"}});if(!n.ok)throw new Error(`Failed to load running activities (${n.status})`);return(await n.json()).activities??[]}async function ne(n){const a=await fetch(`/api/activities/${encodeURIComponent(n)}/finish`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error||`Failed to finish activity (${a.status})`)}}async function ae(n){const a=await fetch(`/api/activities/${encodeURIComponent(n)}/pause`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error||`Failed to pause activity (${a.status})`)}}async function re(n){const a=await fetch(`/api/activities/${encodeURIComponent(n)}/resume`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error||`Failed to resume activity (${a.status})`)}}async function oe(n,a,s){const l=await fetch(`/api/activities/${encodeURIComponent(n)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:a??{},actorId:s})}),c=await l.json();if(!l.ok||c.ok===!1)throw new Error(c.error||`Failed to start activity (${l.status})`);return c}const x={padding:"12px",color:"#e2e8f0",fontSize:"13px"},ce={HelpCircle:te,Vote:ee,BarChart3:Z,MessagesSquare:Y,Users:K,FileText:G,Trophy:_,CheckCircle2:X,BookOpen:V};function le({name:n,className:a}){const s=n&&ce[n]||se;return e.jsx(s,{size:18,className:a})}function de(n,a){if(!n)return a==="zh"?"进行中":"In progress";const s=Math.max(0,Math.floor((Date.now()-n)/1e3)),l=Math.floor(s/60),c=s%60;return a==="zh"?`${l} 分 ${c} 秒`:`${l}m ${c}s`}const ge=({role:n,actorId:a,lang:s="en",classroomId:l,mode:c="launcher"})=>{const[p,E]=o.useState([]),[A,j]=o.useState(!0),[b,$]=o.useState(null),[v,m]=o.useState({}),[h,w]=o.useState([]),[T,R]=o.useState(!0),[P,I]=o.useState(null),[y,u]=o.useState(null),[f,z]=o.useState(!1),[S,C]=o.useState(null),B=D(i=>i.setTeacherTab),F=o.useMemo(()=>{const i=new Map;for(const t of p){const r=t.category;i.has(r)||i.set(r,[]),i.get(r).push(t)}return Array.from(i.entries())},[p]);o.useEffect(()=>{if(c!=="launcher")return;let i=!1;return j(!0),ie(n).then(t=>{i||E(t)}).catch(t=>{i||$(t instanceof Error?t.message:String(t))}).finally(()=>{i||j(!1)}),()=>{i=!0}},[n,c]),o.useEffect(()=>{if(c!=="status")return;let i=!1;const t=async()=>{try{const d=await k();i||w(d)}catch(d){i||I(d instanceof Error?d.message:String(d))}finally{i||R(!1)}};t();const r=setInterval(t,5e3);return()=>{i=!0,clearInterval(r)}},[c]);const g=async i=>{if(y){z(!0),C(null);try{await i(y),w(await k())}catch(t){C(t instanceof Error?t.message:String(t))}finally{z(!1)}}},W=()=>g(ne),M=()=>g(ae),O=()=>g(re),L=()=>{u(null),B("live_class")};if(c==="status"){if(T)return e.jsx("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm h-24 animate-pulse"});if(P||h.length===0)return null;const i=h.find(t=>t.id===y)||null;return e.jsxs("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-800 font-extrabold",children:[e.jsx("span",{children:"🧩"}),e.jsx("span",{children:s==="zh"?"进行中的活动":"Activities in Progress"})]}),e.jsx("span",{className:"text-xs font-bold bg-indigo-50 text-indigo-700 px-2 py-0.5 rounded-full",children:h.length})]}),e.jsx("div",{className:"flex flex-col gap-2",children:h.map(t=>{const r=t.state==="running";return e.jsxs("button",{onClick:()=>u(t.id),className:"w-full flex items-center gap-3 text-left bg-slate-50 hover:bg-slate-100 border border-slate-200/70 rounded-xl p-3 transition-colors",children:[e.jsx(le,{name:t.icon,className:"text-indigo-600 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-bold text-slate-800 truncate",children:t.name}),t.category&&e.jsx("div",{className:"text-xs text-slate-500 truncate",children:t.category})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${r?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"}`,children:r?s==="zh"?"进行中":"Running":s==="zh"?"已暂停":"Paused"}),e.jsxs("span",{className:"text-xs text-slate-400 flex items-center gap-1",children:[e.jsx(q,{size:10})," ",de(t.startedAt,s)]})]})]},t.id)})}),i&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4",onClick:()=>u(null),children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-sm p-5",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-bold text-slate-800",children:i.name}),e.jsx("button",{onClick:()=>u(null),className:"text-slate-400 hover:text-slate-600","aria-label":"close",children:e.jsx(H,{size:18})})]}),e.jsxs("div",{className:"text-sm text-slate-500 mb-1",children:[s==="zh"?"状态":"Status",":"," ",i.state==="running"?s==="zh"?"进行中":"Running":s==="zh"?"已暂停":"Paused"]}),e.jsxs("div",{className:"text-sm text-slate-500 mb-4",children:[s==="zh"?"开始时间":"Started",":"," ",i.startedAt?new Date(i.startedAt).toLocaleString():"-"]}),S&&e.jsx("div",{className:"text-xs text-rose-600 mb-2",children:S}),e.jsxs("div",{className:"flex gap-2",children:[i.state==="running"?e.jsxs("button",{disabled:f,onClick:M,className:"flex-1 flex items-center justify-center gap-1 bg-amber-500 hover:bg-amber-600 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:[e.jsx(J,{size:14})," ",s==="zh"?"暂停":"Pause"]}):e.jsxs("button",{disabled:f,onClick:O,className:"flex-1 flex items-center justify-center gap-1 bg-indigo-500 hover:bg-indigo-600 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:[e.jsx(Q,{size:14})," ",s==="zh"?"恢复":"Resume"]}),e.jsx("button",{disabled:f,onClick:W,className:"flex-1 flex items-center justify-center gap-1 bg-rose-600 hover:bg-rose-700 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:f?s==="zh"?"处理中…":"Working…":s==="zh"?"结束":"End"})]}),e.jsx("button",{onClick:L,className:"w-full mt-2 bg-slate-100 hover:bg-slate-200 text-slate-700 rounded-lg py-2 text-sm font-bold",children:s==="zh"?"进入课堂":"Enter Classroom"})]})})]})}const U=async i=>{m(t=>({...t,[i.id]:s==="zh"?"启动中…":"Starting…"}));try{const t=await oe(i.id,{classroomId:l,role:n},a);m(r=>({...r,[i.id]:t.dispatched?s==="zh"?"已启动 ✓":"Started ✓":s==="zh"?"已通知 ✓":"Notified ✓"}))}catch(t){m(r=>({...r,[i.id]:t instanceof Error?t.message:String(t)}))}};if(A)return e.jsx("div",{style:x,children:s==="zh"?"加载活动中…":"Loading activities…"});if(b)return e.jsxs("div",{style:x,children:[e.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",s==="zh"?"活动中心":"Activity Center"]}),e.jsx("div",{style:{opacity:.7},children:b})]});const N=n==="teacher"?s==="zh"?"活动中心(教师)":"Activity Center":s==="zh"?"活动(学生)":"Activities";return p.length===0?e.jsxs("div",{style:x,children:[e.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",N]}),e.jsx("div",{style:{opacity:.7},children:s==="zh"?"暂无可用活动。":"No activities available."})]}):e.jsxs("div",{style:x,children:[e.jsxs("div",{style:{fontWeight:600,marginBottom:8},children:["🧩 ",N]}),F.map(([i,t])=>e.jsxs("div",{style:{marginBottom:10},children:[e.jsx("div",{style:{opacity:.6,fontSize:12,textTransform:"uppercase",marginBottom:4},children:i}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:t.map(r=>e.jsxs("div",{style:{border:"1px solid #334155",borderRadius:8,padding:"8px 10px",minWidth:150,background:"#0f172a"},children:[e.jsxs("div",{style:{fontWeight:600},children:[r.icon?`${r.icon} `:"▫️ ",r.name]}),r.description&&e.jsx("div",{style:{opacity:.7,fontSize:12,margin:"2px 0 6px"},children:r.description}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("button",{onClick:()=>U(r),style:{cursor:"pointer",background:n==="teacher"?"#2563eb":"#0ea5e9",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontSize:12},children:n==="teacher"?s==="zh"?"启动":"Start":s==="zh"?"参与":"Open"}),v[r.id]&&e.jsx("span",{style:{fontSize:12,opacity:.85},children:v[r.id]})]}),e.jsx("div",{style:{opacity:.5,fontSize:12,marginTop:4},children:r.provider==="official"?"official":r.provider})]},r.id))})]},i))]})};export{ge as ActivityWorkspaceWidget};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as l,j as e}from"./vendor-react-Kv_JATwr.js";import{k as fe,E as ie}from"./index-DN3E-Fmw.js";import{y as ce,_ as pe,aA as ge,R as we,D as je,o as ye,$ as Z,z as be,b0 as ve,U as Ne,b7 as ze,j as re,i as I,a6 as de,av as ne,aw as oe,m as le,ad as ae,a9 as me,bR as Ce,l as ke}from"./vendor-icons-hc6MjYFv.js";import{a as Re,B as Se,C as Ae,X as $e,Y as Te,T as Ee,f as Pe,g as De,i as _e}from"./vendor-charts-SrpBsvM3.js";const ue=["#F59E0B","#6366F1","#10B981","#3B82F6","#0EA5E9"];function Fe({lang:n="zh",lessonId:o,classId:g,lessons:j=[],classes:C=[],schedules:v=[],students:y=[],addToast:Q,className:r="",compact:B=!1,allowSimulation:N=!1}){const[p,q]=l.useState(o||""),[w,Y]=l.useState("score"),[ee,U]=l.useState(!1),[G,F]=l.useState(!1),[z,K]=l.useState([]),[L,M]=l.useState({totalParticipants:0,totalResponses:0,averageScore:0}),[te,P]=l.useState(null);l.useEffect(()=>{o&&o!==p&&q(o)},[o]),l.useEffect(()=>{if(!p&&j.length>0){const s=new Date().toISOString().split("T")[0],m=v.find(u=>u.scheduled_date===s);q(m?.lesson_id||j[0].id)}},[p,j,v]);const A=l.useCallback(async s=>{const m=s||p;if(m){U(!0);try{const u=g?`&classId=${encodeURIComponent(g)}`:"",x=await fetch(`/api/classroom/sessions/${encodeURIComponent(m)}/top-performers?limit=5${u}`);if(x.ok){const d=await x.json();d.success&&Array.isArray(d.topPerformers)&&d.topPerformers.length>0?(K(d.topPerformers),d.summary&&M(d.summary)):(K([]),M({totalParticipants:0,totalResponses:0,averageScore:0}))}}catch(u){console.warn("[TopPerformersWidget] fetch failed:",u)}finally{U(!1)}}},[p,g]);l.useEffect(()=>{p&&A(p)},[p,g,A]),l.useEffect(()=>{const s=x=>{if(P(Date.now()),!x||x.lessonId&&x.lessonId!==p)return;const d=x.studentId||x.id;Array.isArray(y)&&y.length>0&&!y.some(h=>h.id===d)||(K(h=>{const H=x.studentName||y.find(b=>b.id===d)?.name||`Student ${String(d).slice(-4)}`,T=Number(x.score)||0,_=x.isCorrect?1:0,X=h.findIndex(b=>b.studentId===d);let O;if(X>=0){const b=h[X],k=b.totalQuizzesAnswered+1,t=b.correctCount+_,i=b.cumulativeScore+T,a=Math.round(t/k*100),c={...b,cumulativeScore:i,totalQuizzesAnswered:k,correctCount:t,accuracy:a,lastSubmittedAt:Date.now()};O=[...h],O[X]=c}else{const b={rank:99,studentId:d,studentName:H,cumulativeScore:T,totalQuizzesAnswered:1,correctCount:_,accuracy:_?100:0,avgTimeSpentMs:x.time_spent_ms??null,lastSubmittedAt:Date.now()};O=[...h,b]}return O.sort((b,k)=>k.cumulativeScore-b.cumulativeScore||k.accuracy-b.accuracy||k.correctCount-b.correctCount),O.slice(0,5).map((b,k)=>({...b,rank:k+1}))}),M(h=>({...h,totalResponses:h.totalResponses+1})))};let m=null;const u=fe(x=>{m?.(),x.on("whiteboard-quiz-answered",s),m=()=>{typeof x.off=="function"&&x.off("whiteboard-quiz-answered",s)}});return()=>{u(),m?.()}},[p,y]);const W=async()=>{if(p){F(!0);try{(await fetch(`/api/classroom/sessions/${p}/simulate-quiz-responses`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok&&(Q?.(n==="zh"?"🎯 实时答题模拟成功":"🎯 Quiz Simulation Success",n==="zh"?"已为 8 位学生生成随堂测验提交,实时成绩榜单已即时重排!":"Generated simulated live quiz submissions. Top performers updated!","success"),await A(p))}catch(s){console.error("Failed to simulate quiz responses:",s)}finally{F(!1)}}},D=s=>{Q?.(n==="zh"?"🏆 表扬已送达":"🏆 Praise Sent",n==="zh"?`已向榜首学生 [${s.studentName}] 发送课堂「随堂之星」荣誉勋章与鼓励!`:`Sent "Quiz Star" honor medal to top performer [${s.studentName}]!`,"success")},$=()=>{const s=["Rank","Student ID","Student Name","Cumulative Score","Answered","Correct","Accuracy %"],m=z.map(h=>[h.rank,h.studentId,h.studentName,h.cumulativeScore,h.totalQuizzesAnswered,h.correctCount,`${h.accuracy}%`]),u="data:text/csv;charset=utf-8,\uFEFF"+[s.join(","),...m.map(h=>h.join(","))].join(`
|
|
2
|
-
`),x=encodeURI(u),d=document.createElement("a");d.setAttribute("href",x),d.setAttribute("download",`top_performers_quiz_${p||"class"}.csv`),document.body.appendChild(d),d.click(),document.body.removeChild(d),Q?.(n==="zh"?"📥 导出成功":"📥 Exported",n==="zh"?"随堂测验 Top 5 榜单数据已导出为 CSV 文件。":"Top 5 performers exported to CSV.","info")},J=l.useMemo(()=>z.map(s=>{const m=s.studentName.length>8?`${s.studentName.slice(0,7)}…`:s.studentName;return{rank:s.rank,name:m,fullName:s.studentName,studentId:s.studentId,score:s.cumulativeScore,accuracy:s.accuracy,count:s.totalQuizzesAnswered,correctCount:s.correctCount,avgTimeSec:(s.avgTimeSpentMs/1e3).toFixed(1),chartValue:w==="score"?s.cumulativeScore:w==="accuracy"?s.accuracy:s.totalQuizzesAnswered}}),[z,w]),S=l.useMemo(()=>j.find(s=>s.id===p)?.title||p||"Classroom Session",[j,p]);return e.jsxs("div",{id:"top-performers-widget","data-testid":"top-performers-widget",className:`bg-surface border border-theme rounded-2xl p-5 shadow-sm transition-all relative flex flex-col gap-4 ${r}`,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-3 border-b border-theme/60",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-amber-500/10 text-amber-500 flex items-center justify-center font-bold shadow-xs",children:e.jsx(ce,{size:20,className:"text-amber-500 animate-bounce"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-base font-bold text-main tracking-tight",children:n==="zh"?"随堂测验优秀榜 (Top 5 Performers)":"Live Quiz Top 5 Performers"}),te&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-semibold bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-400 border border-emerald-200 dark:border-emerald-800 animate-pulse",children:[e.jsx(pe,{size:10,className:"animate-spin text-emerald-500"}),e.jsx("span",{children:n==="zh"?"实时作答同步中":"Live Sync"})]})]}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:n==="zh"?"基于课堂互动白板随堂测试累计得分与答题正确率智能聚合":"Aggregated from cumulative scores and accuracy in live quiz responses"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[j.length>0&&e.jsx("select",{value:p,onChange:s=>q(s.target.value),className:"bg-surface-secondary border border-theme text-xs rounded-lg px-2.5 py-1.5 text-main outline-none focus:ring-1 focus:ring-primary-theme cursor-pointer max-w-[160px] truncate",title:S,children:j.map(s=>e.jsx("option",{value:s.id,children:s.title},s.id))}),e.jsxs("div",{className:"bg-surface-secondary p-0.5 rounded-lg flex items-center border border-theme text-xs",children:[e.jsx("button",{onClick:()=>Y("score"),className:`px-2 py-1 rounded-md font-medium transition-all ${w==="score"?"bg-surface text-primary-theme shadow-xs font-bold":"text-muted hover:text-main"}`,title:n==="zh"?"按累计得分排序":"By Cumulative Score",children:n==="zh"?"累计得分":"Score"}),e.jsx("button",{onClick:()=>Y("accuracy"),className:`px-2 py-1 rounded-md font-medium transition-all ${w==="accuracy"?"bg-surface text-primary-theme shadow-xs font-bold":"text-muted hover:text-main"}`,title:n==="zh"?"按正确率排序":"By Accuracy",children:n==="zh"?"正确率":"Accuracy"}),e.jsx("button",{onClick:()=>Y("count"),className:`px-2 py-1 rounded-md font-medium transition-all ${w==="count"?"bg-surface text-primary-theme shadow-xs font-bold":"text-muted hover:text-main"}`,title:n==="zh"?"按答题题次排序":"By Quiz Count",children:n==="zh"?"题次":"Count"})]}),N&&e.jsxs("button",{onClick:W,disabled:G,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-bold bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-400 border border-amber-200 dark:border-amber-800 hover:bg-amber-100 transition-colors cursor-pointer shadow-xs disabled:opacity-50",title:n==="zh"?"模拟学生实时答题":"Simulate Quiz Responses",children:[e.jsx(ge,{size:12,className:G?"animate-spin text-amber-600":"text-amber-600"}),e.jsx("span",{className:"hidden sm:inline",children:n==="zh"?"模拟答题":"Simulate"})]}),e.jsx("button",{onClick:()=>A(p),disabled:ee,className:"p-1.5 rounded-lg border border-theme bg-surface hover:bg-surface-secondary text-muted hover:text-main transition-colors cursor-pointer shadow-xs disabled:opacity-50",title:n==="zh"?"刷新榜单数据":"Refresh rankings",children:e.jsx(we,{size:14,className:ee?"animate-spin text-primary-theme":""})}),e.jsx("button",{onClick:$,disabled:z.length===0,className:"p-1.5 rounded-lg border border-theme bg-surface hover:bg-surface-secondary text-muted hover:text-main transition-colors cursor-pointer shadow-xs disabled:opacity-40",title:n==="zh"?"导出 Top 5 榜单 CSV":"Export CSV",children:e.jsx(je,{size:14})})]})]}),z.length===0?e.jsxs("div",{className:"p-8 rounded-xl border border-dashed border-theme bg-surface-secondary/20 flex flex-col items-center justify-center text-center gap-2",children:[e.jsx(ce,{size:28,className:"text-muted/60"}),e.jsx("p",{className:"text-sm font-semibold text-main",children:n==="zh"?"暂无随堂作答数据":"No Quiz Responses Yet"}),e.jsx("p",{className:"text-xs text-muted max-w-sm",children:n==="zh"?"学生开始作答随堂测验或白板互动题后,实时榜单与答题数据将自动刷新呈现。":"Rankings and visual distribution will appear here once students submit answers."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:z.slice(0,3).map(s=>{const m=s.rank===1,u=s.rank===2;s.rank;const x=m?"border-amber-400/50 bg-amber-500/5":u?"border-indigo-400/40 bg-indigo-500/5":"border-emerald-400/40 bg-emerald-500/5",d=m?"bg-amber-500 text-white":u?"bg-indigo-500 text-white":"bg-emerald-500 text-white",h=m?"🥇":u?"🥈":"🥉";return e.jsxs("div",{"data-testid":"top-performers-item",className:`p-3.5 rounded-xl border ${x} flex flex-col justify-between gap-3 relative transition-all hover:shadow-sm`,children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center font-extrabold text-sm shadow-xs ${d}`,children:h}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-main leading-tight truncate max-w-[130px]",children:s.studentName}),e.jsxs("span",{className:"text-xs text-muted flex items-center gap-1 mt-0.5",children:[e.jsx(ye,{size:11,className:"text-emerald-500"}),s.correctCount,"/",s.totalQuizzesAnswered," ",n==="zh"?"题全对":"correct"]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-base font-extrabold text-main font-mono",children:[s.cumulativeScore," ",e.jsx("span",{className:"text-xs font-normal text-muted",children:n==="zh"?"分":"pts"})]}),e.jsxs("span",{className:"text-xs font-semibold px-1.5 py-0.2 rounded bg-surface border border-theme text-primary-theme",children:[s.accuracy,"% ",n==="zh"?"正确率":"acc"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted pt-2 border-t border-theme/40",children:[e.jsxs("span",{className:"flex items-center gap-1 font-mono",children:[e.jsx(Z,{size:11})," ",s.avgTimeSpentMs?`${(s.avgTimeSpentMs/1e3).toFixed(1)}s`:"—"," ",n==="zh"?"均速":"avg"]}),m&&e.jsxs("button",{onClick:()=>D(s),className:"flex items-center gap-1 text-xs font-semibold text-amber-600 hover:text-amber-700 dark:text-amber-400 hover:underline cursor-pointer",title:n==="zh"?"一键表扬榜首":"Praise top performer",children:[e.jsx(be,{size:11})," ",n==="zh"?"一键表扬":"Praise"]})]})]},s.studentId)})}),e.jsxs("div",{className:"bg-surface-secondary/40 border border-theme rounded-xl p-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted px-1",children:[e.jsxs("span",{className:"font-semibold text-main flex items-center gap-1.5",children:[e.jsx(ve,{size:14,className:"text-primary-theme"}),n==="zh"?`Top 5 答题得分可视化分布 (${w==="score"?"累计得分":w==="accuracy"?"正确率%":"答题数"})`:`Top 5 Visual Distribution (${w.toUpperCase()})`]}),e.jsx("span",{className:"text-xs text-muted font-mono",children:n==="zh"?`全班平均得分: ${L.averageScore} 分 | 参与人次: ${L.totalResponses}`:`Class Avg: ${L.averageScore} pts | Responses: ${L.totalResponses}`})]}),e.jsx("div",{"data-testid":"top-performers-chart",className:"w-full h-56 pt-2",children:e.jsx(Re,{width:"100%",height:"100%",children:e.jsxs(Se,{data:J,layout:"vertical",margin:{top:8,right:36,left:10,bottom:8},children:[e.jsx(Ae,{strokeDasharray:"3 3",horizontal:!1,stroke:"currentColor",className:"text-theme/40"}),e.jsx($e,{type:"number",domain:[0,w==="accuracy"?100:"auto"],tick:{fontSize:11,fill:"currentColor"},className:"text-muted",unit:w==="accuracy"?"%":""}),e.jsx(Te,{type:"category",dataKey:"name",tick:{fontSize:12,fill:"currentColor",fontWeight:600},className:"text-main",width:85}),e.jsx(Ee,{content:({active:s,payload:m})=>{if(s&&m&&m.length){const u=m[0].payload;return e.jsxs("div",{className:"bg-surface border border-theme p-3 rounded-xl shadow-lg text-xs flex flex-col gap-1.5 min-w-[180px] z-50",children:[e.jsx("div",{className:"flex items-center justify-between font-bold text-main border-b border-theme/60 pb-1",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"w-5 h-5 rounded-full bg-primary-theme/10 text-primary-theme flex items-center justify-center font-mono",children:["#",u.rank]}),u.fullName]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-2 gap-y-1 text-muted pt-1",children:[e.jsx("span",{children:n==="zh"?"累计得分:":"Total Score:"}),e.jsxs("span",{className:"font-bold text-main font-mono text-right",children:[u.score," 分"]}),e.jsx("span",{children:n==="zh"?"正确率:":"Accuracy:"}),e.jsxs("span",{className:"font-bold text-emerald-600 dark:text-emerald-400 font-mono text-right",children:[u.accuracy,"%"]}),e.jsx("span",{children:n==="zh"?"答对题次:":"Correct Count:"}),e.jsxs("span",{className:"font-mono text-right",children:[u.correctCount," / ",u.count," 题"]}),e.jsx("span",{children:n==="zh"?"平均答题速度:":"Avg Speed:"}),e.jsxs("span",{className:"font-mono text-right",children:[u.avgTimeSec," 秒"]})]})]})}return null}}),e.jsxs(Pe,{dataKey:"chartValue",radius:[0,6,6,0],barSize:22,children:[J.map((s,m)=>e.jsx(De,{fill:ue[m%ue.length]},`cell-${s.studentId}-${m}`)),e.jsx(_e,{dataKey:"chartValue",position:"right",formatter:s=>w==="accuracy"?`${s}%`:w==="score"?`${s}分`:`${s}题`,className:"fill-main text-xs font-bold font-mono"})]})]})})})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-2 text-xs text-muted pt-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ne,{size:12,className:"text-primary-theme"}),n==="zh"?"统计口径: 课中互动测验与答题器":"Scope: Live interactive quizzes & clickers"]}),e.jsx("span",{className:"hidden sm:inline text-theme",children:"•"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ze,{size:12,className:"text-amber-500"}),n==="zh"?"实时随堂竞赛积分制":"Gamified Live Quiz Points"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:z.length>0&&e.jsx("span",{className:"text-xs text-muted font-medium",children:n==="zh"?`榜首: ${z[0].studentName} (${z[0].cumulativeScore}分)`:`Leader: ${z[0].studentName} (${z[0].cumulativeScore} pts)`})})]})]})}const xe=[{id:"1m",label:"1 分钟快速提问",duration:60,icon:"⚡"},{id:"3m",label:"3 分钟温故知新",duration:180,icon:"📖"},{id:"5m",label:"5 分钟随堂小测",duration:300,icon:"📝"},{id:"10m",label:"10 分钟小组研讨",duration:600,icon:"👥"},{id:"15m",label:"15 分钟探究实验",duration:900,icon:"🔬"},{id:"25m",label:"25 分钟番茄专注",duration:1500,icon:"🍅"},{id:"45m",label:"45 分钟完整自习",duration:2700,icon:"⏱️"}],he=["📝 随堂小测","👥 小组研讨","🎯 专注练习","⚡ 限时答题","📖 课前预热","💬 自由提问"];function Le(){try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,g=o.currentTime,j=o.createOscillator(),C=o.createGain();j.type="sine",j.frequency.setValueAtTime(523.25,g),j.frequency.exponentialRampToValueAtTime(783.99,g+.25),C.gain.setValueAtTime(.3,g),C.gain.exponentialRampToValueAtTime(.001,g+.8),j.connect(C),C.connect(o.destination),j.start(g),j.stop(g+.8);const v=o.createOscillator(),y=o.createGain();v.type="triangle",v.frequency.setValueAtTime(659.25,g+.15),v.frequency.exponentialRampToValueAtTime(1046.5,g+.4),y.gain.setValueAtTime(.2,g+.15),y.gain.exponentialRampToValueAtTime(.001,g+1.2),v.connect(y),y.connect(o.destination),v.start(g+.15),v.stop(g+1.2)}catch{}}function Ie({lessonId:n,lang:o="zh",compact:g=!1,variant:j="card",syncChannel:C,onlineStudentCount:v=0,onTimeRemainingChange:y,className:Q=""}){const[r,B]=l.useState({lessonId:n,totalDuration:300,timeRemaining:300,isRunning:!1,isPaused:!1,label:o==="zh"?"📝 随堂小测":"📝 In-Class Quiz",endsAt:null,updatedAt:Date.now()}),[N,p]=l.useState(!0),[q,w]=l.useState(!1),[Y,ee]=l.useState("5"),[U,G]=l.useState(!1),[F,z]=l.useState(""),[K,L]=l.useState(!1),[M,te]=l.useState([]),[P,A]=l.useState(!1),W=l.useRef(null);l.useEffect(()=>{if(!P)return;const t=i=>{W.current&&!W.current.contains(i.target)&&A(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[P]);const D=l.useRef(null),$=l.useRef(r);$.current=r;const J=l.useCallback(async()=>{if(!n)return;const t=`openlearn_classroom_countdown_${n}`;try{const i=localStorage.getItem(t);if(i){const a=JSON.parse(i);if(a&&typeof a.timeRemaining=="number"){if(a.isRunning&&a.endsAt){const c=Date.now(),f=Math.max(0,Math.round((a.endsAt-c)/1e3));a.timeRemaining=f,f===0&&(a.isRunning=!1,a.isPaused=!1,a.endsAt=null)}B(a)}}}catch{}try{const i=await fetch(`/api/classroom/sessions/${n}/countdown`);if(i.ok){const a=await i.json();a.success&&a.countdown&&B(c=>{const f=a.countdown;return f.totalDuration>0||f.isRunning?f:c})}}catch{}},[n]);l.useEffect(()=>{J()},[J]);const S=l.useCallback(t=>{if(B(t),n)try{localStorage.setItem(`openlearn_classroom_countdown_${n}`,JSON.stringify(t))}catch{}y?.(t.timeRemaining,t.isRunning),C&&C.broadcastCountdown(t),n&&fetch(`/api/classroom/sessions/${n}/countdown`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t.isRunning?"start":t.isPaused?"pause":"set",duration:t.totalDuration,label:t.label})}).catch(()=>{});try{window.dispatchEvent(new CustomEvent("openlearn:countdown:updated",{detail:t}))}catch{}},[n,y,C]);l.useEffect(()=>(r.isRunning&&r.endsAt?D.current=setInterval(()=>{const t=$.current;if(!t.isRunning||!t.endsAt)return;const i=Date.now(),a=Math.max(0,Math.round((t.endsAt-i)/1e3));if(a!==t.timeRemaining){const c={...t,timeRemaining:a,updatedAt:i};if(a<=0){c.isRunning=!1,c.isPaused=!1,c.endsAt=null,N&&Le();try{window.dispatchEvent(new CustomEvent("openlearn:countdown:expired",{detail:{lessonId:n,label:t.label,totalDuration:t.totalDuration}}))}catch{}}B(c),y?.(c.timeRemaining,c.isRunning),C?.broadcastCountdown(c);try{window.dispatchEvent(new CustomEvent("openlearn:countdown:tick",{detail:{timeRemaining:c.timeRemaining,totalDuration:c.totalDuration}}))}catch{}}},500):D.current&&(clearInterval(D.current),D.current=null),()=>{D.current&&clearInterval(D.current)}),[r.isRunning,r.endsAt,N,n,y,C]);const s=(t,i)=>{const a=Date.now(),c=t>0?t:r.totalDuration||300,f=i||r.label,V={lessonId:n,totalDuration:c,timeRemaining:c,isRunning:!0,isPaused:!1,label:f,endsAt:a+c*1e3,updatedAt:a};S(V);try{window.dispatchEvent(new CustomEvent("openlearn:countdown:started",{detail:V}))}catch{}},m=()=>{const t=Date.now(),i=$.current,a=i.endsAt?Math.max(0,Math.round((i.endsAt-t)/1e3)):i.timeRemaining,c={...i,timeRemaining:a,isRunning:!1,isPaused:!0,endsAt:null,updatedAt:t};S(c);try{window.dispatchEvent(new CustomEvent("openlearn:countdown:paused",{detail:c}))}catch{}},u=()=>{const t=Date.now(),i=$.current,a=i.timeRemaining>0?i.timeRemaining:i.totalDuration||300,c={...i,timeRemaining:a,isRunning:!0,isPaused:!1,endsAt:t+a*1e3,updatedAt:t};S(c);try{window.dispatchEvent(new CustomEvent("openlearn:countdown:resumed",{detail:c}))}catch{}},x=()=>{const t=Date.now(),i=$.current,a={...i,timeRemaining:i.totalDuration||300,isRunning:!1,isPaused:!1,endsAt:null,updatedAt:t};S(a);try{window.dispatchEvent(new CustomEvent("openlearn:countdown:reset",{detail:a}))}catch{}},d=t=>{const i=Date.now(),a=$.current,c=Math.max(0,a.timeRemaining+t),f=Math.max(a.totalDuration,c),V={...a,totalDuration:f,timeRemaining:c,endsAt:a.isRunning?i+c*1e3:null,updatedAt:i};S(V)};l.useEffect(()=>{const t={getState:()=>$.current,start:(R,E)=>s(R,E),pause:()=>m(),resume:()=>u(),reset:()=>x(),addTime:R=>d(R),registerPreset:R=>{te(E=>E.some(se=>se.id===R.id)?E:[...E,R])},getPresets:()=>[...xe,...M]};window.__openlearn_countdown=t;const i=R=>{const{duration:E,label:se}=R.detail||{};s(E||300,se)},a=()=>m(),c=()=>u(),f=()=>x(),V=R=>{const{seconds:E}=R.detail||{};d(E||60)};return window.addEventListener("openlearn:countdown:trigger_start",i),window.addEventListener("openlearn:countdown:trigger_pause",a),window.addEventListener("openlearn:countdown:trigger_resume",c),window.addEventListener("openlearn:countdown:trigger_reset",f),window.addEventListener("openlearn:countdown:trigger_add_time",V),()=>{window.removeEventListener("openlearn:countdown:trigger_start",i),window.removeEventListener("openlearn:countdown:trigger_pause",a),window.removeEventListener("openlearn:countdown:trigger_resume",c),window.removeEventListener("openlearn:countdown:trigger_reset",f),window.removeEventListener("openlearn:countdown:trigger_add_time",V)}},[M]);const h=t=>{const i=Math.floor(t/60),a=t%60,c=f=>f.toString().padStart(2,"0");return`${c(i)}:${c(a)}`},H=r.totalDuration>0?Math.min(100,Math.max(0,r.timeRemaining/r.totalDuration*100)):0,T=r.timeRemaining>0&&r.timeRemaining<=60,_=r.timeRemaining>60&&r.timeRemaining<=180,X=T?"text-rose-500":_?"text-amber-500":"text-primary-theme",O=T?"bg-rose-500":_?"bg-amber-500":"bg-primary-theme",b=[...xe,...M],k=()=>q?e.jsxs("div",{id:"classroom-countdown-projector-modal",className:"fixed inset-0 z-50 bg-black/85 backdrop-blur-md flex flex-col items-center justify-center p-6 select-none animate-in fade-in duration-200",children:[e.jsxs("div",{className:"absolute top-6 right-6 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>p(!N),className:"p-2.5 rounded-xl bg-white/10 hover:bg-white/20 text-white transition-colors cursor-pointer",children:N?e.jsx(ne,{size:20}):e.jsx(oe,{size:20})}),e.jsx("button",{type:"button",onClick:()=>w(!1),className:"p-2.5 rounded-xl bg-white/10 hover:bg-white/20 text-white transition-colors cursor-pointer",children:e.jsx(ke,{size:20})})]}),e.jsxs("div",{className:"flex flex-col items-center gap-6 max-w-2xl w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 rounded-full bg-white/10 border border-white/20 text-white text-sm font-bold",children:[e.jsx(be,{size:16,className:"text-amber-300"}),e.jsx("span",{children:r.label}),e.jsx("span",{className:"text-xs text-white/60 ml-2",children:o==="zh"?`全班 ${v} 位学生正在同步`:`${v} students connected`})]}),e.jsx("div",{className:`text-8xl md:text-9xl font-black font-mono tracking-widest drop-shadow-2xl transition-all ${T?"text-rose-500 animate-pulse":_?"text-amber-400":"text-emerald-400"}`,children:h(r.timeRemaining)}),e.jsx("div",{className:"w-full h-3 bg-white/10 rounded-full overflow-hidden border border-white/20 shadow-inner",children:e.jsx("div",{className:`h-full transition-all duration-500 ${T?"bg-rose-500":_?"bg-amber-400":"bg-emerald-400"}`,style:{width:`${H}%`}})}),e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[r.isRunning?e.jsxs("button",{type:"button",onClick:m,className:"px-8 py-3 rounded-2xl bg-amber-700 hover:bg-amber-800 text-white font-bold text-lg transition-transform active:scale-95 shadow-xl flex items-center gap-2 cursor-pointer",children:[e.jsx(re,{size:20}),e.jsx("span",{children:o==="zh"?"暂停":"Pause"})]}):r.isPaused?e.jsxs("button",{type:"button",onClick:u,className:"px-8 py-3 rounded-2xl bg-emerald-700 hover:bg-emerald-800 text-white font-bold text-lg transition-transform active:scale-95 shadow-xl flex items-center gap-2 cursor-pointer",children:[e.jsx(I,{size:20}),e.jsx("span",{children:o==="zh"?"继续":"Resume"})]}):e.jsxs("button",{type:"button",onClick:()=>s(r.totalDuration||300),className:"px-8 py-3 rounded-2xl bg-primary-theme hover:opacity-90 text-white font-bold text-lg transition-transform active:scale-95 shadow-xl flex items-center gap-2 cursor-pointer",children:[e.jsx(I,{size:20}),e.jsx("span",{children:o==="zh"?"开始":"Start"})]}),e.jsx("button",{type:"button",onClick:()=>d(60),className:"px-5 py-3 rounded-2xl bg-white/10 hover:bg-white/20 text-white font-bold text-base transition-colors cursor-pointer border border-white/20",children:"+1 分钟"}),e.jsx("button",{type:"button",onClick:()=>d(300),className:"px-5 py-3 rounded-2xl bg-white/10 hover:bg-white/20 text-white font-bold text-base transition-colors cursor-pointer border border-white/20",children:"+5 分钟"}),e.jsx("button",{type:"button",onClick:x,className:"p-3 rounded-2xl bg-white/10 hover:bg-white/20 text-white font-bold transition-colors cursor-pointer border border-white/20",title:"重置",children:e.jsx(ae,{size:20})})]})]})]}):null;return j==="header"?e.jsxs("div",{ref:W,id:"classroom-countdown-header-container",className:`relative flex items-center shrink-0 ${Q}`,children:[e.jsxs("div",{id:"classroom-countdown-header-pill",className:`h-7 sm:h-8 px-2 py-0.5 rounded-lg border text-xs font-semibold flex items-center gap-1.5 shadow-2xs select-none transition-all ${r.isRunning?"bg-primary-theme/10 border-primary-theme/40 text-primary-theme ring-1 ring-primary-theme/20":"bg-surface border-theme text-main hover:bg-surface-secondary"}`,children:[e.jsx(Z,{size:13,className:`shrink-0 ${r.isRunning?"animate-spin text-primary-theme":"text-muted"}`,style:{animationDuration:"6s"}}),e.jsx("span",{className:"text-[11px] font-medium text-muted hidden xl:inline truncate max-w-[68px]",children:r.label}),e.jsx("span",{id:"classroom-countdown-digits",className:`font-mono font-black text-xs sm:text-sm tracking-wider ${T?"text-rose-500 animate-pulse":r.isRunning?"text-primary-theme font-extrabold":"text-main"}`,children:h(r.timeRemaining)}),e.jsxs("div",{className:"flex items-center gap-1 ml-0.5 border-l border-theme/60 pl-1.5",children:[r.isRunning?e.jsx("button",{type:"button",id:"classroom-countdown-pause-btn",onClick:m,className:"w-5 h-5 rounded-md bg-amber-700 text-white hover:bg-amber-800 flex items-center justify-center cursor-pointer transition-colors shadow-2xs",title:o==="zh"?"暂停倒计时":"Pause",children:e.jsx(re,{size:10})}):r.isPaused?e.jsx("button",{type:"button",id:"classroom-countdown-resume-btn",onClick:u,className:"w-5 h-5 rounded-md bg-emerald-600 text-white hover:bg-emerald-700 flex items-center justify-center cursor-pointer transition-colors shadow-2xs",title:o==="zh"?"继续倒计时":"Resume",children:e.jsx(I,{size:10})}):e.jsx("button",{type:"button",id:"classroom-countdown-start-btn",onClick:()=>s(r.totalDuration||300),className:"w-5 h-5 rounded-md bg-primary-theme text-white hover:opacity-90 flex items-center justify-center cursor-pointer transition-colors shadow-2xs",title:o==="zh"?"开始倒计时":"Start",children:e.jsx(I,{size:10})}),e.jsx("button",{type:"button",onClick:()=>d(60),className:"px-1.5 h-5 rounded bg-surface-secondary hover:bg-primary-theme/15 hover:text-primary-theme border border-theme/60 text-[10px] font-bold text-muted transition-colors cursor-pointer",title:o==="zh"?"增加1分钟":"+1m",children:"+1m"}),e.jsx("button",{type:"button",id:"classroom-countdown-settings-toggle",onClick:()=>A(!P),className:`w-5 h-5 rounded flex items-center justify-center text-muted hover:text-main hover:bg-surface-secondary transition-colors cursor-pointer ${P?"bg-surface-secondary text-main":""}`,title:o==="zh"?"倒计时设置与大屏投放":"Settings & Projector",children:e.jsx(de,{size:11,className:`transition-transform duration-200 ${P?"rotate-180":""}`})})]})]}),P&&e.jsxs("div",{id:"classroom-countdown-header-popover",className:"absolute right-0 top-full mt-1.5 w-72 bg-surface border border-theme rounded-2xl shadow-xl p-3 z-40 flex flex-col gap-2.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme/60 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold text-main",children:[e.jsx(Z,{size:13,className:"text-primary-theme"}),e.jsx("span",{children:o==="zh"?"课堂倒计时设置":"Countdown Settings"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>p(!N),className:`p-1 rounded-md text-xs transition-colors cursor-pointer border border-theme ${N?"text-primary-theme bg-surface":"text-muted bg-surface/50"}`,title:N?o==="zh"?"提示音已开启":"Sound On":o==="zh"?"提示音已静音":"Muted",children:N?e.jsx(ne,{size:12}):e.jsx(oe,{size:12})}),e.jsx("button",{type:"button",onClick:()=>{w(!0),A(!1)},className:"p-1 rounded-md text-xs text-muted hover:text-main bg-surface hover:bg-surface-secondary transition-colors cursor-pointer border border-theme",title:o==="zh"?"大屏全屏投放":"Projector Mode",children:e.jsx(le,{size:12})})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-1 text-[11px]",children:[e.jsx("span",{className:"text-muted font-medium",children:o==="zh"?"当前任务:":"Task:"}),e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("select",{value:r.label,onChange:t=>S({...r,label:t.target.value}),className:"px-2 py-0.5 rounded-lg bg-surface border border-theme text-xs font-semibold text-main outline-none cursor-pointer",children:he.map(t=>e.jsx("option",{value:t,children:t},t))})})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-muted font-semibold uppercase tracking-wider",children:o==="zh"?"快捷预设":"Presets"}),e.jsx("div",{className:"grid grid-cols-3 gap-1",children:b.slice(0,6).map(t=>e.jsxs("button",{type:"button",onClick:()=>{s(t.duration,t.label),A(!1)},className:`px-1.5 py-1 rounded-lg text-[10px] font-bold transition-all cursor-pointer border flex items-center justify-center gap-1 ${r.totalDuration===t.duration&&r.isRunning?"bg-primary-theme text-white border-primary-theme shadow-2xs":"bg-surface hover:bg-surface-secondary text-main border-theme"}`,title:t.label,children:[e.jsx("span",{children:t.icon||"⏱️"}),e.jsxs("span",{children:[t.duration/60,"m"]})]},t.id))})]}),e.jsxs("div",{className:"flex items-center justify-between gap-1 pt-1.5 border-t border-theme/60",children:[e.jsxs("button",{type:"button",id:"classroom-countdown-header-reset-btn",onClick:x,className:"px-2 py-1 rounded-lg bg-surface hover:bg-surface-secondary border border-theme text-xs font-semibold text-muted hover:text-main transition-colors flex items-center gap-1 cursor-pointer",children:[e.jsx(ae,{size:11}),e.jsx("span",{children:o==="zh"?"重置":"Reset"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>d(-60),disabled:r.timeRemaining<=60,className:"px-2 py-1 rounded-lg bg-surface hover:bg-surface-secondary border border-theme text-xs font-bold text-muted hover:text-main disabled:opacity-40 transition-colors cursor-pointer",children:"-1m"}),e.jsx("button",{type:"button",onClick:()=>d(60),className:"px-2 py-1 rounded-lg bg-surface hover:bg-surface-secondary border border-theme text-xs font-bold text-muted hover:text-main transition-colors cursor-pointer",children:"+1m"}),e.jsx("button",{type:"button",onClick:()=>d(300),className:"px-2 py-1 rounded-lg bg-surface hover:bg-surface-secondary border border-theme text-xs font-bold text-primary-theme hover:bg-primary-theme/10 transition-colors cursor-pointer",children:"+5m"})]})]})]}),k()]}):e.jsxs("div",{id:"classroom-countdown-widget",className:`bg-surface-secondary border border-theme rounded-2xl p-3.5 flex flex-col gap-2.5 shadow-sm transition-all ${Q}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-1 select-none",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"p-1 rounded-lg bg-primary-theme/10 text-primary-theme shrink-0",children:e.jsx(Z,{size:13,className:r.isRunning?"animate-spin":"",style:{animationDuration:"6s"}})}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"text-xs font-black uppercase tracking-wider text-main truncate flex items-center gap-1",children:o==="zh"?"课堂倒计时":"Classroom Countdown"}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-muted",children:[e.jsx(pe,{size:9,className:r.isRunning?"text-emerald-500 animate-pulse":"text-muted"}),e.jsx("span",{children:r.isRunning?o==="zh"?`实时广播中 (${v}人)`:`Broadcasting (${v})`:o==="zh"?"就绪":"Ready"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>p(!N),className:`p-1 rounded-md text-xs transition-colors cursor-pointer border border-theme ${N?"text-primary-theme bg-surface":"text-muted bg-surface/50"}`,title:N?o==="zh"?"提示音已开启":"Sound On":o==="zh"?"提示音已静音":"Muted",children:N?e.jsx(ne,{size:12}):e.jsx(oe,{size:12})}),e.jsx("button",{type:"button",onClick:()=>w(!0),className:"p-1 rounded-md text-xs text-muted hover:text-main bg-surface hover:bg-surface-secondary transition-colors cursor-pointer border border-theme",title:o==="zh"?"展台大屏全屏投放":"Projector Mode",children:e.jsx(le,{size:12})})]})]}),e.jsxs("div",{className:"relative",children:[K?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"text",value:F,onChange:t=>z(t.target.value),placeholder:"输入任务名称...",className:"flex-1 px-2 py-0.5 text-xs bg-surface border border-theme rounded-md text-main focus:outline-hidden focus:ring-1 focus:ring-primary-theme",autoFocus:!0}),e.jsx("button",{type:"button",onClick:()=>{F.trim()&&S({...r,label:F.trim()}),L(!1)},className:"p-1 rounded bg-primary-theme text-white text-xs cursor-pointer",children:e.jsx(me,{size:11})})]}):e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsxs("button",{type:"button",onClick:()=>G(!U),className:"flex items-center gap-1 text-[11px] font-semibold text-muted hover:text-main px-1.5 py-0.5 rounded-md hover:bg-surface transition-colors cursor-pointer border border-transparent hover:border-theme truncate",title:"切换任务类型",children:[e.jsx(Ce,{size:10,className:"shrink-0 text-primary-theme"}),e.jsx("span",{className:"truncate",children:r.label}),e.jsx(de,{size:10,className:"shrink-0 opacity-60"})]}),e.jsx("button",{type:"button",onClick:()=>{z(r.label),L(!0)},className:"text-[10px] text-muted hover:text-primary-theme underline cursor-pointer shrink-0",children:o==="zh"?"自定义":"Custom"})]}),U&&e.jsx("div",{className:"absolute left-0 top-full mt-1 w-full bg-surface border border-theme rounded-xl shadow-lg p-1.5 z-30 flex flex-col gap-0.5",children:he.map(t=>e.jsxs("button",{type:"button",onClick:()=>{S({...r,label:t}),G(!1)},className:`text-left px-2 py-1 text-xs rounded-lg transition-colors cursor-pointer flex items-center justify-between ${r.label===t?"bg-primary-theme/10 text-primary-theme font-bold":"text-main hover:bg-surface-secondary"}`,children:[e.jsx("span",{children:t}),r.label===t&&e.jsx(me,{size:10})]},t))})]}),e.jsxs("div",{className:"flex flex-col items-center justify-center p-3 bg-surface border border-theme rounded-xl relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 bg-surface-secondary overflow-hidden",children:e.jsx("div",{className:`h-full transition-all duration-500 ${O}`,style:{width:`${H}%`}})}),e.jsx("div",{id:"classroom-countdown-digits",className:`text-3xl font-black font-mono tracking-widest transition-colors ${T?"animate-pulse text-rose-500":X}`,children:h(r.timeRemaining)}),e.jsx("span",{className:"text-[10px] font-semibold text-muted mt-0.5",children:r.timeRemaining===0?o==="zh"?"⏰ 时间到!建议点评总结":"⏰ Time is up!":`${o==="zh"?"总设时长":"Total"}: ${h(r.totalDuration)}`})]}),e.jsxs("div",{className:"flex items-center gap-1.5 w-full",children:[r.isRunning?e.jsxs("button",{type:"button",id:"classroom-countdown-pause-btn",onClick:m,className:"flex-1 py-1.5 px-3 rounded-xl bg-amber-700 hover:bg-amber-800 text-white text-xs font-bold transition-all shadow-sm flex items-center justify-center gap-1.5 cursor-pointer",children:[e.jsx(re,{size:12}),e.jsx("span",{children:o==="zh"?"暂停计时":"Pause"})]}):r.isPaused?e.jsxs("button",{type:"button",id:"classroom-countdown-resume-btn",onClick:u,className:"flex-1 py-1.5 px-3 rounded-xl bg-emerald-600 hover:bg-emerald-700 text-white text-xs font-bold transition-all shadow-sm flex items-center justify-center gap-1.5 cursor-pointer",children:[e.jsx(I,{size:12}),e.jsx("span",{children:o==="zh"?"继续计时":"Resume"})]}):e.jsxs("button",{type:"button",id:"classroom-countdown-start-btn",onClick:()=>s(r.totalDuration||300),className:"flex-1 py-1.5 px-3 rounded-xl bg-primary-theme hover:opacity-90 text-white text-xs font-bold transition-all shadow-sm flex items-center justify-center gap-1.5 cursor-pointer",children:[e.jsx(I,{size:12}),e.jsx("span",{children:o==="zh"?"开始倒计时":"Start"})]}),e.jsxs("button",{type:"button",id:"classroom-countdown-reset-btn",onClick:x,className:"p-1.5 px-2.5 rounded-xl bg-surface hover:bg-surface-secondary border border-theme text-xs font-bold text-muted hover:text-main transition-colors flex items-center justify-center gap-1 cursor-pointer",title:o==="zh"?"重置计时":"Reset",children:[e.jsx(ae,{size:12}),e.jsx("span",{className:"sr-only",children:"重置"})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-1 pt-1 border-t border-theme/60",children:[e.jsx("span",{className:"text-[10px] text-muted font-medium",children:o==="zh"?"快速调整:":"Adjust:"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>d(-60),disabled:r.timeRemaining<=60,className:"px-1.5 py-0.5 rounded-md bg-surface hover:bg-surface-secondary border border-theme text-[11px] font-bold text-muted hover:text-main disabled:opacity-40 transition-colors cursor-pointer",title:"减去1分钟",children:"-1m"}),e.jsx("button",{type:"button",onClick:()=>d(60),className:"px-1.5 py-0.5 rounded-md bg-surface hover:bg-surface-secondary border border-theme text-[11px] font-bold text-muted hover:text-main transition-colors cursor-pointer",title:"增加1分钟",children:"+1m"}),e.jsx("button",{type:"button",onClick:()=>d(300),className:"px-1.5 py-0.5 rounded-md bg-surface hover:bg-surface-secondary border border-theme text-[11px] font-bold text-primary-theme hover:bg-primary-theme/10 transition-colors cursor-pointer",title:"增加5分钟",children:"+5m"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 pt-1",children:[e.jsx("span",{className:"text-[10px] text-muted font-semibold uppercase tracking-wider",children:o==="zh"?"预设时长":"Presets"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:b.map(t=>e.jsxs("button",{type:"button",onClick:()=>s(t.duration,t.label),className:`px-1.5 py-0.5 rounded-lg text-[10px] font-bold transition-all cursor-pointer border ${r.totalDuration===t.duration&&r.isRunning?"bg-primary-theme text-white border-primary-theme":"bg-surface hover:bg-surface-secondary text-main border-theme"}`,title:t.label,children:[e.jsx("span",{children:t.icon||"⏱️"})," ",t.duration/60,"m"]},t.id))})]}),e.jsx(ie,{slot:"classroom.countdown.action",slotProps:{countdown:r,onStart:s,onPause:m,onReset:x,onAddTime:d,lang:o}}),e.jsx(ie,{slot:"classroom.countdown.widget",slotProps:{countdown:r,lang:o}}),k()]})}export{Ie as C,Fe as T};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,j as e}from"./vendor-react-Kv_JATwr.js";import{_ as Ae,E as M,c as Te}from"./index-DN3E-Fmw.js";import{am as fe,ak as Le,bu as J,bt as Pe,ac as Me,X as te,V as Re,a9 as be,U as je,z as Oe,ad as Fe,c as ye,ae as Ue,C as Be,Z as Je}from"./vendor-icons-hc6MjYFv.js";import"./vendor-utils-aM7aYvPP.js";import"./vendor-pdf-By0fofA0.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-SrpBsvM3.js";function qe({computerLabs:h,onRefresh:y,lang:n,classes:b}){const[q,w]=l.useState(!1),[R,V]=l.useState(null),[G,H]=l.useState(""),[N,K]=l.useState(5),[S,Y]=l.useState(6),[O,p]=l.useState(""),[se,ae]=l.useState(!1),ne="openlearn_computer_lab_selected",X="openlearn_computer_lab_selected_class",[A,re]=l.useState(()=>{try{const t=localStorage.getItem(ne);if(t&&h.some(s=>s.id===t))return t}catch{}return h.length>0?h[0].id:null}),o=h.find(t=>t.id===(A||h[0]?.id)),[ve,ie]=l.useState([]),[d,F]=l.useState(()=>{const t=o??h[0];if(!t)return null;const s=b||[];try{const a=localStorage.getItem(X),i=a?s.find(c=>c.id===a):void 0;if(i&&i.lab_id===t.id)return i.id}catch{}const r=s.find(a=>a.lab_id===t.id);return r?r.id:null}),[E,oe]=l.useState([]),[g,C]=l.useState([]),[le,de]=l.useState(!1),[Z,ce]=l.useState(!1),[xe,Q]=l.useState(""),[W,k]=l.useState(!1),[f,v]=l.useState(null),[we,$]=l.useState(null),[x,T]=l.useState(null),[I,L]=l.useState(null);l.useEffect(()=>{b&&b.length>0?ie(b):fetch("/api/classes?pageSize=all").then(t=>t.ok?t.json():{data:[]}).then(t=>{const s=Ae(t);(s.length>0||Array.isArray(t?.data))&&ie(s)}).catch(t=>console.error("Failed to fetch classes in ComputerLabManager:",t))},[b]);const _=b&&b.length>0?b:ve,ue=l.useMemo(()=>o?_.filter(t=>t.lab_id===o.id):[],[_,o]);l.useEffect(()=>{if(!o)return;if(d){_.find(s=>s.id===d);return}try{const s=localStorage.getItem(X),r=s?_.find(a=>a.id===s):void 0;if(r&&r.lab_id===o.id){F(r.id);return}}catch{}const t=_.find(s=>s.lab_id===o.id);t&&F(t.id)},[o?.id,_]),l.useEffect(()=>{try{A&&localStorage.setItem(ne,A)}catch{}},[A]),l.useEffect(()=>{try{d&&localStorage.setItem(X,d)}catch{}},[d]);const me=l.useCallback(async(t,s)=>{de(!0),p(""),v(null),$(null);try{const[r,a]=await Promise.all([fetch(`/api/classes/${t}/seats`),fetch(`/api/classes/${t}/students`)]);let i=[];if(a.ok&&(i=await a.json(),oe(i)),r.ok){const u=(await r.json()).seats||[],D=new Map(i.map(j=>[j.id,j])),U=u.map(j=>{const B=D.get(j.student_id);return{...j,student_name:j.student_name||B?.name||"",student_number:j.student_number||B?.student_number||""}});C(U)}k(!1)}catch(r){console.error("Error loading seating:",r),p(r.message||"Failed to load class seating data")}finally{de(!1)}},[]);l.useEffect(()=>{d?me(d,o?.id):(oe([]),C([]),k(!1),v(null),$(null))},[d,me]);const ee=l.useMemo(()=>{const t=new Map;for(const s of g)t.set(`${s.row_idx}_${s.col_idx}`,s);return t},[g]),he=l.useMemo(()=>new Set(g.map(t=>t.student_id)),[g]),z=l.useMemo(()=>E.filter(t=>!he.has(t.id)).sort((t,s)=>String(t.student_number??t.name??"").localeCompare(String(s.student_number??s.name??""),"zh-Hans-CN",{numeric:!0})),[E,he]),pe=(t,s,r)=>{const a=g.find(u=>u.row_idx===s.row&&u.col_idx===s.col),i=!!r&&!!a&&a.student_id!==t.id;let c=g.filter(u=>!(u.row_idx===s.row&&u.col_idx===s.col)&&u.student_id!==t.id);i&&r&&(c=c.filter(u=>!(u.row_idx===r.row&&u.col_idx===r.col)),c=[...c,{...a,row_idx:r.row,col_idx:r.col}]),c=[...c,{student_id:t.id,row_idx:s.row,col_idx:s.col,student_name:t.name,student_number:t.student_number}],C(c),k(!0)},Ne=(t,s)=>{if(!d||!o)return;const r=ee.get(`${t}_${s}`);if(f){pe(f,{row:t,col:s},we),v(null),$(null);return}if(r){const a=E.find(i=>i.id===r.student_id)||{id:r.student_id,name:r.student_name||"Student",student_number:r.student_number||""};v(a),$({row:t,col:s})}},Se=(t,s,r)=>{t.stopPropagation(),C(a=>a.filter(i=>!(i.row_idx===s&&i.col_idx===r))),k(!0)},_e=()=>{if(!o||z.length===0)return;const t=[];for(let a=0;a<o.rows;a++)for(let i=0;i<o.cols;i++)ee.has(`${a}_${i}`)||t.push([a,i]);if(t.length===0)return;const r=z.slice(0,t.length).map((a,i)=>{const[c,u]=t[i];return{student_id:a.id,row_idx:c,col_idx:u,student_name:a.name,student_number:a.student_number}});C(a=>[...a,...r]),k(!0),v(null)},ze=()=>{g.length!==0&&confirm(n==="zh"?"确定要清空当前班级在该机房的所有机位排座吗?":"Are you sure you want to clear all seat assignments for this class in this lab?")&&(C([]),k(!0),v(null))},Ce=async()=>{if(!(!d||!o))try{ce(!0),p(""),Q("");const t=await fetch(`/api/classes/${d}/seats`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lab_id:o.id,seats:g.map(s=>({student_id:s.student_id,row_idx:s.row_idx,col_idx:s.col_idx}))})});if(t.ok)k(!1),Q(n==="zh"?"统一机房排座已成功持久化至系统 student_seats 数据表!":"Seating assignments saved to system student_seats table successfully!"),y(),setTimeout(()=>Q(""),4e3);else{const s=await t.json();p(s.error||"Failed to save seats")}}catch(t){p(t.message||"Network error saving seats")}finally{ce(!1)}},ke=()=>{H(""),K(5),Y(6),p(""),V(null),w(!0)},$e=t=>{H(t.room_number),K(t.rows),Y(t.cols),p(""),V(t.id),w(!0)},Ee=async t=>{if(t.preventDefault(),!G.trim()){p(n==="zh"?"请输入机房编号/名称":"Please enter room name or number");return}if(N<=0||N>15){p(n==="zh"?"行数应在 1 至 15 之间":"Rows should be between 1 and 15");return}if(S<=0||S>15){p(n==="zh"?"列数应在 1 至 15 之间":"Columns should be between 1 and 15");return}try{ae(!0),p("");const s=R?`/api/labs/${R}`:"/api/labs",a=await fetch(s,{method:R?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({room_number:G.trim(),rows:N,cols:S})});if(a.ok)y(),w(!1),V(null);else{const i=await a.json();p(i.error||"Server error saving lab")}}catch(s){p(s.message||"Network error")}finally{ae(!1)}},De=async t=>{if(confirm(n==="zh"?"确定要删除该机房吗?删除后对应的座位分配也会被重置。":"Are you sure you want to delete this lab? Seat mappings will be cleared."))try{(await fetch(`/api/labs/${t}`,{method:"DELETE"})).ok&&(y(),A===t&&re(null))}catch(s){console.error(s)}};return e.jsxs("div",{className:"flex-1 flex flex-col h-full overflow-hidden",id:"lab_manager_root",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between pb-4 border-b border-gray-200 gap-4 shrink-0",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold text-gray-800 flex items-center gap-2",children:[e.jsx(fe,{className:"text-indigo-600",size:24}),n==="zh"?"统一机房座位管理":"Unified Computer Lab Seating"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:n==="zh"?"维护物理机房规格及其行列排列规则,并直接根据班级信息读取并编排系统中已存的统一机房座位数据(student_seats 表)。":"Maintain physical lab layouts and manage unified student seat allocations directly synced with existing system data tables."})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:ke,className:"bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-xl text-xs font-semibold flex items-center gap-1.5 shadow-sm transition-all focus:ring-2 focus:ring-indigo-500 cursor-pointer",children:[e.jsx(Le,{size:14}),n==="zh"?"新增机房规则":"New Lab Config"]}),e.jsx(M,{slot:"computer_lab.toolbar.action",slotProps:{activeLab:o,computerLabs:h,onRefresh:y,lang:n}})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 grid grid-cols-1 lg:grid-cols-12 gap-6 pt-5 overflow-hidden",children:[e.jsxs("div",{className:"lg:col-span-4 flex flex-col min-h-0 bg-white border border-gray-200 rounded-2xl shadow-xs overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 bg-gray-50 flex justify-between items-center shrink-0",children:[e.jsx("span",{className:"text-xs font-bold text-gray-700 uppercase tracking-wider block",children:n==="zh"?"机房列表":"Computer Labs"}),e.jsx("span",{className:"bg-gray-200 text-gray-700 font-bold px-2 py-0.5 rounded-full text-xs",children:h.length})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3",children:h.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center text-gray-400 h-full",children:[e.jsx(fe,{size:40,className:"mb-2 opacity-30"}),e.jsx("p",{className:"text-xs font-medium",children:n==="zh"?"暂无机房编号规则":"No Computer Labs configured yet."}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:n==="zh"?"点击右上角按钮添加首个机房规格。":"Click the button above to add your first computer room."})]}):h.map(t=>{const s=o?.id===t.id,r=_.filter(a=>a.lab_id===t.id);return e.jsxs("div",{onClick:()=>{re(t.id),w(!1)},className:`p-3 rounded-xl border transition-all cursor-pointer flex flex-col gap-2 group ${s?"border-indigo-300 bg-indigo-50/60 shadow-xs ring-1 ring-indigo-200":"border-gray-150 hover:border-gray-300 hover:bg-gray-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${s?"bg-indigo-600 text-white":"bg-gray-100 text-gray-500 group-hover:bg-gray-200"}`,children:e.jsx(J,{size:16})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-bold text-gray-800 flex items-center gap-1.5",children:t.room_number}),e.jsxs("div",{className:"text-xs text-gray-400 font-mono mt-0.5",children:[t.rows," ",n==="zh"?"行":"Rows"," × ",t.cols," ",n==="zh"?"列":"Cols",e.jsx("span",{className:"mx-1.5",children:"•"}),t.rows*t.cols," ",n==="zh"?"个机位":"Seats"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:a=>{a.stopPropagation(),$e(t)},className:"p-1 text-gray-500 hover:text-indigo-600 hover:bg-white rounded transition-colors",title:n==="zh"?"编辑规则":"Edit Rule",children:e.jsx(Pe,{size:13})}),e.jsx("button",{onClick:a=>{a.stopPropagation(),De(t.id)},className:"p-1 text-gray-500 hover:text-rose-600 hover:bg-white rounded transition-colors",title:n==="zh"?"删除机房间":"Delete Lab",children:e.jsx(Me,{size:14})})]})]}),r.length>0&&e.jsxs("div",{className:"flex items-center gap-1 flex-wrap pt-1 border-t border-gray-100/80",children:[e.jsx("span",{className:"text-[10px] text-gray-400 font-medium",children:n==="zh"?"绑定班级:":"Bound:"}),r.map(a=>e.jsx("span",{className:"text-[10px] font-semibold bg-indigo-100/70 text-indigo-700 px-1.5 py-0.5 rounded-md",children:a.name},a.id))]})]},t.id)})})]}),e.jsx("div",{className:"lg:col-span-8 flex flex-col min-h-0 bg-white border border-gray-200 rounded-2xl shadow-xs overflow-hidden",children:q?e.jsxs("form",{onSubmit:Ee,className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 bg-gray-50 font-bold text-xs text-gray-700 uppercase tracking-wider shrink-0 flex items-center justify-between",children:[e.jsx("span",{children:R?n==="zh"?"编辑机房规则":"Edit Lab Seating":n==="zh"?"创建全新上机机房":"Create Computer Lab"}),e.jsx("button",{type:"button",onClick:()=>w(!1),className:"text-gray-400 hover:text-gray-600",children:e.jsx(te,{size:16})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:[O&&e.jsxs("div",{className:"p-3 bg-red-50 border border-red-200 text-red-700 text-xs rounded-xl flex items-center gap-1.5",children:[e.jsx(Re,{size:14}),e.jsx("span",{children:O})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wide",children:n==="zh"?"机房编号 / 场所名称 *":"Lab Name / Number *"}),e.jsx("input",{type:"text",value:G,onChange:t=>H(t.target.value),placeholder:n==="zh"?"例如:305综合机房、软创中心、Lab A":"e.g. Lab 404, Software Sandbox, Suite C",className:"w-full text-xs p-2.5 border border-gray-300 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 rounded-xl mt-1.5",maxLength:32,required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wide",children:n==="zh"?"排列行数 (Rows) *":"Rows Direction *"}),e.jsx("input",{type:"number",value:N,onChange:t=>K(Math.max(1,parseInt(t.target.value)||1)),min:1,max:15,className:"w-full text-xs p-2.5 border border-gray-300 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 rounded-xl mt-1.5",required:!0}),e.jsx("span",{className:"text-xs text-gray-400 block mt-0.5",children:n==="zh"?"上下方向机位数 (最大15行)":"Horizontal sets count (Max 15)"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wide",children:n==="zh"?"排列列数 (Columns) *":"Columns Direction *"}),e.jsx("input",{type:"number",value:S,onChange:t=>Y(Math.max(1,parseInt(t.target.value)||1)),min:1,max:15,className:"w-full text-xs p-2.5 border border-gray-300 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 rounded-xl mt-1.5",required:!0}),e.jsx("span",{className:"text-xs text-gray-400 block mt-0.5",children:n==="zh"?"左右方向机位数 (最大15列)":"Vertical sets count (Max 15)"})]})]}),e.jsxs("div",{className:"border border-dashed border-gray-200 bg-gray-50/50 p-4 rounded-xl",children:[e.jsx("span",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider block mb-2",children:n==="zh"?"布局网格缩略结构":"Layout Aspect Schema"}),e.jsxs("div",{className:"flex flex-col gap-1 items-center justify-center p-3 bg-white rounded-lg border border-gray-100 min-h-[120px]",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[Array.from({length:Math.min(N,6)}).map((t,s)=>e.jsxs("div",{className:"flex gap-1 justify-center",children:[Array.from({length:Math.min(S,8)}).map((r,a)=>e.jsx("div",{className:"w-4 h-4 rounded bg-indigo-100 border border-indigo-200 shrink-0"},a)),S>8&&e.jsx("div",{className:"w-4 text-xs text-gray-400 flex items-center justify-center",children:"..."})]},s)),N>6&&e.jsx("div",{className:"text-xs text-center text-gray-400 mt-1",children:"..."})]}),e.jsxs("span",{className:"text-xs text-gray-450 mt-3 font-medium",children:["配置容量:",N," × ",S," = ",N*S," 座位"]})]})]})]}),e.jsxs("div",{className:"p-4 border-t border-gray-100 shrink-0 flex items-center justify-end gap-2 bg-gray-50",children:[e.jsx("button",{type:"button",onClick:()=>w(!1),className:"px-4 py-2 text-xs font-semibold text-gray-500 hover:text-gray-700 bg-white hover:bg-gray-100 border border-gray-200 rounded-xl transition-all cursor-pointer",children:n==="zh"?"取消":"Cancel"}),e.jsxs("button",{type:"submit",disabled:se,className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 rounded-xl flex items-center gap-1 shadow-sm transition-all cursor-pointer",children:[e.jsx(be,{size:14}),e.jsx("span",{children:se?n==="zh"?"提交中...":"Saving...":n==="zh"?"提交保存":"Save Config"})]})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"p-3 border-b border-gray-100 bg-gray-50 flex flex-wrap items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-bold text-gray-700 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(je,{size:14,className:"text-indigo-600"}),n==="zh"?"班级机位联动:":"Class Seating Link:"]}),e.jsxs("select",{value:d||"",onChange:t=>F(t.target.value?t.target.value:null),className:"text-xs font-semibold bg-white border border-gray-300 rounded-lg px-2.5 py-1.5 text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 cursor-pointer shadow-2xs",children:[e.jsx("option",{value:"",children:n==="zh"?"📐 物理规格总览 (无班级)":"📐 Physical Blueprint (No Class)"}),_.map(t=>{const s=t.lab_id===o?.id;return e.jsxs("option",{value:t.id,children:[t.name," ",s?n==="zh"?"★ 已绑定此机房":"★ Bound":""]},t.id)})]})]}),d&&o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:_e,disabled:z.length===0,className:"px-2.5 py-1.5 text-xs font-semibold bg-indigo-50 hover:bg-indigo-100 text-indigo-700 border border-indigo-200 rounded-lg flex items-center gap-1 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",title:n==="zh"?"将未排座学生按学号依次填入空闲机位":"Auto assign unplaced students",children:[e.jsx(Oe,{size:13}),e.jsx("span",{children:n==="zh"?"一键排座":"Auto Fill"})]}),e.jsxs("button",{type:"button",onClick:ze,disabled:g.length===0,className:"px-2.5 py-1.5 text-xs font-semibold bg-gray-100 hover:bg-rose-50 text-gray-600 hover:text-rose-600 border border-gray-200 rounded-lg flex items-center gap-1 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",title:n==="zh"?"清空当前班级排座":"Clear Seating",children:[e.jsx(Fe,{size:13}),e.jsx("span",{children:n==="zh"?"清空":"Clear"})]}),e.jsxs("button",{type:"button",onClick:Ce,disabled:Z||!W&&!o,className:`px-3 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 shadow-xs transition-all cursor-pointer ${W?"bg-emerald-600 hover:bg-emerald-700 text-white animate-pulse":"bg-indigo-600 hover:bg-indigo-700 text-white disabled:opacity-60 disabled:cursor-not-allowed"}`,children:[Z?e.jsx(ye,{size:13,className:"animate-spin"}):e.jsx(Ue,{size:13}),e.jsx("span",{children:Z?n==="zh"?"保存中...":"Saving...":W?n==="zh"?"保存排座 (已修改)":"Save (Modified)":n==="zh"?"已保存":"Saved"})]}),e.jsx(M,{slot:"computer_lab.seating.toolbar",slotProps:{labId:o.id,classId:d,assignedSeats:g,setAssignedSeats:C,lang:n}})]})]}),xe&&e.jsxs("div",{className:"bg-emerald-50 border-b border-emerald-200 text-emerald-800 text-xs px-4 py-2 flex items-center gap-1.5 animate-fadeIn",children:[e.jsx(be,{size:14,className:"text-emerald-600 shrink-0"}),e.jsx("span",{className:"font-medium",children:xe})]}),O&&e.jsxs("div",{className:"bg-red-50 border-b border-red-200 text-red-700 text-xs px-4 py-2 flex items-center gap-1.5",children:[e.jsx(Be,{size:14,className:"text-red-500 shrink-0"}),e.jsx("span",{children:O})]}),o?e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-slate-950 text-white overflow-hidden relative",children:[e.jsx("div",{className:"py-2.5 flex justify-center shrink-0 border-b border-slate-900 bg-slate-950/80 backdrop-blur-xs z-10",children:e.jsx("div",{className:"w-56 bg-slate-900 border border-slate-700 py-1 rounded text-center text-xs font-bold text-slate-300 uppercase tracking-widest select-none shadow-sm flex items-center justify-center gap-1.5",children:e.jsxs("span",{children:["📽️ ",n==="zh"?"讲台 / 教师主荧幕":"Classroom Stage / Screen"]})})}),e.jsx("div",{className:"flex-1 overflow-auto p-4 flex flex-col items-center",children:le?e.jsxs("div",{className:"flex flex-col items-center justify-center h-48 gap-2 text-slate-400",children:[e.jsx(ye,{size:24,className:"animate-spin text-indigo-400"}),e.jsx("span",{className:"text-xs",children:n==="zh"?"正在读取统一机房座位数据...":"Loading lab seating data..."})]}):e.jsx("div",{className:"flex flex-col gap-2.5 py-2 max-w-full",children:Array.from({length:o.rows}).map((t,s)=>e.jsxs("div",{className:"flex gap-2.5 justify-center items-center",children:[e.jsxs("span",{className:"text-xs font-bold font-mono text-slate-500 w-6 text-right select-none pr-0.5",children:["R",s+1]}),Array.from({length:o.cols}).map((r,a)=>{const i=ee.get(`${s}_${a}`),c=!!i,u=f&&(!c||i.student_id!==f.id),D=!!x?.from&&x.from.row===s&&x.from.col===a,U=!!x&&!!I&&I.row===s&&I.col===a&&!D,j=U&&c&&x?.type==="seat"&&i.student_id!==x.studentId,B=U&&(!c||x?.type==="pool");return e.jsx("div",{"data-seat-id":`${s}_${a}`,onClick:()=>Ne(s,a),draggable:!!d&&c,onDragStart:m=>{!d||!i||(T({type:"seat",studentId:i.student_id,from:{row:s,col:a}}),m.dataTransfer.setData("text/plain",JSON.stringify({type:"seat",studentId:i.student_id,from:{row:s,col:a}})),m.dataTransfer.effectAllowed="move")},onDragEnd:()=>{T(null),L(null)},onDragOver:m=>{!x||D||(m.preventDefault(),m.dataTransfer.dropEffect="move",L({row:s,col:a}))},onDragLeave:()=>{L(m=>m&&m.row===s&&m.col===a?null:m)},onDrop:m=>{if(m.preventDefault(),x&&!D){const ge=x.type==="pool"?z.find(P=>P.id===x.studentId)||E.find(P=>P.id===x.studentId):E.find(P=>P.id===x.studentId);ge&&(pe(ge,{row:s,col:a},x.from),v(null),$(null))}T(null),L(null)},className:`group relative rounded-xl flex flex-col items-center justify-center transition-all select-none shadow-sm ${d&&c?"cursor-grab":"cursor-pointer"} ${d?"w-20 h-14":"w-11 h-11"} ${c?"bg-slate-850 border border-indigo-500/70 hover:border-indigo-400 shadow-indigo-950/50":u?"bg-indigo-950/40 border border-dashed border-indigo-400 hover:bg-indigo-900/50 ring-1 ring-indigo-400/50 animate-pulse":"bg-slate-900 border border-slate-800 hover:border-slate-700 hover:bg-slate-850"}${j?" ring-2 ring-amber-400 border-amber-400 bg-amber-950/40":""}${B&&!j?" ring-2 ring-emerald-400 border-emerald-400 bg-emerald-950/40":""}${D?" opacity-40":""}`,children:c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"w-full h-full p-1.5 flex flex-col justify-between items-center text-center",children:[e.jsxs("div",{className:"flex items-center justify-between w-full px-0.5",children:[e.jsxs("span",{className:"text-[10px] font-mono text-indigo-300/80",children:[s+1,"-",a+1]}),d&&e.jsx("button",{type:"button",onClick:m=>Se(m,s,a),className:"opacity-0 group-hover:opacity-100 text-slate-400 hover:text-rose-400 p-0.5 rounded transition-opacity",title:n==="zh"?"移出此座位":"Unseat student",children:e.jsx(te,{size:11})})]}),e.jsx("div",{className:"font-bold text-xs text-white truncate max-w-[70px] leading-tight",children:i.student_name||"Student"}),e.jsx("div",{className:"text-[9px] font-mono text-slate-400 truncate max-w-[70px]",children:i.student_number||`ID:${i.student_id.slice(-4)}`}),e.jsx("div",{className:"w-full min-w-0",onClick:m=>m.stopPropagation(),children:e.jsx(M,{slot:"computer_lab.seat.overlay",slotProps:{labId:o.id,row:s,col:a,seat:i,isOccupied:!0}})})]}),e.jsxs("div",{className:"absolute bottom-16 bg-slate-900 text-white text-xs rounded-lg px-2.5 py-1.5 hidden group-hover:block whitespace-nowrap z-30 font-sans border border-indigo-700 shadow-2xl pointer-events-none",children:[e.jsx("div",{className:"font-bold text-indigo-300",children:i.student_name}),e.jsxs("div",{className:"text-[10px] text-slate-400 font-mono",children:[n==="zh"?"学号:":"No: ",i.student_number||i.student_id]}),e.jsx("div",{className:"text-[10px] text-slate-300 mt-0.5",children:n==="zh"?`第 ${s+1} 排,第 ${a+1} 列`:`Row ${s+1}, Col ${a+1}`})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{size:d?14:15,className:u?"text-indigo-400 animate-bounce":"text-slate-600 opacity-60"}),e.jsxs("span",{className:"text-[10px] font-mono text-slate-500 mt-0.5",children:[s+1,"-",a+1]}),e.jsx("div",{className:"absolute bottom-12 bg-slate-900 text-white text-xs rounded px-2 py-1 hidden group-hover:block whitespace-nowrap z-30 font-sans border border-slate-700 shadow-xl pointer-events-none",children:f?n==="zh"?`点击安排 [${f.name}] 到第 ${s+1} 排第 ${a+1} 列`:`Place [${f.name}] here`:n==="zh"?`第 ${s+1} 排第 ${a+1} 列 (空闲)`:`Row ${s+1} / Column ${a+1} (Empty)`})]})},a)})]},s))})}),d&&o&&!le&&e.jsx("div",{className:"shrink-0 px-4 pb-2",children:e.jsx(M,{slot:"computer_lab.seating.sidebar",slotProps:{labId:o.id,classId:d,assignedSeats:g,unassignedStudents:z}})}),d?e.jsxs("div",{className:"border-t border-slate-900 bg-slate-900/90 p-3 shrink-0 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-bold text-slate-300 flex items-center gap-1.5",children:[e.jsx(je,{size:13,className:"text-indigo-400"}),n==="zh"?"待排座学生池:":"Unassigned Students Pool:"]}),e.jsxs("span",{className:"text-[11px] font-mono text-slate-400",children:[z.length," ",n==="zh"?"人未排":"unplaced"," / ",E.length," ",n==="zh"?"人总计":"total"]}),f&&e.jsxs("span",{className:"bg-indigo-900/80 text-indigo-300 border border-indigo-700 text-[11px] px-2 py-0.5 rounded-full flex items-center gap-1 animate-pulse",children:[e.jsx("span",{children:n==="zh"?`当前选择: ${f.name} (点击上方空位落座)`:`Selected: ${f.name} (click empty seat)`}),e.jsx("button",{type:"button",onClick:()=>{v(null),$(null)},className:"hover:text-white",children:e.jsx(te,{size:10})})]})]}),e.jsxs("div",{className:"text-[11px] font-mono text-slate-400",children:[n==="zh"?"机房已占:":"Occupied: ",e.jsx("span",{className:"text-indigo-400 font-bold",children:g.length})," /"," ",o.rows*o.cols]})]}),z.length===0?e.jsxs("div",{className:"text-xs text-slate-500 py-1 italic flex items-center gap-1",children:[e.jsx(Je,{size:13,className:"text-emerald-400"}),e.jsx("span",{children:n==="zh"?"当前班级全部学生均已成功分配机位!":"All students in this class have been assigned seats!"})]}):e.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto py-1 max-h-16 pr-2",children:z.map(t=>{const s=f?.id===t.id,r=x?.type==="pool"&&x.studentId===t.id;return e.jsxs("div",{className:"shrink-0 flex items-center gap-1","data-unassigned-id":t.id,children:[e.jsxs("button",{type:"button",draggable:!0,onDragStart:a=>{T({type:"pool",studentId:t.id}),a.dataTransfer.setData("text/plain",JSON.stringify({type:"pool",studentId:t.id})),a.dataTransfer.effectAllowed="move"},onDragEnd:()=>{T(null),L(null)},onClick:()=>{v(s?null:t),$(null)},className:`px-2.5 py-1 rounded-lg text-xs font-medium border transition-all cursor-grab active:cursor-grabbing flex items-center gap-1.5 ${s?"bg-indigo-600 text-white border-indigo-400 ring-2 ring-indigo-400/50 shadow-md":"bg-slate-800 text-slate-300 border-slate-700 hover:border-indigo-500 hover:bg-slate-750"}${r?" opacity-40":""}`,children:[e.jsx("span",{children:t.name}),t.student_number&&e.jsx("span",{className:"text-[10px] font-mono text-slate-400",children:t.student_number})]}),e.jsx(M,{slot:"computer_lab.unassigned.item",slotProps:{student:t,classId:d,labId:o?.id}})]},t.id)})})]}):e.jsxs("div",{className:"border-t border-slate-900 bg-slate-900/60 p-3 shrink-0 flex items-center justify-between text-xs text-slate-400 select-none",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3.5 h-3.5 rounded bg-slate-800 border border-slate-700 flex items-center justify-center p-0.5",children:e.jsx(J,{size:10,className:"text-indigo-400 opacity-60"})}),e.jsx("span",{children:n==="zh"?"标准上机终端":"Console Terminals"})]}),ue.length>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-slate-500",children:n==="zh"?"已绑定班级:":"Bound Classes:"}),ue.map(t=>e.jsx("button",{type:"button",onClick:()=>F(t.id),className:"text-indigo-400 hover:text-indigo-300 underline font-semibold text-xs cursor-pointer ml-1",children:t.name},t.id))]})]}),e.jsxs("div",{className:"font-mono text-slate-500",children:[n==="zh"?"总行数:":"Rows: ",e.jsx("span",{className:"text-indigo-400 font-bold",children:o.rows})," |",n==="zh"?" 总列数:":" Columns: ",e.jsx("span",{className:"text-indigo-400 font-bold",children:o.cols})," |",n==="zh"?" 配置席位:":" Total: ",e.jsx("span",{className:"text-white font-bold",children:o.rows*o.cols})]})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8 text-gray-400 h-full",children:[e.jsx(J,{size:48,className:"opacity-20 mb-3"}),e.jsx("p",{className:"text-xs font-medium",children:n==="zh"?"请选择一个机房以预览其座位图":"Please select a lab config to preview details."})]})]})})]})]})}function Qe(h={}){const y=Te(),n=h.computerLabs??y?.computerLabs??[],b=h.onRefresh??y?.fetchLabs??(async()=>{}),q=h.lang??y?.lang??"zh",w=h.classes??y?.classes??[];return e.jsx(qe,{computerLabs:n,onRefresh:b,lang:q,classes:w})}export{Qe as ComputerLabView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as i,j as e}from"./vendor-react-Kv_JATwr.js";import{b as ee,E as y}from"./index-DN3E-Fmw.js";import{B as j,a8 as se,aW as te,ak as _,a$ as D,X as re,Z as ae,U as T,bX as ne,bY as ie,t as oe,u as le,af as de,ac as I,T as ce,c as O}from"./vendor-icons-hc6MjYFv.js";import"./vendor-utils-aM7aYvPP.js";import"./vendor-pdf-By0fofA0.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-SrpBsvM3.js";function xe(s){if(typeof s!="string")return"";let a=s;return a=a.replace(/<(think|thinking|reasoning|analysis)(?:\s+[^>]*)?>[\s\S]*?<\/\1>/gi,""),a=a.replace(/<(think|thinking|reasoning|analysis)(?:\s+[^>]*)?>[\s\S]*$/gi,""),a=a.replace(/```(?:think|thinking|reasoning|analysis)[\s\S]*?```/gi,""),a=a.replace(/^```(?:json|markdown|md)?\s*/i,"").replace(/```\s*$/i,""),a.trim()}function me(s,a=160){if(!s||typeof s!="string")return"";let r=xe(s);return r?(r=r.replace(/```[\s\S]*?```/g," "),r=r.replace(/!\[.*?\]\(.*?\)/g,""),r=r.replace(/\[(.*?)\]\(.*?\)/g,"$1"),r=r.replace(/^#+\s+/gm,""),r=r.replace(/^\s*[-*+]\s+/gm,""),r=r.replace(/^\s*\d+\.\s+/gm,""),r=r.replace(/^\s*>\s+/gm,""),r=r.replace(/\*\*([^*]+)\*\*/g,"$1"),r=r.replace(/\*([^*]+)\*/g,"$1"),r=r.replace(/__([^_]+)__/g,"$1"),r=r.replace(/_([^_]+)_/g,"$1"),r=r.replace(/~~(.*?)~~/g,"$1"),r=r.replace(/`([^`]+)`/g,"$1"),r=r.replace(/\s+/g," ").trim(),r.length<=a?r:r.slice(0,a).trimEnd()+"..."):""}function ve(){const{lang:s,session:a,lessons:r,lessonsSearchQuery:g,setLessonsSearchQuery:h,lessonsSortOrder:E,setLessonsSortOrder:A,filteredAndSortedLessons:u,isImportLessonsOpen:ge,setIsImportLessonsOpen:P,isCourseWizardOpen:he,setIsCourseWizardOpen:F,onViewCourse:N,onDeleteCourse:M,onCopyCourse:R,filterEnrollment:v,setFilterEnrollment:W,filterHasContent:C,setFilterHasContent:U,filterThisMonth:w,setFilterThisMonth:X,copyingLessonId:B,fetchLessons:H,downloadCourseTemplate:Q}=ee(),V=()=>P(!0),z=()=>F(!0),n=a,Z=n?.username==="admin"||n?.userId==="usr_admin"||n?.role==="administrator"||n?.subRole==="administrator",[p,J]=i.useState(!1),[o,b]=i.useState(null),[l,d]=i.useState(null),[k,S]=i.useState(!1),[Y,L]=i.useState(!1),[x,$]=i.useState(null),q=t=>{navigator.clipboard.writeText(t).then(()=>{$(t),setTimeout(()=>$(null),1500)})},G=async t=>{b(t),d(null),L(!0);try{const m=await fetch(`/api/lessons/${t.id}/stats`);if(m.ok){const c=await m.json();d(c)}}catch{d({whiteboardCount:0,scheduleCount:0,enrollmentCount:0,assignmentCount:0})}finally{L(!1)}},K=async()=>{if(o){S(!0);try{await M(o.id),b(null),d(null)}finally{S(!1)}}};return e.jsxs("div",{className:"flex-1 flex flex-col gap-6 h-full overflow-y-auto",children:[e.jsxs("div",{className:"flex-1 bg-white border border-gray-200 rounded-xl shadow-sm flex flex-col min-h-0",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between shrink-0",children:[e.jsxs("h3",{className:"font-medium text-gray-700 flex items-center gap-2",children:[e.jsx(j,{size:16,className:"text-gray-400"}),s==="zh"?"课程与教学环节管理 (SQLite)":"Courses & Lessons Management"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{id:"import-lessons-csv-btn",onClick:V,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs bg-indigo-50 hover:bg-indigo-100 text-indigo-700 border border-indigo-200 font-semibold rounded-lg shadow-3xs transition-all hover:shadow-xs hover:-translate-y-0.5 cursor-pointer",children:[e.jsx(se,{size:14}),s==="zh"?"批量导入课程":"Import Lessons"]}),e.jsxs("button",{id:"download-course-template-btn",onClick:()=>void Q(),title:s==="zh"?"下载自包含的课程模板(教学环节 + 全部预设组件 + PDF/PPTX 课件附件)":"Download a self-contained course template (segments + every preset component + PDF/PPTX assets)",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs bg-emerald-50 hover:bg-emerald-100 text-emerald-700 border border-emerald-200 font-semibold rounded-lg shadow-3xs transition-all hover:shadow-xs hover:-translate-y-0.5 cursor-pointer",children:[e.jsx(te,{size:14}),s==="zh"?"下载课程模板":"Course Template"]}),e.jsxs("button",{id:"add-course-wizard-btn",onClick:z,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs bg-indigo-600 hover:bg-indigo-700 text-white font-semibold rounded-lg shadow-sm transition-all hover:shadow-md hover:-translate-y-0.5 cursor-pointer",children:[e.jsx(_,{size:14}),s==="zh"?"手动添加课程 (向导)":"Add Course Wizard"]}),e.jsx(y,{slot:"course.list.toolbar.action",slotProps:{lang:s,onRefresh:H}})]})]}),r.length>0&&e.jsxs("div",{className:"px-5 py-3.5 border-b border-gray-100 bg-gray-50/50 flex flex-col sm:flex-row items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 w-full sm:w-auto",children:[e.jsxs("div",{className:"relative w-full sm:w-64",children:[e.jsx("span",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-gray-400",children:e.jsx(D,{size:14})}),e.jsx("input",{type:"text",placeholder:"Search courses by title...",value:g,onChange:t=>h(t.target.value),className:"w-full pl-9 pr-8 py-1.5 text-xs bg-white border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 text-gray-800 shadow-sm"}),g&&e.jsx("button",{onClick:()=>h(""),className:"absolute inset-y-0 right-0 flex items-center pr-2.5 text-gray-400 hover:text-gray-600",children:e.jsx(re,{size:12,className:"bg-gray-100 hover:bg-gray-200 rounded-full p-0.5"})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-bold text-subtle uppercase tracking-wider",children:s==="zh"?"排序方式:":"Sort by:"}),e.jsxs("select",{"aria-label":s==="zh"?"课程排序方式":"Course sort order",value:E,onChange:t=>A(t.target.value),className:"bg-white border border-gray-200 text-xs text-gray-755 font-bold px-2.5 py-1.5 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 shadow-sm",id:"courses-sort-select",children:[e.jsx("option",{value:"recent",children:s==="zh"?"最新创建":"Most Recent"}),e.jsx("option",{value:"alphabetical",children:s==="zh"?"按名称 (A-Z)":"Alphabetical (A-Z)"}),e.jsx("option",{value:"enrollment",children:s==="zh"?"学生选课人次":"Student Enrollment Count"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>J(!p),className:`px-2 py-1 text-xs font-bold rounded-md border transition-all cursor-pointer ${p?"bg-indigo-600 text-white border-indigo-600 shadow-2xs":"bg-white text-gray-600 border-gray-200 hover:border-gray-300"}`,title:s==="zh"?"只看我创建的课程":"Only show courses created by me",children:[e.jsx(ae,{size:11,className:"inline mr-0.5 -mt-0.5"}),s==="zh"?"我的备课":"My Courses"]}),e.jsxs("button",{onClick:()=>W(!v),className:`px-2 py-1 text-xs font-bold rounded-md border transition-all cursor-pointer ${v?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-white text-gray-500 border-gray-200 hover:border-gray-300"}`,children:[e.jsx(T,{size:11,className:"inline mr-0.5 -mt-0.5"}),s==="zh"?"有人选":"Enrolled"]}),e.jsxs("button",{onClick:()=>U(!C),className:`px-2 py-1 text-xs font-bold rounded-md border transition-all cursor-pointer ${C?"bg-indigo-50 text-indigo-700 border-indigo-200":"bg-white text-gray-500 border-gray-200 hover:border-gray-300"}`,children:[e.jsx(j,{size:11,className:"inline mr-0.5 -mt-0.5"}),s==="zh"?"有内容":"Has Content"]}),e.jsx("button",{onClick:()=>X(!w),className:`px-2 py-1 text-xs font-bold rounded-md border transition-all cursor-pointer ${w?"bg-amber-50 text-amber-700 border-amber-200":"bg-white text-gray-500 border-gray-200 hover:border-gray-300"}`,children:s==="zh"?"本月":"This Month"})]}),e.jsxs("div",{className:"text-xs font-semibold text-gray-500",children:["Found ",e.jsx("span",{className:"text-indigo-650 font-bold",children:u.length})," of"," ",e.jsx("span",{className:"text-gray-700 font-bold",children:r.length})," course",r.length===1?"":"s"]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-400 min-h-[300px]",children:[e.jsx(j,{size:48,className:"mb-4 opacity-30 text-indigo-500"}),e.jsx("h3",{className:"text-lg font-bold text-gray-800",children:s==="zh"?"暂无可用课程":"No Courses Available"}),e.jsx("p",{className:"mt-2 text-sm text-gray-500 text-center max-w-xs",children:s==="zh"?"系统中暂未部署任何课程。请通过下方按钮启动添加向导指南。":"There are no courses active in the system yet. Build your first curriculum!"}),e.jsxs("button",{id:"empty-add-course-btn",onClick:z,className:"mt-5 flex items-center gap-2 px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white font-bold rounded-xl shadow-md transition-all cursor-pointer",children:[e.jsx(_,{size:16}),s==="zh"?"使用向导指南来创建新课程":"Create Course via Wizard"]})]}):u.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-12 text-gray-450 text-center",children:[e.jsx(D,{size:44,className:"mb-3 opacity-30 text-gray-450"}),e.jsxs("h4",{className:"font-semibold text-gray-700 text-sm",children:['No Courses Match "',g,'"']}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 max-w-xs",children:"Double-check the spelling or try searching for another curriculum keyword."}),e.jsx("button",{onClick:()=>h(""),className:"mt-3 text-xs bg-indigo-50 hover:bg-indigo-100 text-indigo-700 border border-indigo-200 font-semibold px-3 py-1.5 rounded-lg transition-colors",children:"Clear Search Filter"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:u.filter(t=>p?!t.creator_id||t.creator_id===n?.userId||t.creator_id===n?.username:!0).map(t=>{const m=B===t.id,c=!t.creator_id||t.creator_id===n?.userId||t.creator_id===n?.username,f=Z||c;return e.jsxs("div",{className:`border border-gray-200 hover:border-indigo-300 rounded-xl p-4 flex flex-col bg-gray-50/50 hover:shadow-md transition-all ${m?"opacity-60 pointer-events-none":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2",children:[e.jsx("div",{className:"font-semibold text-gray-800 text-lg truncate cursor-pointer hover:text-indigo-600 transition-colors",title:t.title,onClick:()=>N(t.id),children:t.title}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(y,{slot:"course.card.badge",slotProps:{course:t}}),t.creator_name?e.jsxs("span",{className:`text-xs font-medium px-1.5 py-0.5 rounded border flex items-center gap-0.5 ${c?"bg-indigo-50 text-indigo-700 border-indigo-200 font-semibold":"bg-slate-100 text-slate-600 border-slate-200"}`,title:s==="zh"?`创建教师: ${t.creator_name}`:`Created by: ${t.creator_name}`,children:[c?"👑 ":"👤 ",t.creator_name]}):null,e.jsxs("span",{className:"inline-flex items-center gap-1 bg-indigo-50 text-indigo-700 px-1.5 py-0.5 border border-indigo-100 rounded text-xs font-bold",children:[e.jsx(T,{size:10,className:"text-indigo-500"}),t.enrollment_count||0]})]})]}),e.jsx("div",{className:"text-sm text-gray-500 line-clamp-3 mb-4 flex-1 leading-relaxed",children:me(t.content)||e.jsx("span",{className:"italic text-gray-400",children:s==="zh"?"暂无课程大纲与简介":"No outline or summary available."})}),e.jsxs("div",{className:"flex justify-between items-center mt-auto",children:[e.jsxs("button",{onClick:()=>q(t.id),className:`flex items-center gap-1 text-xs rounded px-1.5 py-0.5 transition-all cursor-pointer ${x===t.id?"text-emerald-700 bg-emerald-50 border border-emerald-200":"text-subtle hover:text-indigo-600 hover:bg-indigo-50 border border-transparent"}`,title:x===t.id?s==="zh"?"已复制!":"Copied!":s==="zh"?"复制课程 ID":"Copy Course ID",children:[x===t.id?e.jsx(ne,{size:12}):e.jsx(ie,{size:12}),e.jsx("span",{className:"font-mono",children:x===t.id?s==="zh"?"已复制!":"Copied!":`${t.id.substring(0,8)}…`})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:()=>N(t.id),className:"p-1.5 text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 rounded transition-colors cursor-pointer",title:f?s==="zh"?"查看与编辑":"View & Edit":s==="zh"?"查看只读 (他人课程)":"View Read-Only",children:f?e.jsx(oe,{size:15}):e.jsx(le,{size:15})}),e.jsx("button",{onClick:()=>R(t.id),className:"p-1.5 text-gray-400 hover:text-emerald-600 hover:bg-emerald-50 rounded transition-colors cursor-pointer",title:s==="zh"?"克隆为我的备课":"Clone Course",children:e.jsx(de,{size:14})}),f?e.jsx("button",{onClick:()=>G(t),className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded transition-colors cursor-pointer",title:s==="zh"?"删除课程":"Delete Course",children:e.jsx(I,{size:14})}):e.jsx("span",{className:"p-1.5 text-gray-300 cursor-not-allowed",title:s==="zh"?"仅创建教师或管理员可删除":"Only creator or admin can delete",children:e.jsx(I,{size:14})}),e.jsx(y,{slot:"course.card.action",slotProps:{course:t,lang:s}})]})]})]},t.id)})})})]}),o&&e.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-[2px] flex items-center justify-center z-[9999] p-4",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-2xl max-w-md w-full border border-gray-100 overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-100 bg-red-50 flex items-center gap-2",children:[e.jsx(ce,{size:18,className:"text-red-600"}),e.jsx("h3",{className:"font-bold text-red-800 text-sm",children:s==="zh"?"确认删除课程":"Confirm Course Deletion"})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("p",{className:"text-sm text-gray-700",children:s==="zh"?e.jsxs(e.Fragment,{children:["确定要删除课程 ",e.jsx("span",{className:"font-bold text-red-600",children:o.title})," 吗?"]}):e.jsxs(e.Fragment,{children:["Are you sure you want to delete ",e.jsx("span",{className:"font-bold text-red-600",children:o.title}),"?"]})}),e.jsx("p",{className:"text-xs text-red-600 font-medium",children:s==="zh"?"此操作不可撤销,将删除课程的所有关联数据。":"This action is irreversible and will delete all associated data."}),Y?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 py-2",children:[e.jsx(O,{size:14,className:"animate-spin"}),s==="zh"?"正在统计关联数据...":"Counting related data..."]}):l?e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 space-y-1.5 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600",children:s==="zh"?"白板元素":"Whiteboard Elements"}),e.jsx("span",{className:"font-bold text-gray-800",children:l.whiteboardCount})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600",children:s==="zh"?"排课记录":"Schedules"}),e.jsx("span",{className:"font-bold text-gray-800",children:l.scheduleCount})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600",children:s==="zh"?"选课学生":"Enrollments"}),e.jsx("span",{className:"font-bold text-gray-800",children:l.enrollmentCount})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600",children:s==="zh"?"作业任务":"Assignments"}),e.jsx("span",{className:"font-bold text-gray-800",children:l.assignmentCount})]})]}):null]}),e.jsxs("div",{className:"px-5 py-3 border-t border-gray-100 bg-gray-50 flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>{b(null),d(null)},className:"px-4 py-2 text-xs font-medium text-gray-600 hover:bg-gray-100 border border-gray-200 rounded-lg transition-colors cursor-pointer",children:s==="zh"?"取消":"Cancel"}),e.jsxs("button",{onClick:K,disabled:k,className:"px-4 py-2 text-xs font-bold text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:[k&&e.jsx(O,{size:12,className:"animate-spin"}),s==="zh"?"确认删除":"Confirm Delete"]})]})]})})]})}export{ve as CourseManagement};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./vendor-react-Kv_JATwr.js";import{m as $,C as P}from"./index-DN3E-Fmw.js";import{a8 as b,D,aW as T,aX as O,c as u,o as V,a9 as f}from"./vendor-icons-hc6MjYFv.js";import"./vendor-utils-aM7aYvPP.js";import"./vendor-pdf-By0fofA0.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-SrpBsvM3.js";const j=Math.round(P/(1024*1024));function _(y){const{isImportLessonsOpen:N,setIsImportLessonsOpen:o,lang:s,importStatus:a,setIsDraggingImport:m,handleCSVFileChange:F,handleImportFileChange:h,downloadCsvTemplate:v,downloadCourseTemplate:w,packagePreview:t,handlePackageImportSubmit:p,packageDuplicate:n=null,handlePackageDuplicateDismiss:k=()=>{},isDraggingImport:C,previewImportData:l,setPreviewImportData:g,setImportStatus:d,importProgress:i,importProgressTotal:c,importErrorMsg:z,setImportErrorMsg:S,handleCSVImportSubmit:I}=y;return e.jsx(e.Fragment,{children:N&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/50 backdrop-blur-sm flex items-center justify-center p-4 md:p-6 z-50 overflow-y-auto text-gray-850",children:e.jsxs($.div,{initial:{opacity:0,y:15,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.98},className:"bg-white border text-gray-900 border-gray-250 rounded-2xl shadow-2xl w-full max-w-2xl flex flex-col overflow-hidden max-h-[90vh] font-sans text-left",children:[e.jsxs("div",{className:"p-4 md:p-5 border-b border-gray-100 flex items-center justify-between bg-slate-50 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-indigo-50 border border-indigo-100 rounded-lg text-indigo-650",children:e.jsx(b,{size:20,className:"animate-pulse"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-bold text-gray-850 text-base md:text-lg",children:s==="zh"?"批量导入课程":"Bulk-Import Courses"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:s==="zh"?"CSV 为「简易导入」(仅标题与正文);需要教学环节 + 白板组件 + 课件附件的完整课程请用课程包 JSON。":'CSV is a "quick import" (title and body only). For a complete lesson — segments, whiteboard components and assets — use a course package JSON.'})]})]}),e.jsx("button",{onClick:()=>{a!=="importing"&&o(!1)},disabled:a==="importing",className:"text-gray-400 hover:text-gray-650 font-bold p-1 rounded-lg hover:bg-gray-150 transition-all text-xl leading-none disabled:opacity-40",children:"×"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[a==="idle"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-indigo-50/50 border border-indigo-100 rounded-xl",children:[e.jsxs("h4",{className:"text-xs font-bold text-indigo-850 uppercase tracking-wide flex items-center gap-2",children:[e.jsx("span",{children:"📌"}),s==="zh"?"简易导入(CSV)":"Quick import (CSV)",e.jsx("span",{className:"text-[10px] font-mono font-normal normal-case tracking-normal text-indigo-700 bg-indigo-100 border border-indigo-200 rounded px-1.5 py-0.5","data-testid":"csv-simple-import-badge",children:s==="zh"?"仅标题 + 正文":"title + body only"})]}),e.jsx("p",{className:"text-xs text-indigo-900 mt-1 leading-relaxed",children:s==="zh"?"CSV 文件的首行必须定义列标题(不区分大小写、无多余空格),包含以下两项必需内容:":"Your CSV file must include exactly these header columns on the first row (case-insensitive):"}),e.jsxs("ul",{className:"list-disc pl-5 mt-2 text-xs text-indigo-950 space-y-1",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"title"}),":"," ",s==="zh"?'课程名 (非空,例如 "代数几何")':'Course title (Required, e.g. "Linear Algebra")']}),e.jsxs("li",{children:[e.jsx("strong",{children:"content"}),":"," ",s==="zh"?"教学大纲 / Markdown 格式的课堂细目":"Syllabus content supporting rich markdown."]})]}),e.jsxs("div",{className:"mt-3.5 flex flex-wrap gap-2 justify-start",children:[e.jsxs("button",{onClick:v,className:"flex items-center gap-1 p-2 text-xs font-bold text-indigo-700 bg-white border border-indigo-200 rounded-lg shadow-3xs hover:bg-indigo-50 hover:-translate-y-0.5 hover:shadow-xs transition-all cursor-pointer",children:[e.jsx(D,{size:12}),s==="zh"?"获取标准 CSV 模板":"Download Template CSV"]}),e.jsxs("button",{onClick:w,"data-testid":"download-course-package-template-btn",className:"flex items-center gap-1 p-2 text-xs font-bold text-emerald-700 bg-white border border-emerald-200 rounded-lg shadow-3xs hover:bg-emerald-50 hover:-translate-y-0.5 hover:shadow-xs transition-all cursor-pointer",children:[e.jsx(T,{size:12}),s==="zh"?"下载课程模板(JSON)":"Download Course Template (JSON)"]})]}),e.jsx("p",{className:"text-[11px] text-indigo-800/80 mt-2.5 leading-relaxed",children:s==="zh"?"课程模板是一个自包含的 JSON 文件:包含教学环节、全部预设组件的白板元素,以及内嵌的 PDF / PPTX 课件附件 —— 拖回本对话框即可导入成一节完整的课。完整课程统一走这条通道,CSV 只做批量建空壳。":"The course template is a self-contained JSON file: teaching segments, whiteboard elements for every preset component, and embedded PDF/PPTX assets — drop it back here to import a complete lesson. Complete lessons go through this path; CSV only creates shells in bulk."})]}),e.jsxs("div",{onDragOver:r=>{r.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:r=>{r.preventDefault(),m(!1),r.dataTransfer.files&&r.dataTransfer.files[0]&&h(r.dataTransfer.files[0])},onClick:()=>{document.getElementById("import-csv-file-picker")?.click()},className:`border-2 border-dashed rounded-2xl p-8 text-center cursor-pointer transition-all flex flex-col items-center justify-center min-h-[180px] ${C?"border-indigo-500 bg-indigo-50/70 scale-[1.01]":"border-gray-250 bg-gray-50/50 hover:bg-gray-50 hover:border-indigo-400"}`,children:[e.jsx("input",{id:"import-csv-file-picker",type:"file",accept:".csv,.json",className:"hidden",onChange:r=>{r.target.files&&r.target.files[0]&&h(r.target.files[0])}}),e.jsx("div",{className:"p-3 bg-gray-100 border border-gray-200 rounded-full text-indigo-600 mb-3 group-hover:scale-105 transition-all",children:e.jsx(b,{size:24})}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:s==="zh"?"选择 CSV / 课程包 JSON 文件,或拖放至此处":"Click to select or drag and drop a CSV / course-package JSON file here"}),e.jsx("span",{className:"text-xs text-gray-400 mt-1",children:s==="zh"?`CSV(简易导入)或课程包 JSON(完整课程),单文件最大 ${j}MB`:`CSV (quick import) or course-package JSON (full lesson), up to ${j}MB`})]})]}),a==="parsing"&&t&&e.jsxs("div",{className:"space-y-4","data-testid":"course-package-preview",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-bold text-emerald-600 bg-emerald-50 border border-emerald-200 px-2.5 py-1 rounded-full",children:["✓"," ",s==="zh"?`课程包解析成功:${t.segments} 个教学环节 · ${t.elements} 个白板元素`:`Course package parsed: ${t.segments} segments · ${t.elements} elements`]}),e.jsx("button",{onClick:()=>{g([]),d("idle")},className:"text-xs text-indigo-600 hover:text-indigo-800 font-semibold",children:s==="zh"?"重新上传":"Upload Different File"})]}),e.jsxs("div",{className:"p-4 bg-white border border-gray-200 rounded-xl shadow-3xs",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-50 border border-emerald-100 rounded-lg text-emerald-600",children:e.jsx(O,{size:18})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"text-sm font-bold text-gray-800 truncate",title:t.title,children:t.title}),t.metaName&&e.jsx("p",{className:"text-[11px] text-gray-500 mt-0.5 truncate",children:t.metaName}),e.jsx("p",{className:"text-[11px] text-gray-400 mt-0.5 font-mono truncate",children:t.fileName})]})]}),e.jsxs("dl",{className:"grid grid-cols-3 gap-2 mt-3",children:[e.jsxs("div",{className:"p-2 bg-gray-50 border border-gray-150 rounded-lg",children:[e.jsx("dt",{className:"text-[10px] text-gray-500 font-semibold",children:s==="zh"?"教学环节":"Segments"}),e.jsx("dd",{className:"text-base font-bold text-gray-800",children:t.segments})]}),e.jsxs("div",{className:"p-2 bg-gray-50 border border-gray-150 rounded-lg",children:[e.jsx("dt",{className:"text-[10px] text-gray-500 font-semibold",children:s==="zh"?"白板元素":"Elements"}),e.jsx("dd",{className:"text-base font-bold text-gray-800",children:t.elements})]}),e.jsxs("div",{className:"p-2 bg-gray-50 border border-gray-150 rounded-lg",children:[e.jsx("dt",{className:"text-[10px] text-gray-500 font-semibold",children:s==="zh"?"课件附件":"Assets"}),e.jsx("dd",{className:"text-base font-bold text-gray-800",children:t.assets})]})]}),t.componentTypes.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-[10px] text-gray-500 font-semibold mb-1.5",children:s==="zh"?"覆盖的预设组件":"Covered components"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:t.componentTypes.map(r=>e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-indigo-50 border border-indigo-100 text-[10px] font-mono text-indigo-700",children:r},r))})]})]}),e.jsxs("div",{className:"bg-amber-50 border border-amber-100 text-amber-900 text-xs rounded-xl p-3 flex gap-2.5 items-start",children:[e.jsx("span",{className:"text-base leading-none",children:"⚠️"}),e.jsx("p",{className:"leading-relaxed",children:s==="zh"?"导入将以单个事务写入:教学环节、白板元素与课件附件要么全部成功,要么全部回滚,不会留下半截课程。":"The import runs as a single transaction: segments, whiteboard elements and assets are either all written or all rolled back."})]})]}),a==="parsing"&&!t&&l.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-bold text-emerald-600 bg-emerald-50 border border-emerald-200 px-2.5 py-1 rounded-full",children:["✓"," ",s==="zh"?`解析成功:查找到 ${l.length} 门课程`:`Parsed Successfully: Found ${l.length} records`]}),e.jsx("button",{onClick:()=>{g([]),d("idle")},className:"text-xs text-indigo-600 hover:text-indigo-800 font-semibold",children:s==="zh"?"重新上传":"Upload Different File"})]}),e.jsx("div",{className:"border border-gray-200 rounded-xl overflow-hidden shadow-3xs max-h-[300px] overflow-y-auto",children:e.jsxs("table",{className:"w-full text-left text-xs border-collapse",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-600 border-b border-gray-200 font-bold",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-3 w-1/4",children:s==="zh"?"课程名称":"Course Title"}),e.jsx("th",{className:"p-3 w-3/4",children:s==="zh"?"大纲简介片段":"Syllabus Preview"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 bg-white",children:l.map((r,x)=>e.jsxs("tr",{className:"hover:bg-slate-50/50",children:[e.jsx("td",{className:"p-3 font-semibold text-gray-800 align-top truncate max-w-[150px]",title:r.title,children:r.title}),e.jsx("td",{className:"p-3 text-gray-500 font-mono text-xs leading-relaxed break-words col-span-2",children:r.content.length>150?r.content.substring(0,150)+"...":r.content||e.jsx("em",{className:"text-gray-300 italic",children:"None"})})]},x))})]})}),e.jsxs("div",{className:"bg-amber-50 border border-amber-100 text-amber-900 text-xs rounded-xl p-3 flex gap-2.5 items-start",children:[e.jsx("span",{className:"text-base leading-none",children:"⚠️"}),e.jsx("p",{className:"leading-relaxed",children:s==="zh"?'请确认课程名称没有与系统已有的课程同名。确认无误后点击下方"开始导入"写入 SQLite。':"Please ensure column details are accurate. Clicking Import will instantly commit all parsed courses into the server SQLite backend."})]})]}),a==="importing"&&t&&e.jsxs("div",{className:"py-8 flex flex-col items-center justify-center space-y-4",children:[e.jsx("div",{className:"relative w-20 h-20 flex items-center justify-center",children:e.jsx(u,{size:36,className:"text-indigo-600 animate-spin"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"font-bold text-gray-800 text-sm",children:s==="zh"?"正在导入课程包":"Importing course package"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s==="zh"?`正在写入 ${t.segments} 个教学环节、${t.elements} 个白板元素与 ${t.assets} 份课件附件...`:`Writing ${t.segments} segments, ${t.elements} elements and ${t.assets} assets...`})]}),e.jsx("div",{className:"w-full max-w-md bg-gray-50 rounded-xl p-3 border border-gray-150 font-mono text-xs text-gray-400",children:e.jsx("div",{children:"[API] POST /api/course-packages/import -> single transaction..."})})]}),a==="importing"&&!t&&e.jsxs("div",{className:"py-8 flex flex-col items-center justify-center space-y-4",children:[e.jsxs("div",{className:"relative w-20 h-20 flex items-center justify-center",children:[e.jsx(u,{size:36,className:"text-indigo-600 animate-spin"}),e.jsxs("span",{className:"absolute text-xs font-extrabold text-indigo-700",children:[Math.round(i/c*100),"%"]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"font-bold text-gray-800 text-sm",children:s==="zh"?"正在写入数据库":"Populating Database Records"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s==="zh"?`正在导入第 ${i} / ${c} 项...`:`Importing item ${i} of ${c}...`})]}),e.jsx("div",{className:"w-full max-w-sm bg-gray-100 h-2 rounded-full overflow-hidden border border-gray-200",children:e.jsx("div",{className:"bg-indigo-600 h-full transition-all duration-300 rounded-full",style:{width:`${i/c*100}%`}})}),e.jsxs("div",{className:"w-full max-w-md bg-gray-50 rounded-xl p-3 border border-gray-150 font-mono text-xs text-gray-400 max-h-[140px] overflow-y-auto",children:[e.jsx("div",{children:"[API] POST /api/lessons -> one request per course (no cross-course transaction)"}),l.slice(0,i).map((r,x)=>e.jsx("div",{className:"text-indigo-600 font-bold mt-1",children:`✓ [${x+1}] "${r.title}" -> status 200 (Success)`},x))]})]}),a==="success"&&e.jsxs("div",{className:"py-8 text-center flex flex-col items-center justify-center space-y-4",children:[e.jsx("div",{className:"w-16 h-16 bg-emerald-50 rounded-full flex items-center justify-center border border-emerald-200 text-emerald-600 animate-bounce",children:e.jsx(V,{size:32})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-gray-800 text-base",children:s==="zh"?"🎉 批量导入大功告成":"🎉 Bulk-Import Complete"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 max-w-md mx-auto",children:t?s==="zh"?`课程包已导入:${t.segments} 个教学环节、${t.elements} 个白板元素、${t.assets} 份课件附件均已写入。`:`Course package imported: ${t.segments} segments, ${t.elements} elements and ${t.assets} assets written.`:s==="zh"?`所有 ${l.length} 门学科教案数据已顺畅写入系统底层 SQLite 数据仓库,现在已可以用于备课。`:`All ${l.length} curriculum lessons records have been successfully saved into security logs and SQLite storage.`})]})]}),a==="error"&&e.jsxs("div",{className:"space-y-4",children:[n?e.jsxs("div",{className:"p-4 bg-amber-50 border border-amber-100 rounded-xl flex gap-3 items-start","data-testid":"course-package-duplicate-notice",children:[e.jsx("span",{className:"text-amber-600 font-bold text-lg leading-none",children:"⧉"}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-amber-850",children:s==="zh"?"该课程包已经导入过了":"This course package was already imported"}),e.jsx("p",{className:"text-xs text-amber-900 mt-1 leading-relaxed",children:s==="zh"?e.jsxs(e.Fragment,{children:["已存在课程「",n.lessonTitle,"」",n.hasDeclaredId?"(同一个课程包 id)":"(内容完全相同)",", 再次导入会得到两节内容相同的课程。"]}):e.jsxs(e.Fragment,{children:['A lesson named "',n.lessonTitle,'" already exists',n.hasDeclaredId?" (same course-package id)":" (identical content)",". Importing again would create two lessons with the same content."]})})]})]}):e.jsxs("div",{className:"p-4 bg-rose-50 border border-rose-100 rounded-xl flex gap-3 items-start",children:[e.jsx("span",{className:"text-rose-600 font-bold text-lg leading-none",children:"⚠️"}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-rose-850",children:s==="zh"?"数据导入或解析中断":"Import or Parsing Error"}),e.jsx("p",{className:"text-xs text-rose-900 mt-1 leading-relaxed",children:z||(s==="zh"?"未知异常或文件破损。":"An unknown exception or corrupted CSV formatting occurred.")})]})]}),e.jsx("div",{className:"flex gap-3 justify-end",children:n?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:k,"data-testid":"course-package-duplicate-cancel",className:"px-4 py-2 text-xs font-bold text-gray-700 bg-white border border-gray-250 cursor-pointer hover:bg-gray-50 rounded-lg transition-all",children:s==="zh"?"取消":"Cancel"}),e.jsx("button",{onClick:()=>p(!0),"data-testid":"course-package-duplicate-force",className:"px-4 py-2 text-xs font-bold text-white bg-amber-600 cursor-pointer hover:bg-amber-700 rounded-lg transition-all",children:s==="zh"?"仍然导入副本":"Import as a Copy Anyway"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{d("idle"),S("")},className:"px-4 py-2 text-xs font-bold text-gray-700 bg-white border border-gray-250 cursor-pointer hover:bg-gray-50 rounded-lg transition-all",children:s==="zh"?"返回重试":"Go Back & Retry"}),e.jsx("button",{onClick:()=>o(!1),className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 cursor-pointer hover:bg-indigo-700 rounded-lg transition-all",children:s==="zh"?"关闭窗口":"Close"})]})})]})]}),a!=="idle"&&a!=="error"&&e.jsxs("div",{className:"p-4 md:p-5 border-t border-gray-100 flex items-center justify-between bg-slate-50 shrink-0",children:[e.jsx("button",{onClick:()=>{g([]),d("idle")},disabled:a==="importing",className:"px-4 py-2 text-xs font-bold text-gray-650 bg-white border border-gray-200 hover:bg-gray-100 rounded-lg transition-all disabled:opacity-40 cursor-pointer",children:s==="zh"?"重置重选":"Reset & Clear"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(!1),disabled:a==="importing",className:"px-4 py-2 text-xs font-bold text-gray-600 hover:text-gray-800 transition-all disabled:opacity-40 cursor-pointer",children:s==="zh"?"取消":"Cancel"}),a==="parsing"&&t&&e.jsxs("button",{onClick:()=>p(!1),"data-testid":"import-course-package-btn",className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 rounded-lg shadow-sm transition-all flex items-center gap-1 cursor-pointer",children:[e.jsx(f,{size:12}),s==="zh"?"导入课程包":"Import Course Package"]}),a==="parsing"&&!t&&e.jsxs("button",{onClick:I,className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 rounded-lg shadow-sm transition-all flex items-center gap-1 cursor-pointer",children:[e.jsx(f,{size:12}),s==="zh"?`开始导入 (${l.length} 类)`:`Proceed and Import (${l.length})`]}),a==="success"&&e.jsx("button",{onClick:()=>o(!1),className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 rounded-lg shadow-sm transition-all cursor-pointer",children:s==="zh"?"完成":"Done"})]})]})]})})})}export{_ as ImportLessonsModal};
|