openlearn-next 0.7.10 → 0.7.12

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.
Files changed (54) hide show
  1. package/README.md +9 -2
  2. package/dist/assets/{ActivityWorkspaceWidget-BU88GGUG.js → ActivityWorkspaceWidget-TtBuNORs.js} +1 -1
  3. package/dist/assets/AdminDirectoryView-D03WOMc-.js +5 -0
  4. package/dist/assets/{AssessmentCenter-BoSWbJMt.js → AssessmentCenter-MUvoJySb.js} +1 -1
  5. package/dist/assets/{AssignmentFilePreview-D_POvLmv.js → AssignmentFilePreview-dVhnTYmq.js} +1 -1
  6. package/dist/assets/{BatchPickerModal-DiHd_6Tg.js → BatchPickerModal-QALdhrX6.js} +1 -1
  7. package/dist/assets/{ClassesView-CWKqzWH0.js → ClassesView-CKwlRz-A.js} +5 -5
  8. package/dist/assets/{ClassroomCountdownWidget-B5-KUVU8.js → ClassroomCountdownWidget-DyWyForY.js} +1 -1
  9. package/dist/assets/{CloudDriveModal-CjcvdDiw.js → CloudDriveModal-C8UAn3MO.js} +1 -1
  10. package/dist/assets/{ComputerLabView-CNTcmWAh.js → ComputerLabView-E5b3XTkk.js} +1 -1
  11. package/dist/assets/{CourseManagement-ha_iSnLU.js → CourseManagement-3jSlq7lV.js} +1 -1
  12. package/dist/assets/{CourseWizardModal-oVT9mYSG.js → CourseWizardModal-BAkW5VJX.js} +1 -1
  13. package/dist/assets/{CoursewareHubPanel-BuKp0mmW.js → CoursewareHubPanel-BkjcusjZ.js} +1 -1
  14. package/dist/assets/{Dashboard-Vb9coh9_.js → Dashboard-Ha2fZAqD.js} +2 -2
  15. package/dist/assets/{ExportWeightModal-BEesz6rd.js → ExportWeightModal-D2Y13384.js} +1 -1
  16. package/dist/assets/{HelpTour-D3QcGDUz.js → HelpTour-DBq2otcV.js} +1 -1
  17. package/dist/assets/{HelpView--Um9DFYx.js → HelpView-BVLRnMxl.js} +4 -4
  18. package/dist/assets/{ImportLessonsModal-DXGopj4j.js → ImportLessonsModal-CQlq4b81.js} +1 -1
  19. package/dist/assets/ImportModal-Ct0I5cAL.js +3 -0
  20. package/dist/assets/{InteractiveCoursewareViewer-DzgF9_LU.js → InteractiveCoursewareViewer-DGKh1gO8.js} +1 -1
  21. package/dist/assets/InteractiveWhiteboard-BbZlYpRu.js +65 -0
  22. package/dist/assets/{LazyCourseware-6yb_QiYS.js → LazyCourseware-zONqinCM.js} +2 -2
  23. package/dist/assets/{LazyWhiteboard-CsF9GB6J.js → LazyWhiteboard-BV98LEZ8.js} +2 -2
  24. package/dist/assets/{LessonEditorView-CZTZ7Q0B.js → LessonEditorView-LXRkKxdY.js} +1 -1
  25. package/dist/assets/LiveClassroomView-TaHtHWkY.js +63 -0
  26. package/dist/assets/{NotificationDetailModal-mUeIQP4R.js → NotificationDetailModal-BF_-pn0c.js} +1 -1
  27. package/dist/assets/{PluginView-CT3-zS2n.js → PluginView-sVMPXae9.js} +1 -1
  28. package/dist/assets/{ProcessLogsModal-DmsOrZnV.js → ProcessLogsModal-D97xLgnL.js} +1 -1
  29. package/dist/assets/{QuizGeneratorModal-ViKxNX5Q.js → QuizGeneratorModal-CNY8ISjR.js} +1 -1
  30. package/dist/assets/{StudentAssignmentEvalPanel-BRxHMABY.js → StudentAssignmentEvalPanel-CUmM5DbT.js} +1 -1
  31. package/dist/assets/{StudentAssignmentView-g-ewJIS3.js → StudentAssignmentView-B-1MtwKj.js} +1 -1
  32. package/dist/assets/{StudentLessonView-Dbvr3Xlo.js → StudentLessonView-CqrcvVND.js} +1 -1
  33. package/dist/assets/{StudentView-20vfEk4v.js → StudentView-Bi9kgSrN.js} +2 -2
  34. package/dist/assets/{SystemResourceLibraryModal-CDKeaKf8.js → SystemResourceLibraryModal-DDALKrJC.js} +1 -1
  35. package/dist/assets/{TeacherView-KIKuhXGF.js → TeacherView-C5JmoKHk.js} +2 -2
  36. package/dist/assets/{TimetableView-7V2AwWml.js → TimetableView-BOLB-kZC.js} +4 -4
  37. package/dist/assets/index-Bc9003lB.js +131 -0
  38. package/dist/assets/index-D4aq9poS.css +1 -0
  39. package/dist/assets/pluginParsers-DD3QL1Xl.js +1 -0
  40. package/dist/assets/{student-workspace-DstiW0pM.js → student-workspace-C4UgD58C.js} +1 -1
  41. package/dist/assets/{vendor-icons-DLOPlM4i.js → vendor-icons-CaXLq01o.js} +1 -1
  42. package/dist/index.html +3 -3
  43. package/dist/server.cjs +630 -433
  44. package/migrations/045_ai_providers_owner_and_scope.sql +20 -0
  45. package/migrations/README.md +1 -0
  46. package/migrations/schema-golden.json +13 -3
  47. package/package.json +4 -2
  48. package/dist/assets/AdminDirectoryView-Cdsk9Mdr.js +0 -5
  49. package/dist/assets/ImportModal-h5ShIMzO.js +0 -2
  50. package/dist/assets/InteractiveWhiteboard-DJqgP_tU.js +0 -65
  51. package/dist/assets/LiveClassroomView-D2ugupT9.js +0 -61
  52. package/dist/assets/index-C4cHQZyx.css +0 -1
  53. package/dist/assets/index-XduPa2-x.js +0 -131
  54. package/dist/assets/pluginParsers-BO6U1E-h.js +0 -1
package/README.md CHANGED
@@ -7,7 +7,10 @@
7
7
  [![pnpm: 10.x](https://img.shields.io/badge/pnpm-10.33.4-orange.svg)](package.json)
8
8
  [![CI](https://github.com/aymwoo/OpenLearn-Next-V2/actions/workflows/ci.yml/badge.svg)](https://github.com/aymwoo/OpenLearn-Next-V2/actions/workflows/ci.yml)
9
9
 
10
- 📚 **官方文档**:[在线文档库 (ReadTheDocs)](https://openlearn-next-v2.readthedocs.io/zh-cn/latest/) · [快速上手](https://openlearn-next-v2.readthedocs.io/zh-cn/latest/getting-started/quickstart.html) · [插件开发教程](https://openlearn-next-v2.readthedocs.io/zh-cn/latest/tutorials/plugin-development-tutorial.html) · [部署运维手册](https://openlearn-next-v2.readthedocs.io/zh-cn/latest/deployment/production-guide.html)
10
+ 📚 **官方文档**:[在线文档库 (ReadTheDocs)](https://openlearn-next-v2.readthedocs.io/zh-cn/latest/) · [**快速上手手册**(安装 → 运行 → 上课 → 写插件,含截图)](docs/getting-started/quickstart-handbook.md) · [插件开发教程](https://openlearn-next-v2.readthedocs.io/zh-cn/latest/tutorials/plugin-development-tutorial.html) · [部署运维手册](https://openlearn-next-v2.readthedocs.io/zh-cn/latest/deployment/production-guide.html)
11
+
12
+ > 🔁 **仓库双平台**:主仓 [GitHub](https://github.com/aymwoo/OpenLearn-Next-V2)(Issue / PR / CI / Release 主入口)| 镜像 [Gitee](https://gitee.com/aymwoo/openlearn-next)(**国内网络访问 GitHub 受限**时用于克隆源码与提交 Issue)。
13
+ > 镜像是 **GitHub → Gitee 单向同步**:内容与 `main` 对齐,但 **CI、Release、npm 发布仍只在 GitHub 侧运行**;提 Issue / PR 请只在一个平台开一份,避免两边分叉。
11
14
 
12
15
  ---
13
16
 
@@ -43,6 +46,8 @@
43
46
 
44
47
  ## 🚀 快速开始
45
48
 
49
+ > 第一次使用?先看 [**快速上手手册**](docs/getting-started/quickstart-handbook.md):安装 → 运行 → 上一节课 → 写第一个插件,一步一图。下面是命令速查。
50
+
46
51
  ### 方式 A:一键试用(无需克隆代码)
47
52
 
48
53
  ```bash
@@ -70,7 +75,9 @@ npm update -g openlearn-next # 更新
70
75
 
71
76
  ```bash
72
77
  # 1. 克隆仓库并安装依赖(建议 Node 22 + pnpm)
73
- git clone https://github.com/aymwoo/OpenLearn-Next-V2.git
78
+ git clone https://github.com/aymwoo/OpenLearn-Next-V2.git openlearnv2
79
+ # 国内网络访问 GitHub 受限时,改用 Gitee 镜像(内容一致,单向同步):
80
+ # git clone https://gitee.com/aymwoo/openlearn-next.git openlearnv2
74
81
  cd openlearnv2
75
82
  pnpm install
76
83
 
@@ -1 +1 @@
1
- import{r as o,j as e}from"./vendor-react-DHoBZpn2.js";import{e as D}from"./index-XduPa2-x.js";import{a4 as Q,X as q,o as H,n as J,B as V,h as X,Q as _,D as G,U as K,b1 as Y,b0 as Z,b2 as ee,e as te,P as se}from"./vendor-icons-DLOPlM4i.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-DVWGghIL.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-skggaP9D.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,b]=o.useState(!0),[j,$]=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 b(!0),ie(n).then(t=>{i||E(t)}).catch(t=>{i||$(t instanceof Error?t.message:String(t))}).finally(()=>{i||b(!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(q,{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(H,{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(J,{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(j)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:j})]});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
+ import{r as o,j as e}from"./vendor-react-DHoBZpn2.js";import{e as D}from"./index-Bc9003lB.js";import{a4 as Q,X as q,o as H,n as J,B as V,h as X,Q as _,D as G,U as K,b3 as Y,b2 as Z,b4 as ee,e as te,P as se}from"./vendor-icons-CaXLq01o.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-DVWGghIL.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-skggaP9D.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,b]=o.useState(!0),[j,$]=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 b(!0),ie(n).then(t=>{i||E(t)}).catch(t=>{i||$(t instanceof Error?t.message:String(t))}).finally(()=>{i||b(!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(q,{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(H,{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(J,{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(j)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:j})]});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};
@@ -0,0 +1,5 @@
1
+ import{r,j as e}from"./vendor-react-DHoBZpn2.js";import{E as W,aa as as,b as rs}from"./index-Bc9003lB.js";import{as as U,c as se,R as y,h as Ue,a4 as is,K as ns,T as te,V as os,af as Ee,S as J,e as ls,U as X,bz as ds,bx as Z,a8 as cs,ci as xs,ad as ee,ai as ms,i as hs,br as Pe,u as Re,ay as ps,an as $e,b1 as bs,X as Fe,bu as gs,b as us}from"./vendor-icons-CaXLq01o.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-DVWGghIL.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-skggaP9D.js";const fs=[{key:"lesson",zh:"课程",en:"Lessons"},{key:"class",zh:"班级",en:"Classes"},{key:"student",zh:"学生",en:"Students"},{key:"class_student",zh:"班级关系",en:"Enrollments"},{key:"schedule",zh:"课表",en:"Schedules"},{key:"user",zh:"账号",en:"Accounts"}];function ys({lang:n}){const[c,s]=r.useState(null),[P,k]=r.useState(!1),[j,S]=r.useState(!1),[m,D]=r.useState(!1),[N,g]=r.useState(null),Y=async l=>{const d=await l.json().catch(()=>({}));return d&&d.success?d.result:null},O=async l=>{const d=await l.json().catch(()=>({}));return{result:d&&d.success?d.result:null,message:d?.message}},C=r.useCallback(async()=>{try{k(!0);const l=await fetch("/api/demo-data/status");if(l.ok){const d=await Y(l);d&&s(d)}}catch(l){console.error("Failed to fetch demo data status",l)}finally{k(!1)}},[]);r.useEffect(()=>{C()},[C]);const p=!!(c&&(c.seeded||c.total>0)),I=async()=>{try{S(!0),g(null);const l=await fetch(`/api/demo-data/seed${p?"?reset=true":""}`,{method:"POST"}),d=await Y(l);l.ok&&d?(s(d),g({type:"success",text:n==="zh"?"演示数据已就绪,可用下方演示教师账号登录体验。":"Demo data is ready. Log in with the demo teacher account below."})):g({type:"error",text:n==="zh"?"初始化演示数据失败,请稍后重试。":"Failed to seed demo data, please retry."})}catch(l){g({type:"error",text:n==="zh"?`初始化失败:${l.message||"网络异常"}`:`Seed failed: ${l.message||"Network error"}`})}finally{S(!1)}},v=async()=>{if(confirm(n==="zh"?`确定要清理演示数据吗?
2
+
3
+ 只删除演示数据(演示教师、演示课程/班级/学生/课表),系统本身的数据不受影响,管理员账号不会被删除。`:`Purge demo data?
4
+
5
+ Only demo records (demo teacher, demo lesson/class/student/schedule) are removed. Your own data and administrator accounts are never touched.`))try{D(!0),g(null);const d=await fetch("/api/demo-data/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:"PURGE_DEMO_DATA"})}),{result:u,message:w}=await O(d);if(d.ok&&u){s(u.after?u.after:null),u.after||await C();const z=u.report?.totalRemoved,B=z===void 0?"":n==="zh"?`已清理 ${z} 条演示数据。`:`Removed ${z} demo records.`;g({type:"success",text:w||B})}else g({type:"error",text:n==="zh"?"清理演示数据失败,请稍后重试。":"Failed to purge demo data, please retry."})}catch(d){g({type:"error",text:n==="zh"?`清理失败:${d.message||"网络异常"}`:`Purge failed: ${d.message||"Network error"}`})}finally{D(!1)}},L=(l=>{if(!l)return null;const d=new Date(l);return Number.isNaN(d.getTime())?null:d.toLocaleString(n==="zh"?"zh-CN":"en-US",{hour12:!1})})(c?.seededAt),T=j||m;return e.jsx("div",{className:"mt-5",children:e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-3xs overflow-hidden",children:[e.jsxs("div",{className:"p-4 sm:p-5 border-b border-gray-100 flex items-center justify-between bg-gray-50/60",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-bold text-gray-800 flex items-center gap-2 text-sm sm:text-base",children:[e.jsx(U,{size:18,className:"text-indigo-600"}),n==="zh"?"演示数据(Demo)":"Demo Data"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:n==="zh"?"一键生成一套完整的演示课程 / 班级 / 学生 / 课表,便于快速体验与验收;清理时不影响系统本身的数据。":"One-click generation of a full demo lesson / class / student / schedule set for quick evaluation. Purging never touches real data."})]}),e.jsx("button",{type:"button",onClick:C,disabled:P||T,title:n==="zh"?"刷新状态":"Refresh status",className:"p-2 text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 rounded-lg transition-all cursor-pointer disabled:opacity-50 shrink-0",children:P?e.jsx(se,{size:15,className:"animate-spin"}):e.jsx(y,{size:15})})]}),e.jsxs("div",{className:"p-4 sm:p-5 space-y-5 text-left",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-bold border ${p?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-gray-50 text-gray-500 border-gray-200"}`,children:[p?e.jsx(Ue,{size:13}):e.jsx(U,{size:13}),p?n==="zh"?"已播种演示数据":"Demo data seeded":n==="zh"?"尚未播种演示数据":"No demo data yet"]}),L&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-semibold bg-gray-50 text-gray-500 border border-gray-200",children:[e.jsx(is,{size:13}),n==="zh"?`播种时间:${L}`:`Seeded at ${L}`]}),e.jsx("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-semibold bg-gray-50 text-gray-500 border border-gray-200",children:n==="zh"?`合计 ${c?.total??0} 条`:`${c?.total??0} records total`})]}),c?.counts&&e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:fs.map(l=>e.jsxs("div",{className:"flex items-center justify-between gap-2 px-2.5 py-2 rounded-lg border border-gray-200 bg-gray-50/60",children:[e.jsx("span",{className:"text-xs text-gray-500",children:n==="zh"?l.zh:l.en}),e.jsx("span",{className:"text-xs font-bold text-gray-700 font-mono",children:c.counts[l.key]??0})]},l.key))})]}),c?.credentials&&e.jsxs("div",{className:"rounded-lg border border-amber-100 bg-amber-50/60 px-3 py-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold text-amber-700",children:[e.jsx(ns,{size:13}),n==="zh"?"演示教师账号(可用于登录体验)":"Demo teacher account (for sign-in testing)"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-amber-800",children:[e.jsxs("span",{children:[n==="zh"?"姓名":"Name",": ",e.jsx("span",{className:"font-semibold",children:c.credentials.name})]}),e.jsxs("span",{children:[n==="zh"?"用户名":"Username",":"," ",e.jsx("span",{className:"font-mono font-bold",children:c.credentials.username})]}),e.jsxs("span",{children:[n==="zh"?"密码":"Password",":"," ",e.jsx("span",{className:"font-mono font-bold",children:c.credentials.password})]})]})]}),N&&e.jsxs("div",{className:`flex items-start gap-2 px-3 py-2.5 rounded-lg text-xs font-semibold border ${N.type==="success"?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-rose-50 text-rose-700 border-rose-100"}`,children:[N.type==="success"?e.jsx(Ue,{size:14,className:"shrink-0 mt-px"}):e.jsx(te,{size:14,className:"shrink-0 mt-px"}),e.jsx("span",{className:"whitespace-pre-line",children:N.text})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2 border-t border-gray-100",children:[e.jsxs("button",{type:"button",onClick:I,disabled:T,className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 rounded-lg shadow-sm transition-all cursor-pointer flex items-center gap-1.5",children:[j?e.jsx(se,{size:13,className:"animate-spin"}):p?e.jsx(y,{size:14}):e.jsx(os,{size:14}),e.jsx("span",{children:j?n==="zh"?"处理中...":"Working...":p?n==="zh"?"重置并重新初始化":"Reset & Re-seed Demo Data":n==="zh"?"一键初始化演示数据":"Seed Demo Data"})]}),e.jsxs("button",{type:"button",onClick:v,disabled:T||!p,className:"px-4 py-2 text-xs font-bold text-white bg-rose-600 hover:bg-rose-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg shadow-sm transition-all cursor-pointer flex items-center gap-1.5",children:[m?e.jsx(se,{size:13,className:"animate-spin"}):e.jsx(Ee,{size:14}),e.jsx("span",{children:m?n==="zh"?"清理中...":"Purging...":n==="zh"?"一键清理演示数据":"Purge Demo Data"})]}),!p&&e.jsx("span",{className:"text-xs text-gray-400",children:n==="zh"?"清理前需先初始化演示数据。":"Seed demo data before purging."})]})]})]})})}function js({currentUserId:n,currentUserRole:c,lang:s,onLogout:P,aiProviders:k,onAIProvidersChanged:j,onTriggerTour:S,siteInfo:m,onSiteInfoChanged:D}){const[N,g]=r.useState([]),[Y,O]=r.useState(!1),[C,p]=r.useState(""),[I,v]=r.useState(""),[ae,L]=r.useState(m?.siteName||""),[T,l]=r.useState(m?.slogan||""),[d,u]=r.useState(m?.logoUrl||null),[w,z]=r.useState(m?.logoUrl||""),[B,ge]=r.useState(m?.uploadMaxFileMb??10),[ue,fe]=r.useState(m?.currentAcademicYear??""),[ye,je]=r.useState(9),[re,Ne]=r.useState(!1),[ve,_e]=r.useState(!1),[V,we]=r.useState(""),[ie,Ye]=r.useState("all"),[Oe,R]=r.useState(!1),[A,ze]=r.useState(null),[ne,oe]=r.useState(""),[le,de]=r.useState(""),[ce,xe]=r.useState(""),[me,q]=r.useState("teacher"),[he,Q]=r.useState("active"),[ke,M]=r.useState(""),[pe,Se]=r.useState(!1),[Ns,vs]=r.useState({tables:14,sizeKb:256,pingMs:2}),[Ie,Be]=r.useState(14),[Ve,qe]=r.useState(0),[b,$]=r.useState("directory"),[i,Qe]=r.useState(null),[F,Ce]=r.useState(!1),[h,Ge]=r.useState(null),[G,Ae]=r.useState(!1),[He,Me]=r.useState(null),[f,be]=r.useState("npm"),[De,Le]=r.useState(null),Te=async()=>{try{Ae(!0);const t=await fetch("/api/system/check-upgrade");if(t.ok){const a=await t.json();Ge(a)}}catch(t){console.error("Failed to check system upgrade",t)}finally{Ae(!1)}},Ke=(t,a)=>{navigator?.clipboard?.writeText&&navigator.clipboard.writeText(t),Me(a),setTimeout(()=>Me(null),2e3)},H=async()=>{try{Ce(!0);const t=await fetch("/api/db-status");if(t.ok){const a=await t.json();Qe(a)}}catch(t){console.error("Failed to query SQLite stats",t)}finally{Ce(!1)}},We=async()=>{try{const t=await fetch("/api/site-settings");if(t.ok){const a=await t.json();L(a.siteName||""),l(a.slogan||""),u(a.logoUrl||null),z(a.logoUrl||""),typeof a.uploadMaxFileMb=="number"&&a.uploadMaxFileMb>0&&ge(a.uploadMaxFileMb),typeof a.currentAcademicYear=="string"&&a.currentAcademicYear&&fe(a.currentAcademicYear),typeof a.academicStartMonth=="number"&&a.academicStartMonth>0&&je(a.academicStartMonth),_e(!0)}}catch(t){console.error("Failed to fetch site settings",t)}},Je=t=>{if(!t)return;const a=new FileReader;a.onload=()=>{const x=a.result;u(x),z(x)},a.readAsDataURL(t)},Xe=async t=>{t.preventDefault();try{Ne(!0);const a=w&&w.trim()?w.trim():null,x=await fetch("/api/site-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteName:ae.trim(),slogan:T.trim(),logoUrl:a,uploadMaxFileMb:Math.round(Number(B)),currentAcademicYear:ue.trim()||void 0,academicStartMonth:Math.round(Number(ye))})});if(x.ok){const o=await x.json();u(a),D?.(o.siteInfo),v(s==="zh"?"站点信息已保存!":"Site settings saved successfully!"),setTimeout(()=>v(""),4e3)}else{const o=await x.json().catch(()=>({}));alert(o.error||"Server error")}}catch(a){alert(a.message||"Error")}finally{Ne(!1)}},K=async()=>{try{O(!0),p("");const t=await fetch("/api/users");if(t.ok){const a=await t.json();g(a)}else p(s==="zh"?"加载用户账户失败":"Failed to fetch staff directory")}catch{p(s==="zh"?"网络连接异常":"Network communication issue")}finally{O(!1)}};r.useEffect(()=>{if(c!=="administrator")return;let t=!1;return fetch("/api/system/encryption-status").then(a=>a.ok?a.json():null).then(a=>{if(t)return;const x=typeof a?.warning=="string"?a.warning.trim():"";Le(x||null)}).catch(()=>{t||Le(null)}),()=>{t=!0}},[c]),r.useEffect(()=>{K(),H(),Te(),j();const t=setInterval(()=>{H(),Be(a=>{const x=Math.floor(Math.random()*9)-4,o=a+x;return Math.min(Math.max(o,5),35)})},5e3);return()=>clearInterval(t)},[Ve]),r.useEffect(()=>{b==="site_settings"&&!ve&&We()},[b,ve]);const Ze=()=>{ze(null),oe(""),de(""),xe(""),q("teacher"),Q("active"),M(""),R(!0)},es=t=>{ze(t.id),oe(t.username),de(""),xe(t.name),q(t.role),Q(t.status||"active"),M(""),R(!0)},ss=async t=>{if(t.preventDefault(),!ne.trim()||!ce.trim()){M(s==="zh"?"请填写所有必填字段。":"Please provide all key info.");return}if(!A&&!le){M(s==="zh"?"新建账户时密码必填。":"Password is required for new accounts.");return}try{M(""),Se(!0);const a=A?`/api/users/${A}`:"/api/users",o=await fetch(a,{method:A?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:ne.trim(),password:le||void 0,role:me,name:ce.trim(),status:he})});if(o.ok)v(s==="zh"?"账户信息保存成功!":"Staff account saved successfully!"),K(),R(!1),setTimeout(()=>v(""),4e3);else{const _=await o.json();M(_.error||"Server validation failed")}}catch(a){M(a.message||"API error")}finally{Se(!1)}},ts=async(t,a)=>{if(t===n){alert(s==="zh"?"你不能删除你自己当前登录的账户。":"You cannot delete your own logged-in account.");return}const x=s==="zh"?`确定要删除教师账户 "${a}" 吗?此操作不可逆。`:`Confirm deleting staff user "${a}"? This action is irreversible.`;if(confirm(x))try{const o=await fetch(`/api/users/${t}`,{method:"DELETE"});if(o.ok)v(s==="zh"?"账户删除成功":"Account deleted successfully"),K(),setTimeout(()=>v(""),3e3);else{const _=await o.json();alert(_.error||"Failed to delete")}}catch(o){console.error(o)}},E=N.filter(t=>{const a=t.name.toLowerCase().includes(V.toLowerCase())||t.username.toLowerCase().includes(V.toLowerCase()),x=ie==="all"||t.role===ie;return a&&x});return e.jsxs("div",{className:"flex-1 bg-white border border-gray-200 rounded-xl shadow-sm flex flex-col min-h-0 overflow-hidden h-full",id:"admin_panel_root",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex flex-col sm:flex-row sm:items-center justify-between gap-3 bg-white shrink-0",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-base sm:text-lg font-bold text-gray-800 flex items-center gap-2",children:[e.jsx(J,{className:"text-indigo-600 shrink-0",size:20}),e.jsx("span",{children:s==="zh"?"系统管理与教职后台":"Staff Directory & System Admin"}),e.jsx("span",{className:"text-xs font-semibold px-2 py-0.5 rounded-full bg-indigo-50 text-indigo-700 border border-indigo-100/80",children:c==="administrator"?s==="zh"?"超级管理员":"Admin":s==="zh"?"教师":"Teacher"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s==="zh"?`管理学校教师、教工账户、划分角色权限。当前登录角色权限: ${c==="administrator"?"超级管理员 (系统设置已解锁)":"普通教师 (系统设置锁定)"}`:`Create and assign teacher credentials. Active role context: ${c==="administrator"?"Administrator (System parameters editable)":"Standard Teacher (Settings view-only)"}`})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[S&&e.jsxs("button",{onClick:S,className:"flex items-center gap-1.5 px-3 py-1.5 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 text-xs font-semibold rounded-lg border border-indigo-200 transition-all cursor-pointer shadow-3xs",children:[e.jsx(ls,{size:14,className:"animate-bounce"}),e.jsx("span",{children:s==="zh"?"开启新手引导":"Start Help Tour"})]}),e.jsx("button",{onClick:()=>qe(t=>t+1),className:"p-1.5 text-gray-500 hover:text-indigo-600 hover:bg-gray-100 rounded-lg transition-all cursor-pointer border border-gray-200 shadow-3xs",title:s==="zh"?"刷新数据":"Refresh stats",children:e.jsx(y,{size:14})})]})]}),De?e.jsxs("div",{role:"alert",className:"mx-6 mt-4 rounded-xl border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:[e.jsxs("div",{className:"font-bold flex items-center gap-2",children:[e.jsx(te,{size:16,className:"shrink-0"}),"正在使用自动生成的加密密钥"]}),e.jsx("p",{className:"mt-1 leading-relaxed",children:De})]}):null,e.jsx("div",{className:"px-6 py-2.5 border-b border-gray-100 bg-gray-50/50 flex items-center justify-between gap-4 shrink-0 overflow-x-auto",children:e.jsxs("div",{className:"bg-gray-200/60 p-1 rounded-xl flex items-center gap-1 shrink-0",children:[e.jsxs("button",{onClick:()=>$("directory"),className:`px-3.5 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 transition-all cursor-pointer ${b==="directory"?"bg-white text-indigo-700 shadow-xs":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(X,{size:14}),e.jsx("span",{children:s==="zh"?"学校教职及系统配置":"Staff Accounts & Config"})]}),e.jsxs("button",{onClick:()=>$("ai_providers"),className:`px-3.5 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 transition-all cursor-pointer ${b==="ai_providers"?"bg-white text-indigo-700 shadow-xs":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(ds,{size:14}),e.jsx("span",{children:s==="zh"?"AI 模型提供商":"AI Providers"})]}),e.jsxs("button",{onClick:()=>$("sqlite"),className:`px-3.5 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 transition-all cursor-pointer ${b==="sqlite"?"bg-white text-indigo-700 shadow-xs":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(U,{size:14}),e.jsx("span",{children:s==="zh"?"系统监控":"System Monitor"})]}),e.jsxs("button",{onClick:()=>$("site_settings"),className:`px-3.5 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 transition-all cursor-pointer ${b==="site_settings"?"bg-white text-indigo-700 shadow-xs":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(Z,{size:14}),e.jsx("span",{children:s==="zh"?"站点信息设置":"Site Settings"})]}),e.jsx(W,{slot:"admin.tab",slotProps:{renderType:"button",adminActiveTab:b,setAdminActiveTab:$}})]})}),I&&e.jsxs("div",{className:"mx-6 mt-3 p-3 bg-emerald-50 border border-emerald-200 text-emerald-800 text-xs rounded-xl flex items-center gap-2 shrink-0 animate-fade-in shadow-xs font-medium",children:[e.jsx(cs,{size:15}),e.jsx("span",{children:I})]}),C&&e.jsxs("div",{className:"mx-6 mt-3 p-3 bg-rose-50 border border-rose-200 text-rose-800 text-xs rounded-xl flex items-center gap-2 shrink-0 animate-fade-in shadow-xs",children:[e.jsx(te,{size:15}),e.jsx("span",{children:C})]}),b==="ai_providers"?e.jsx(as,{lang:s,aiProviders:k,onAIProvidersChanged:j,currentUserId:n,currentUserRole:c}):b==="sqlite"?e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 animate-fade-in text-gray-800",children:[e.jsxs("div",{className:"bg-gradient-to-r from-slate-900 via-indigo-950 to-slate-900 border border-indigo-800/60 rounded-2xl p-5 text-white shadow-xs overflow-hidden relative",children:[e.jsx("div",{className:"absolute right-0 top-0 translate-x-8 -translate-y-8 w-56 h-56 bg-indigo-500/10 rounded-full blur-3xl pointer-events-none"}),e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 border-b border-indigo-800/50 pb-4",children:[e.jsxs("div",{className:"flex items-start sm:items-center gap-3",children:[e.jsx("div",{className:"p-2.5 bg-indigo-600/30 border border-indigo-500/30 rounded-xl text-indigo-300 shrink-0",children:e.jsx(xs,{size:22,className:G?"animate-spin":""})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-extrabold text-sm sm:text-base text-white tracking-wide",children:s==="zh"?"系统版本与升级生命周期":"System Version & Upgrade Lifecycle"}),e.jsxs("span",{className:"font-mono text-xs px-2 py-0.5 rounded-md bg-indigo-900/90 text-indigo-200 border border-indigo-700/60 font-semibold",children:["v",h?.currentVersion||"2.0.0"]}),h?.hasUpdate?e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-md bg-amber-500/20 text-amber-300 border border-amber-500/40 font-semibold flex items-center gap-1.5 animate-pulse",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400"}),s==="zh"?`可升级至 v${h.latestVersion}`:`Update Available: v${h.latestVersion}`]}):h?e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-md bg-emerald-500/20 text-emerald-300 border border-emerald-500/40 font-semibold flex items-center gap-1",children:[e.jsx(ee,{size:12}),s==="zh"?"已是最新版本":"Up to date"]}):null]}),e.jsx("p",{className:"text-xs text-indigo-200/80 mt-1",children:s==="zh"?"纯 Node.js 生产环境平滑升级管理,支持 NPM 官方源与国内镜像双源智能探测与一键迁移保障。":"Zero-downtime upgrades for Node.js environments with automated pre-migration safety snapshots."})]})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:e.jsxs("button",{type:"button",onClick:Te,disabled:G,className:"px-3.5 py-1.5 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-bold rounded-xl border border-indigo-400/40 flex items-center gap-1.5 transition-all cursor-pointer disabled:opacity-50 shadow-xs",children:[e.jsx(y,{size:12,className:G?"animate-spin":""}),e.jsx("span",{children:G?s==="zh"?"正在检测...":"Checking...":s==="zh"?"检查更新":"Check Updates"})]})})]}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-indigo-200/90",children:s==="zh"?"无缝升级执行命令(根据您的部署方式选择):":"Upgrade command by deployment form factor:"}),e.jsxs("div",{className:"flex items-center bg-indigo-950/90 p-0.5 rounded-lg border border-indigo-700/50 text-xs font-semibold",children:[e.jsx("button",{type:"button",onClick:()=>be("npm"),className:`px-2.5 py-1 rounded-md transition-all cursor-pointer ${f==="npm"?"bg-indigo-600 text-white shadow-xs":"text-indigo-300 hover:text-white"}`,children:s==="zh"?"全局 NPM":"Global NPM"}),e.jsx("button",{type:"button",onClick:()=>be("npx"),className:`px-2.5 py-1 rounded-md transition-all cursor-pointer ${f==="npx"?"bg-indigo-600 text-white shadow-xs":"text-indigo-300 hover:text-white"}`,children:s==="zh"?"NPX 免安装":"NPX Runner"}),e.jsx("button",{type:"button",onClick:()=>be("git"),className:`px-2.5 py-1 rounded-md transition-all cursor-pointer ${f==="git"?"bg-indigo-600 text-white shadow-xs":"text-indigo-300 hover:text-white"}`,children:s==="zh"?"源码部署 (Git)":"Source Clone"})]})]}),e.jsxs("div",{className:"bg-slate-950/90 border border-indigo-800/80 rounded-xl p-3 flex items-center justify-between gap-3 font-mono text-xs",children:[e.jsxs("div",{className:"text-emerald-400 select-all overflow-x-auto whitespace-nowrap scrollbar-none font-medium",children:[f==="npm"&&(h?.upgradeCommands.npm||"npm i -g openlearn-next@latest"),f==="npx"&&(h?.upgradeCommands.npx||"npx openlearn-next@latest"),f==="git"&&(h?.upgradeCommands.git||"git pull && pnpm build && pnpm start")]}),e.jsx("button",{type:"button",onClick:()=>{const t=f==="npm"?h?.upgradeCommands.npm||"npm i -g openlearn-next@latest":f==="npx"?h?.upgradeCommands.npx||"npx openlearn-next@latest":h?.upgradeCommands.git||"git pull && pnpm build && pnpm start";Ke(t,f)},className:"px-2.5 py-1 bg-indigo-600/40 hover:bg-indigo-600 text-indigo-100 hover:text-white rounded-lg border border-indigo-500/40 flex items-center gap-1.5 transition-all cursor-pointer shrink-0 font-sans text-xs font-semibold",children:He===f?e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:12,className:"text-emerald-400"}),e.jsx("span",{className:"text-emerald-300",children:s==="zh"?"已复制":"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ms,{size:12}),e.jsx("span",{children:s==="zh"?"复制":"Copy"})]})})]}),e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-indigo-300/80 pt-0.5",children:[e.jsx("span",{children:s==="zh"?"🛡️ 数据安全保障:系统启动及执行数据库迁移时会自动创建物理快照 (backups/pre_migration_*.db)。亦可随时执行 openlearn backup --full 整包归档。":'🛡️ Automated pre-migration snapshots are recorded. Run "openlearn backup --full" anytime for complete state packaging.'}),h?.publishTime&&e.jsxs("span",{className:"shrink-0 ml-2",children:[s==="zh"?"更新时间: ":"Published: ",new Date(h.publishTime).toLocaleDateString()]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1 text-left",children:[e.jsx("span",{className:"text-xs font-black text-slate-400 uppercase tracking-widest block",children:s==="zh"?"SQLite引擎状况":"SQLite Health Status"}),e.jsxs("span",{className:"text-base font-extrabold text-gray-800 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse inline-block"}),e.jsx("span",{className:"text-emerald-600 font-extrabold uppercase mt-0.5",children:i?.status==="connected"?s==="zh"?"运行正常":"Healthy":s==="zh"?"连接正常":"Connected"})]}),e.jsx("span",{className:"text-xs text-gray-400 block font-mono",children:"SQLite Core v3.x Connected"})]}),e.jsx("div",{className:"p-3 bg-emerald-50 text-emerald-600 rounded-xl",children:e.jsx(J,{size:20})})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1 text-left",children:[e.jsx("span",{className:"text-xs font-black text-slate-400 uppercase tracking-widest block",children:s==="zh"?"核心实体数据表":"Database Table Count"}),e.jsx("span",{className:"text-xl font-black font-mono text-gray-800 block",children:i?.tableCount??"--"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?`包含其外 ${i?.systemTableCount??0} 个系统表`:`Plus ${i?.systemTableCount??0} system catalogs`})]}),e.jsx("div",{className:"p-3 bg-indigo-50 text-indigo-600 rounded-xl",children:e.jsx(U,{size:20})})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1 text-left",children:[e.jsx("span",{className:"text-xs font-black text-slate-400 uppercase tracking-widest block",children:s==="zh"?"系统数据承载行":"Total Records Managed"}),e.jsx("span",{className:"text-xl font-black font-mono text-indigo-700 block",children:i?.totalRows!==void 0?i.totalRows.toLocaleString():"--"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"在册全量索引行数总和":"Cumulative dataset depth"})]}),e.jsx("div",{className:"p-3 bg-indigo-50 text-indigo-600 rounded-xl",children:e.jsx(hs,{size:20})})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1 text-left",children:[e.jsx("span",{className:"text-xs font-black text-slate-400 uppercase tracking-widest block",children:s==="zh"?"物理文件占用空间":"Physical Disk Usage"}),e.jsx("span",{className:"text-xl font-black font-mono text-emerald-600 block",children:i?.diskUsageFriendly??"--"}),e.jsx("span",{className:"text-xs text-gray-400 block font-mono",children:i?.diskUsageBytes?`${i.diskUsageBytes.toLocaleString()} Bytes`:""})]}),e.jsx("div",{className:"p-3 bg-emerald-50 text-emerald-600 rounded-xl",children:e.jsx(Pe,{size:20})})]}),e.jsx(W,{slot:"admin.dashboard.card",slotProps:{sqliteStats:i,lang:s}})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6 items-start",children:[e.jsxs("div",{className:"lg:col-span-8 bg-white border border-gray-200 rounded-xl shadow-3xs overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-4 sm:p-5 border-b border-gray-100 bg-gray-50/60 flex items-center justify-between",children:[e.jsxs("div",{className:"text-left",children:[e.jsxs("h3",{className:"font-extrabold text-gray-800 text-sm sm:text-base flex items-center gap-1.5 justify-start",children:[e.jsx(U,{className:"text-indigo-600",size:18}),s==="zh"?"SQLite 数据库实体列表与行数字典":"SQLite Relational Entity Tables Catalog"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-1 block",children:s==="zh"?"实时展示当前在 educational_os.db 内核中的关系型实体及在册记录行数。":"Dynamic row counting dictionary directly querying metadata catalogs."})]}),e.jsxs("button",{onClick:H,disabled:F,className:"p-1 px-3 text-xs bg-indigo-50 hover:bg-indigo-100 text-indigo-700 font-bold border border-indigo-200/45 rounded-xl flex items-center gap-1 transition-all cursor-pointer",children:[e.jsx(y,{size:11,className:F?"animate-spin":""}),s==="zh"?"重算/刷新 font":"Refresh Metrics"]})]}),e.jsx("div",{className:"p-4 sm:p-5",children:F&&!i?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-slate-400 text-xs",children:[e.jsx(y,{size:36,className:"animate-spin text-indigo-500 mb-2"}),e.jsx("span",{children:s==="zh"?"正在重算数据库实体表统计指标...":"Calculating database page allocation and statistics..."})]}):i?e.jsx("div",{className:"overflow-x-auto border border-gray-100 rounded-xl",children:e.jsxs("table",{className:"w-full text-left border-collapse min-w-[500px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50/70 border-b border-gray-100 text-gray-500 font-bold text-xs uppercase tracking-wider font-sans",children:[e.jsx("th",{className:"py-3 px-4",children:s==="zh"?"实体数据表名":"Table Name"}),e.jsx("th",{className:"py-3 px-4",children:s==="zh"?"当前承载行数":"Active Rows"}),e.jsx("th",{className:"py-3 px-4",children:s==="zh"?"行数比例分布":"Distribution Scale"}),e.jsx("th",{className:"py-3 px-4 font-mono select-none",children:s==="zh"?"系统属性类型":"Metadata Type"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 text-xs text-gray-700 font-sans",children:i.tables.map(t=>{const a=Math.max(...i.tables.map(_=>_.rows),1),x=Math.min(t.rows/a*100,100);let o="Core Application Storage";return t.name==="users"?o="Teacher & Administrator profiles":t.name==="students"?o="Student accounts and lock states":t.name==="classes"?o="Active classes, metadata & codes":t.name==="lessons"?o="Lectures, slides and markdown modules":t.name==="ai_providers"?o="Third party API key provider gateways":t.name==="vfs_nodes"?o="Virtual file storage hierarchies":t.name==="client_sessions"&&(o="Active browser auth cookies"),e.jsxs("tr",{className:"hover:bg-slate-50/40 transition-colors",children:[e.jsxs("td",{className:"py-3 px-4 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2 justify-start",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-indigo-500"}),e.jsx("span",{className:"font-extrabold text-slate-800 font-mono text-sm",children:t.name})]}),e.jsx("span",{className:"text-xs text-gray-400 block mt-0.5",children:o})]}),e.jsx("td",{className:"py-3 px-4 font-mono font-bold text-gray-750 text-left",children:t.rows>=0?t.rows.toLocaleString():e.jsx("span",{className:"text-rose-500 italic font-normal",children:"error"})}),e.jsx("td",{className:"py-3 px-4 min-w-[150px]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-24 bg-gray-100 rounded-full h-1.5 overflow-hidden border border-gray-200/50 shrink-0",children:e.jsx("div",{className:"bg-indigo-600 h-1.5 rounded-full",style:{width:`${x}%`}})}),e.jsxs("span",{className:"text-xs font-mono font-bold text-slate-400",children:[Math.round(x),"%"]})]})}),e.jsx("td",{className:"py-3 px-4 text-left",children:e.jsx("span",{className:"bg-slate-100 text-slate-700 font-bold border border-slate-200 text-xs font-mono px-2 py-0.5 rounded uppercase",children:t.name==="vfs_nodes"||t.name==="whiteboard_strokes"?"BLOB_JSON":"RELATIONAL"})})]},t.name)})})]})}):e.jsx("div",{className:"text-center text-xs py-12 text-slate-400",children:s==="zh"?"无法提取到 SQLite 信息,可能进程被独占。":"Failed to retrieve connection parameters."})})]}),e.jsxs("div",{className:"lg:col-span-4 space-y-6",children:[e.jsxs("div",{className:"bg-white border border-gray-200 rounded-2xl shadow-xs p-5 block text-left",children:[e.jsxs("h3",{className:"text-xs font-black text-gray-700 uppercase tracking-widest flex items-center gap-2 border-b border-gray-100 pb-3 mb-4",children:[e.jsx(Z,{size:15,className:"text-slate-500"}),s==="zh"?"物理控制参数 (PRAGMA)":"SQLite Physical PRAGMAs"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"日志记录模式":"Journal Write Mode"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"决定写操作事务隔离行为":"Active database write transaction protocol"})]}),e.jsx("span",{className:"bg-emerald-50 text-emerald-800 font-mono font-extrabold text-xs px-2.5 py-1 border border-emerald-200 rounded-lg",children:i?.journalMode?i.journalMode.toUpperCase():"N/A"})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"物理扇区页面大小":"Database Page Size"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"单次读写磁盘扇区的字节":"Bytes per allocated physical sector block"})]}),e.jsx("span",{className:"bg-slate-100 text-slate-800 font-mono font-bold text-xs px-2 py-1 border border-slate-200 rounded",children:i?.pageSize?`${i.pageSize} B`:"4096 B"})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"逻辑数据页面总数":"Allocated Blocks Count"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"物理文件包含的逻辑存储页总数":"Total blocks assigned inside database space"})]}),e.jsxs("span",{className:"font-mono text-xs font-bold text-gray-700",children:[i?.pageCount??0," pages"]})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"数据文件完整性自检":"Database File Integrity"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"校验物理页面结构是否损坏":"Validates internal database consistency"})]}),e.jsx("span",{className:"bg-indigo-600 text-white font-mono font-black text-xs px-2 py-0.5 rounded-full shadow-xs",children:i?.integrity?i.integrity.toUpperCase():"PASS"})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"空闲可回收空间块数":"Freelist Empty Pages"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"已被清删但未回缩的空间块数":"Reclaimable blocks pending database VACUUM"})]}),e.jsxs("span",{className:"font-mono text-xs text-gray-750",children:[i?.freelistCount??0," Blocks"]})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"自动空间释放 (Auto Vacuum)":"Auto Vacuum Mode"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"删除数据是否即时整理碎片":"Reclaims file blocks upon record deletions"})]}),e.jsx("span",{className:"text-xs text-slate-500 font-bold",children:i?.autoVacuum===0?"NONE (OFF)":i?.autoVacuum===1?"FULL":"INCREMENTAL"})]})]})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-2xl shadow-xs p-5 block text-left text-gray-800",children:[e.jsxs("h3",{className:"text-xs font-black text-gray-700 uppercase tracking-widest flex items-center gap-2 border-b border-gray-100 pb-3 mb-4 select-none font-sans",children:[e.jsx(Re,{size:14,className:"text-indigo-600 animate-pulse"}),s==="zh"?"分布式内核维护工具箱":"In-Memory Engine Toolbox"]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{onClick:async()=>{alert(s==="zh"?"PRAGMA integrity_check 执行结果: 完整性检测通过(OK). SQLite 数据库物理区块没有任何损坏。":"Database physical consistency verification result: PASS. File blocks are structurally sound.")},className:"w-full text-left bg-slate-50 hover:bg-slate-100 text-gray-800 border border-gray-200 p-3 rounded-xl transition-all cursor-pointer flex items-center gap-3",children:[e.jsx(J,{size:16,className:"text-indigo-600 shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-bold block text-gray-800",children:s==="zh"?"立即执行物理文件自检":"Run Consistency self-audit"}),e.jsx("span",{className:"text-xs text-gray-500 block leading-tight mt-0.5",children:s==="zh"?"核验 educational_os.db 是否有损坏或空页":"Runs a full PRAGMA integrity_check cycle"})]})]}),e.jsxs("button",{onClick:async()=>{alert(s==="zh"?"数据库空间优化成功!释放 0 空闲逻辑页,文件结构对齐完成。":"VACUUM command completed. Over-allocated files are fully reclaimed.")},className:"w-full text-left bg-slate-50 hover:bg-slate-100 text-gray-800 border border-gray-200 p-3 rounded-xl transition-all cursor-pointer flex items-center gap-3",children:[e.jsx(Pe,{size:16,className:"text-emerald-600 shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-bold block text-gray-800",children:s==="zh"?"磁盘碎片整理与空间回缩 (VACUUM)":"Defragment Storage (VACUUM)"}),e.jsx("span",{className:"text-xs text-gray-500 block leading-tight mt-0.5",children:s==="zh"?"物理重排在册物理空间,释放可能存在的空置块":"Triggers VACUUM rebuild to compress physical file"})]})]})]})]})]})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-2xl shadow-xs p-5 flex flex-col shrink-0 animate-fade-in text-gray-850",id:"db_health_dashboard_card",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-3 mb-4",children:[e.jsxs("div",{className:"text-left",children:[e.jsxs("h3",{className:"text-xs font-black text-gray-750 uppercase tracking-widest flex items-center gap-1.5",children:[e.jsx(U,{size:15,className:"text-indigo-600"}),s==="zh"?"SQLite 数据库健康体检":"Database Engine Health"]}),e.jsx("span",{className:"text-xs text-gray-405 block mt-0.5",children:s==="zh"?"实时检测 SQLite 物理空间分配与查询相应时延":"Dynamic, real-time diagnostic metrics directly from connection catalogs."})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]}),e.jsx("span",{className:"text-xs font-bold text-emerald-600 font-mono uppercase tracking-wider",children:s==="zh"?"正常运行":"Healthy"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{className:"bg-slate-50 border border-gray-100 p-3 rounded-xl flex flex-col justify-between text-left",children:[e.jsx("span",{className:"text-xs font-black text-gray-450 uppercase tracking-widest block",children:s==="zh"?"实体表总数":"Total Tables"}),e.jsxs("div",{className:"mt-2 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-xl font-extrabold text-slate-800 font-mono",children:i?.tableCount??"--"}),e.jsx("span",{className:"text-xs text-gray-405 font-bold uppercase",children:s==="zh"?"个":"tbls"})]}),e.jsx("span",{className:"text-xs text-gray-400 block mt-1 truncate",children:s==="zh"?`外含 ${i?.systemTableCount??0} 个系统表`:`+${i?.systemTableCount??0} catalogs`})]}),e.jsxs("div",{className:"bg-slate-50 border border-gray-100 p-3 rounded-xl flex flex-col justify-between text-left",children:[e.jsx("span",{className:"text-xs font-black text-gray-450 uppercase tracking-widest block",children:s==="zh"?"文件容量":"Disk Size"}),e.jsxs("div",{className:"mt-2 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-xl font-extrabold text-indigo-650 font-mono animate-fade-in",children:i?.sizeMb!==void 0?i.sizeMb:"--"}),e.jsx("span",{className:"text-xs text-gray-455 font-bold uppercase",children:"MB"})]}),e.jsx("span",{className:"text-xs text-gray-400 block mt-1 truncate",children:i?.diskUsageFriendly??(s==="zh"?"计算空间中...":"Evaluating...")})]}),e.jsxs("div",{className:"bg-slate-50 border border-gray-100 p-3 rounded-xl flex flex-col justify-between text-left",children:[e.jsx("span",{className:"text-xs font-black text-gray-455 uppercase tracking-widest block",children:s==="zh"?"读取时延/耗时":"Query Latency"}),e.jsxs("div",{className:"mt-2 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-xl font-extrabold text-emerald-600 font-mono animate-fade-in",children:i?.latencyMs!==void 0?i.latencyMs:"--"}),e.jsx("span",{className:"text-xs text-gray-450 font-bold uppercase",children:"ms"})]}),e.jsx("span",{className:"text-xs text-gray-400 block mt-1 truncate",children:s==="zh"?"元数据对齐周期":"Direct catalog check"})]})]}),e.jsxs("div",{className:"flex items-center justify-between bg-slate-50/50 border border-gray-150/40 p-2 rounded-xl",children:[e.jsx("span",{className:"text-xs text-gray-400 font-medium pl-1",children:s==="zh"?"自动检测轮询间隔: 5s":"Dynamic background poll: 5s"}),e.jsxs("button",{type:"button",onClick:H,disabled:F,className:"p-1 px-3 text-xs bg-indigo-50 hover:bg-indigo-100 text-indigo-700 font-black tracking-wider uppercase border border-indigo-250/20 rounded-lg flex items-center gap-1 transition-all cursor-pointer",children:[e.jsx(y,{size:10,className:F?"animate-spin":""}),s==="zh"?"实时评测":"Benchmark Latency"]})]})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-3xs p-5 flex flex-col flex-1 overflow-y-auto",children:[e.jsxs("h3",{className:"text-xs font-black text-gray-700 uppercase tracking-widest flex items-center gap-2 border-b border-gray-100 pb-3 mb-4 select-none",children:[e.jsx(Re,{size:14,className:"text-indigo-600 animate-pulse"}),s==="zh"?"分布式操作系统硬件状况":"Distributed Node Telemetry"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-5",children:[e.jsxs("div",{className:"bg-slate-50 border border-gray-150/65 p-2.5 rounded-xl text-center",children:[e.jsx("span",{className:"text-xs font-bold text-gray-500 block uppercase",children:s==="zh"?"处理器负载":"CPU Load"}),e.jsxs("span",{className:"text-sm font-black font-mono text-indigo-600 block mt-1",children:[Ie,"%"]})]}),e.jsxs("div",{className:"bg-slate-50 border border-gray-150/65 p-2.5 rounded-xl text-center",children:[e.jsx("span",{className:"text-xs font-bold text-gray-500 block uppercase",children:s==="zh"?"数据库行数":"DB Buffer"}),e.jsx("span",{className:"text-sm font-black font-mono text-emerald-600 block mt-1",children:i!==null?i.totalRows.toLocaleString():"2,840"})]}),e.jsxs("div",{className:"bg-slate-50 border border-gray-150/65 p-2.5 rounded-xl text-center",children:[e.jsx("span",{className:"text-xs font-bold text-gray-500 block uppercase",children:s==="zh"?"主数据库延迟":"DB Net Delay"}),e.jsx("span",{className:"text-sm font-black font-mono text-amber-600 block mt-1",children:i!==null&&i.latencyMs!==void 0?`${i.latencyMs} ms`:"1.5 ms"})]})]}),e.jsxs("div",{className:"flex-1 min-h-[160px] overflow-y-auto bg-slate-50 border border-gray-150/60 p-3 rounded-xl font-mono text-xs space-y-1.5 text-gray-650 scrollbar-none",children:[e.jsxs("div",{className:"flex items-center gap-1 text-gray-450 select-none",children:[e.jsx(ps,{size:11})," ",e.jsx("span",{children:"[root@sys-kernel-0] logs --level=info"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-emerald-500 font-bold",children:"[OK]"})," SQLite3 initialization complete: educational_os.db successfully mounted."]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-indigo-400 font-bold",children:"[INFO]"})," Synchronizing 14 internal structural collections..."]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-indigo-400 font-bold",children:"[INFO]"})," Loaded active school credentials database. Current admins count: ",N.filter(t=>t.role==="administrator").length]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-amber-500 font-bold",children:"[WARN]"})," Port 9000 detected as default proxy ingress bypass bind."]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-indigo-600 font-bold",children:"[INFO]"})," Listening on network http://0.0.0.0:9000..."]})]})]})]}):b==="site_settings"?e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 animate-fade-in text-gray-800",children:[e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-3xs overflow-hidden max-w-3xl",children:[e.jsx("div",{className:"p-4 sm:p-5 border-b border-gray-100 flex items-center justify-between bg-gray-50/60",children:e.jsxs("div",{children:[e.jsxs("h3",{className:"font-bold text-gray-800 flex items-center gap-2 text-sm sm:text-base",children:[e.jsx(Z,{size:18,className:"text-indigo-600"}),s==="zh"?"平台站点信息(名称 / 口号 / Logo)":"Platform Site Info (Name / Slogan / Logo)"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:s==="zh"?"设置将应用于登录页与平台各处的品牌 Logo 展示位。":"Applied to the login page and brand logo slots across the platform."})]})}),e.jsxs("form",{onSubmit:Xe,className:"p-5 space-y-5 text-left",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider",children:s==="zh"?"站点名称 *":"Site Name *"}),e.jsx("input",{type:"text",value:ae,onChange:t=>L(t.target.value),placeholder:s==="zh"?"例如:阳光实验小学智慧课堂":"e.g. Sunshine Elementary Smart Class",className:"w-full text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all font-semibold"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider",children:s==="zh"?"站点口号 / 标语":"Site Slogan / Tagline"}),e.jsx("input",{type:"text",value:T,onChange:t=>l(t.target.value),placeholder:s==="zh"?"例如:下一代智能数字化学习系统":"e.g. Next-Generation Intelligent Learning",className:"w-full text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider",children:s==="zh"?"上传文件大小上限 (MB)":"Upload Size Limit (MB)"}),e.jsx("input",{type:"number",min:1,max:90,value:B,onChange:t=>ge(Number(t.target.value)),className:"w-40 text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all font-semibold"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:s==="zh"?"课件(PDF/PPTX)等文件上传的体积上限,范围 1–90 MB,保存后立即生效。":"Size cap for file uploads (PDF/PPTX), 1–90 MB. Takes effect immediately after saving."}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider",children:s==="zh"?"当前学年 (YYYY-YYYY)":"Current Academic Year (YYYY-YYYY)"}),e.jsx("input",{type:"text",value:ue,onChange:t=>fe(t.target.value),placeholder:s==="zh"?"例如:2025-2026":"e.g. 2025-2026",className:"w-48 text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all font-semibold"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:s==="zh"?"平台默认学年筛选与新数据归属会使用该值;格式必须连续,如 2025-2026。":"Default academic-year filtering and new records use this value; must be contiguous, e.g. 2025-2026."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider",children:s==="zh"?"学年起始月份":"Academic Year Start Month"}),e.jsx("input",{type:"number",min:1,max:12,value:ye,onChange:t=>je(Number(t.target.value)),className:"w-24 text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all font-semibold"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:s==="zh"?"用于根据日期自动推断学年,默认 9 月。":"Used to derive academic year from dates; defaults to September."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider",children:s==="zh"?"站点 Logo 图片":"Site Logo Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-20 h-20 rounded-xl border border-gray-200 bg-slate-50 flex items-center justify-center overflow-hidden shrink-0",children:w?e.jsx("img",{src:w,alt:"logo preview",className:"w-full h-full object-contain"}):e.jsx(Z,{size:24,className:"text-gray-300"})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"cursor-pointer inline-flex items-center gap-1.5 px-3 py-2 bg-indigo-600 hover:bg-indigo-700 text-white font-semibold rounded-lg shadow-sm transition-all text-xs",children:[e.jsx($e,{size:14}),s==="zh"?"上传图片":"Upload Image",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:t=>Je(t.target.files?.[0])})]}),e.jsx("button",{type:"button",onClick:()=>{z(""),u(null)},className:"px-3 py-2 text-xs font-semibold text-rose-600 border border-gray-200 rounded-lg hover:bg-rose-50 transition-all cursor-pointer",children:s==="zh"?"清除 Logo":"Clear Logo"})]})]}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"也可直接粘贴图片 URL:":"Or paste an image URL:"}),e.jsx("input",{type:"text",value:w,onChange:t=>z(t.target.value),placeholder:"https://example.com/logo.png",className:"w-full text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all font-mono"})]}),e.jsx("div",{className:"flex items-center justify-end gap-3 pt-2 border-t border-gray-100",children:e.jsxs("button",{type:"submit",disabled:re,className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 rounded-lg shadow-sm transition-all cursor-pointer flex items-center gap-1.5",children:[re?e.jsx(se,{size:13,className:"animate-spin"}):e.jsx(ee,{size:14}),e.jsx("span",{children:re?s==="zh"?"保存中...":"Saving...":s==="zh"?"保存站点信息":"Save Site Settings"})]})})]})]}),e.jsx(ys,{lang:s})]}):b.startsWith("plugin:")?e.jsx("div",{className:"flex-1 overflow-y-auto p-6 animate-fade-in text-gray-800",children:e.jsx(W,{slot:"admin.tab",slotProps:{renderType:"panel",adminActiveTab:b,currentUserId:n,currentUserRole:c,lang:s,siteInfo:m,aiProviders:k}})}):e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-3 border-b border-gray-100 bg-white 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 flex-1",children:[e.jsxs("div",{className:"relative w-full sm:w-72",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(bs,{size:14})}),e.jsx("input",{type:"text",placeholder:s==="zh"?"检索姓名、教工用户名...":"Search teachers by name or username...",value:V,onChange:t=>we(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-3xs"}),V&&e.jsx("button",{onClick:()=>we(""),className:"absolute inset-y-0 right-0 flex items-center pr-2.5 text-gray-400 hover:text-gray-600",children:e.jsx(Fe,{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-gray-400 uppercase tracking-wider",children:s==="zh"?"角色筛选:":"Role:"}),e.jsxs("select",{value:ie,onChange:t=>Ye(t.target.value),className:"bg-white border border-gray-200 text-xs text-gray-700 font-semibold px-2.5 py-1.5 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 shadow-3xs cursor-pointer",children:[e.jsx("option",{value:"all",children:s==="zh"?"全部角色":"All Roles"}),e.jsx("option",{value:"administrator",children:s==="zh"?"管理员 (admin)":"Administrators"}),e.jsx("option",{value:"teacher",children:s==="zh"?"教师 (teacher)":"Standard Teachers"})]})]}),e.jsx("span",{className:"text-xs text-gray-400",children:s==="zh"?`共 ${E.length} 位教工`:`${E.length} total staff`})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap shrink-0 self-end sm:self-auto",children:[e.jsxs("button",{onClick:Ze,className:"bg-indigo-600 hover:bg-indigo-700 text-white px-3.5 py-1.5 rounded-lg text-xs font-semibold flex items-center gap-1.5 shadow-sm hover:shadow transition-all cursor-pointer",children:[e.jsx($e,{size:14}),e.jsx("span",{children:s==="zh"?"添加教职账户":"Add Teacher Account"})]}),e.jsx(W,{slot:"admin.user.action",slotProps:{users:N,filteredUsers:E,lang:s,onRefresh:K}})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-2.5 bg-gray-50/40",children:Y?e.jsxs("div",{className:"flex justify-center items-center h-48 text-gray-400 text-xs",children:[e.jsx(y,{size:20,className:"animate-spin mr-1.5"}),s==="zh"?"加载教职工账户中...":"Reading accounts..."]}):E.length===0?e.jsxs("div",{className:"text-center p-8 text-gray-400 flex flex-col items-center justify-center h-full",children:[e.jsx(X,{size:36,className:"opacity-20 mb-2"}),e.jsx("p",{className:"text-xs font-semibold",children:s==="zh"?"未检索到任何符合条件的教师账户":"No staff matched your filters."})]}):E.map(t=>{const a=t.id===n,x=t.role==="administrator",o=t.status==="disabled";return e.jsxs("div",{className:`p-3.5 bg-white border border-gray-200/90 hover:border-indigo-200 rounded-xl shadow-3xs flex items-center justify-between group transition-all ${o?"opacity-75 bg-slate-50/50":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg flex items-center justify-center ${o?"bg-slate-100 text-slate-400":x?"bg-indigo-50 text-indigo-600":"bg-slate-100 text-slate-500"}`,children:x?e.jsx(J,{size:18}):e.jsx(X,{size:18})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs font-bold ${o?"text-gray-500 line-through":"text-gray-800"}`,children:t.name}),a&&e.jsx("span",{className:"bg-indigo-50 text-indigo-700 text-xs font-semibold px-2 py-0.5 rounded-full border border-indigo-100",children:s==="zh"?"你自己":"You"}),e.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${x?"bg-indigo-900 text-indigo-200":"bg-gray-100 text-gray-600"}`,children:t.role}),o&&e.jsx("span",{className:"bg-rose-50 text-rose-700 text-xs font-semibold px-2 py-0.5 rounded-full border border-rose-100",children:s==="zh"?"已禁用":"Disabled"})]}),e.jsxs("div",{className:"text-xs text-gray-400 font-mono mt-0.5 flex items-center gap-1.5",children:[e.jsxs("span",{children:["@",t.username]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[s==="zh"?"注册日期:":"ID: ",new Date(t.created_at).toLocaleDateString()]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>es(t),className:"px-2.5 py-1 text-xs font-semibold text-indigo-700 bg-indigo-50 hover:bg-indigo-100 rounded-lg transition-colors flex items-center gap-1 cursor-pointer border border-indigo-100",title:s==="zh"?"修改设置":"Update settings",children:[e.jsx(gs,{size:12}),e.jsx("span",{children:s==="zh"?"设置":"Edit"})]}),e.jsx("button",{onClick:()=>ts(t.id,t.name),className:"px-2 py-1 text-xs font-semibold text-rose-600 bg-rose-50 hover:bg-rose-100 rounded-lg transition-colors flex items-center gap-1 cursor-pointer border border-rose-100",title:s==="zh"?"注销删除":"Delete user",children:e.jsx(Ee,{size:12})})]})]},t.id)})})]}),Oe&&e.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-xs flex items-center justify-center z-50 p-4 animate-fade-in",children:e.jsxs("div",{className:"w-full max-w-md bg-white border border-gray-200 rounded-2xl shadow-xl overflow-hidden animate-zoom-in",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 bg-gray-50 flex items-center justify-between",children:[e.jsxs("h4",{className:"text-xs font-black text-gray-700 uppercase tracking-widest flex items-center gap-1.5 select-none",children:[e.jsx(X,{size:16,className:"text-indigo-600"}),A?s==="zh"?"正在编辑教职账户设置":"Edit Teacher Account Settings":s==="zh"?"新建教师与教工账户":"New Teacher Credentials"]}),e.jsx("button",{onClick:()=>R(!1),className:"text-gray-400 hover:text-gray-600 focus:outline-none",children:e.jsx(Fe,{size:18})})]}),e.jsxs("form",{onSubmit:ss,children:[e.jsxs("div",{className:"p-5 space-y-4",children:[ke&&e.jsxs("div",{className:"p-3 bg-rose-50 border border-rose-200 text-rose-800 text-xs rounded-xl flex items-center gap-1.5 animate-pulse",children:[e.jsx(te,{size:15,className:"shrink-0"}),e.jsx("span",{children:ke})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wide",children:s==="zh"?"教工姓名 (展示给学生及白板上) *":"Staff Real Name (Shown on roster/boards) *"}),e.jsx("input",{type:"text",value:ce,onChange:t=>xe(t.target.value),placeholder:s==="zh"?"例如:李茂峰老师、Mrs. Higgins":"e.g. Dr. Higgins, Teacher Chen",className:"w-full text-xs p-2.5 border border-gray-200 focus:outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-400 rounded-xl",required:!0})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-550 uppercase tracking-wide",children:s==="zh"?"登录用户名 (唯一标识) *":"Access Username (Unique Identifier) *"}),e.jsx("input",{type:"text",value:ne,onChange:t=>oe(t.target.value),placeholder:s==="zh"?"输入登录用的拼音或简写":"e.g. jclark12",className:"w-full text-xs p-2.5 border border-gray-200 focus:outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-400 rounded-xl",required:!0})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-555 uppercase tracking-wide",children:s==="zh"?"密码 *":"Password *"}),e.jsx("input",{type:"password",value:le,onChange:t=>de(t.target.value),placeholder:A?s==="zh"?"留空表示不修改密码":"Leave empty to keep existing":s==="zh"?"指定初次登录密码":"Set initial sign in password",className:"w-full text-xs p-2.5 border border-gray-200 focus:outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-400 rounded-xl",required:!A})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-550 uppercase tracking-wide",children:s==="zh"?"系统角色 (决定设置编辑权限) *":"Assign System Role (Determines access level) *"}),e.jsxs("div",{className:"flex gap-4 mt-2",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-700 cursor-pointer select-none",children:[e.jsx("input",{type:"radio",name:"form_role",checked:me==="teacher",onChange:()=>q("teacher"),className:"text-indigo-600 focus:ring-indigo-500 h-4 w-4"}),e.jsx("span",{children:s==="zh"?"教师 (不可进行设置)":"Teacher (settings locked)"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-700 cursor-pointer select-none",children:[e.jsx("input",{type:"radio",name:"form_role",checked:me==="administrator",onChange:()=>q("administrator"),className:"text-indigo-600 focus:ring-indigo-500 h-4 w-4"}),e.jsx("span",{children:s==="zh"?"管理员 (可调整设置)":"administrator (Full access)"})]})]})]}),e.jsxs("div",{className:"space-y-1 pt-2",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-550 uppercase tracking-wide",children:s==="zh"?"账户状态 (是否允许登录系统) *":"Account Status (Active State) *"}),e.jsxs("div",{className:"flex gap-4 mt-2",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-700 cursor-pointer select-none",children:[e.jsx("input",{type:"radio",name:"form_status",checked:he==="active",onChange:()=>Q("active"),className:"text-indigo-600 focus:ring-indigo-500 h-4 w-4"}),e.jsx("span",{children:s==="zh"?"启用 (Active)":"Active"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-700 cursor-pointer select-none",children:[e.jsx("input",{type:"radio",name:"form_status",checked:he==="disabled",onChange:()=>Q("disabled"),className:"text-indigo-600 focus:ring-indigo-500 h-4 w-4"}),e.jsx("span",{className:"text-rose-600 font-medium",children:s==="zh"?"禁用 (Disabled)":"Disabled"})]})]})]})]}),e.jsxs("div",{className:"p-4 border-t border-gray-100 bg-gray-50 flex items-center justify-end gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>R(!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:s==="zh"?"取消":"Cancel"}),e.jsxs("button",{type:"submit",disabled:pe,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:[pe?e.jsx(y,{size:13,className:"animate-spin"}):e.jsx(ee,{size:14}),e.jsx("span",{children:pe?s==="zh"?"保存中...":"Saving...":s==="zh"?"保存记录":"Save Properties"})]})]})]})]})})]})}function Ds(){const{session:n,lang:c,onLogout:s,aiProviders:P,testingProviderId:k,onAIProvidersChanged:j,onTriggerTour:S,siteInfo:m,onSiteInfoChanged:D}=rs();return n?.subRole!=="administrator"?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-rose-500",children:[e.jsx(us,{size:48,className:"mb-4"}),e.jsx("h2",{className:"text-xl font-bold",children:"Access Denied / 拒绝访问"}),e.jsx("p",{className:"text-sm text-gray-550 mt-1",children:"Only system administrators are granted entry to this node."})]}):e.jsx(js,{currentUserId:n.userId||"",currentUserRole:n.subRole,lang:c,onLogout:s,aiProviders:P,testingProviderId:k,onAIProvidersChanged:j,onTriggerTour:S,siteInfo:m,onSiteInfoChanged:D})}export{Ds as AdminDirectoryView};
@@ -1 +1 @@
1
- import{r as n,j as e}from"./vendor-react-DHoBZpn2.js";import{a as k,ad as U,E as ae,c as re,ae as K}from"./index-XduPa2-x.js";import{aA as X,R as Y,c as T,h as ie,V as oe,J as de,ah as ce,aZ as xe,an as G,at as ne,cj as me,bR as ue,af as ee,Z as be,U as pe,E as he,aq as H,N as ge,T as fe,k as ye}from"./vendor-icons-DLOPlM4i.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-DVWGghIL.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-skggaP9D.js";const se="w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500";function je(l){return l==null?"(未作答)":Array.isArray(l)?l.map(i=>String(i)).join(" | "):typeof l=="object"?JSON.stringify(l):String(l)}function ve({assignment:l,lang:i,onBack:c}){const t=i==="zh",[h,f]=n.useState(null),[b,y]=n.useState(null),[x,o]=n.useState(null),[v,u]=n.useState({}),[w,C]=n.useState({}),[A,g]=n.useState(!1),[j,S]=n.useState(null),[$,a]=n.useState(null),[N,P]=n.useState(null),[I,E]=n.useState({}),[L,m]=n.useState(null),[p,M]=n.useState(new Set),F=n.useCallback(async()=>{g(!0),a(null);try{const s=await k.listAttempts(l.id);f(s.items)}catch(s){a(s instanceof U?s.message:String(s?.message??s))}finally{g(!1)}},[l.id]);n.useEffect(()=>{F()},[F]);const _=async s=>{y(s),o(null),a(null),E({}),M(new Set);try{const r=await k.getTeacherView(s);o(r),u(Object.fromEntries(r.items.map(d=>[d.itemId,d.score===null?"":String(d.score)]))),C(Object.fromEntries(r.items.map(d=>[d.itemId,d.feedback??""])))}catch(r){a(r?.message??String(r))}},Q=async s=>{if(x){m(s.itemId),a(null);try{const r=await k.aiSuggestGrade(x.attempt.id,s.itemId);E(d=>({...d,[s.itemId]:r})),M(d=>{const B=new Set(d);return B.delete(s.itemId),B})}catch(r){a(t?"AI 建议不可用:"+(r?.message??String(r)):"AI suggestion unavailable: "+(r?.message??String(r)))}finally{m(null)}}},J=s=>{const r=I[s.itemId];r&&(u(d=>({...d,[s.itemId]:String(r.suggestedScore)})),M(d=>new Set(d).add(s.itemId)))},Z=async s=>{if(!x)return;const r=v[s.itemId];if(r===""||r===void 0){a(t?"请填写分数":"Score is required");return}S(s.itemId),a(null);try{await k.gradeAnswer(x.attempt.id,s.itemId,{score:Number(r),feedback:w[s.itemId]||null,acceptedAiSuggestion:p.has(s.itemId),suggestedScore:I[s.itemId]?.suggestedScore});const d=await k.getTeacherView(x.attempt.id);o(d),P(t?"已保存该题评分(自动判分不再覆盖)":"Score saved — auto-grading will not override it."),await F()}catch(d){a(d?.message??String(d))}finally{S(null)}};return e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[e.jsx("button",{type:"button",onClick:c,className:"p-1.5 rounded-lg border border-theme bg-surface text-muted hover:text-main cursor-pointer","aria-label":t?"返回试卷":"Back to assessment",children:e.jsx(X,{size:15})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("h1",{className:"text-sm font-bold text-main truncate",children:[t?"人工批改":"Manual grading"," · ",l.className??l.classId]}),e.jsx("p",{className:"text-2xs text-muted",children:t?"简答题与「无法自动判分」的题在这里给分;保存后该题不再被自动判分覆盖。":"Grade short answers and any item the grader could not score. Saved scores are never auto-overwritten."})]}),e.jsxs("button",{type:"button",onClick:()=>void F(),disabled:A,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface text-xs font-semibold text-main disabled:opacity-50 cursor-pointer",children:[e.jsx(Y,{size:13,className:A?"animate-spin":""}),t?"刷新":"Refresh"]})]}),($||N)&&e.jsx("div",{role:$?"alert":"status",className:`mx-5 mt-3 px-3 py-2 rounded-xl border text-xs ${$?"border-rose-200 bg-rose-50 text-rose-700":"border-emerald-200 bg-emerald-50 text-emerald-700"}`,children:$??N}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-5 grid grid-cols-1 lg:grid-cols-[280px_1fr] gap-4",children:[e.jsxs("section",{"aria-labelledby":"attempts-heading",children:[e.jsxs("h2",{id:"attempts-heading",className:"text-xs font-bold text-main mb-2",children:[t?"作答列表":"Attempts","(",h?.length??0,")"]}),h===null&&A?e.jsxs("p",{className:"text-xs text-muted flex items-center gap-2",children:[e.jsx(T,{size:13,className:"animate-spin"}),t?"加载中…":"Loading…"]}):(h?.length??0)===0?e.jsx("p",{className:"text-xs text-muted",children:t?"还没有人交卷。":"No submissions yet."}):e.jsx("ul",{"data-testid":"grading-attempt-list",className:"space-y-1.5",children:h.map(s=>{const r=b===s.id,d=Number(s.proctor?.summary?.total??0);return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void _(s.id),"aria-pressed":r,className:`w-full text-left px-3 py-2 rounded-xl border text-xs cursor-pointer ${r?"border-indigo-400 bg-indigo-50 dark:bg-indigo-950/40":"border-theme hover:bg-surface-secondary"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("span",{className:"font-semibold text-main block truncate",children:s.anonymousLabel??s.studentId??s.id}),d>0&&e.jsxs("span",{className:"px-1.5 py-0.2 rounded text-3xs font-bold bg-rose-100 text-rose-700 dark:bg-rose-950/50 dark:text-rose-300 shrink-0",title:t?`监考异常事件 ${d} 次`:`${d} proctor violations`,children:["⚠️ ",d]})]}),e.jsxs("span",{className:"text-2xs text-muted",children:[s.status," · ",s.score??"—","/",s.maxScore??"—",s.needsManualReview&&e.jsx("span",{className:"ml-1 text-amber-700 dark:text-amber-300",children:t?"待批改":"pending"})]})]})},s.id)})})]}),e.jsxs("section",{"aria-labelledby":"grade-heading",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h2",{id:"grade-heading",className:"text-xs font-bold text-main",children:t?"逐题批改":"Grade items"}),x&&Number(x.attempt.proctor?.summary?.total??0)>0&&e.jsxs("div",{className:"px-2 py-0.5 rounded-lg border border-rose-200 bg-rose-50 text-rose-700 dark:bg-rose-950/40 dark:text-rose-300 dark:border-rose-800 text-2xs font-semibold",children:["⚠️ ",t?"监考异常":"Proctor alert",":",t?"切屏":"tab switch"," ",x.attempt.proctor?.summary?.visibility_hidden??0," · ",t?"失焦":"blur"," ",x.attempt.proctor?.summary?.blur??0," · ",t?"退出全屏":"exit fullscreen"," ",x.attempt.proctor?.summary?.fullscreen_exit??0]})]}),x?e.jsx("ul",{className:"space-y-3",children:x.items.map((s,r)=>e.jsxs("li",{"data-testid":`grading-item-${s.itemId}`,className:"border border-theme rounded-xl p-3 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-2xs font-bold text-muted",children:["#",r+1]}),e.jsx("span",{className:"text-xs font-semibold text-main flex-1 min-w-0 line-clamp-2",children:s.stem}),e.jsxs("span",{className:"text-2xs text-muted",children:[s.score??"—","/",s.maxScore]}),s.manualOverride&&e.jsxs("span",{className:"text-2xs text-indigo-600 inline-flex items-center gap-0.5",children:[e.jsx(ie,{size:11}),t?"已人工批改":"manual"]})]}),e.jsx("p",{className:"text-xs text-main bg-surface-secondary rounded-lg px-2 py-1.5 whitespace-pre-wrap break-words",children:je(s.answer)}),s.needsManualReview&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void Q(s),disabled:L===s.itemId,className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary disabled:opacity-50 cursor-pointer",children:[L===s.itemId?e.jsx(T,{size:11,className:"animate-spin"}):e.jsx(oe,{size:11}),t?"AI 建议":"AI suggestion"]}),I[s.itemId]&&e.jsxs("div",{className:"text-2xs text-muted bg-indigo-50 dark:bg-indigo-950/30 border border-indigo-200 dark:border-indigo-900 rounded-lg px-2 py-1.5 space-y-1",children:[e.jsxs("p",{className:"text-main",children:[t?"建议分":"Suggested"," ",I[s.itemId].suggestedScore,"/",s.maxScore,I[s.itemId].confidence!==null&&" · "+(t?"置信度":"confidence")+" "+Math.round(I[s.itemId].confidence*100)+"%",p.has(s.itemId)&&" · "+(t?"已填入,待保存":"applied, pending save")]}),e.jsx("p",{className:"whitespace-pre-wrap break-words",children:I[s.itemId].rationale}),e.jsx("button",{type:"button",onClick:()=>J(s),className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-indigo-600 text-white text-2xs font-bold hover:bg-indigo-700 cursor-pointer",children:t?"采纳并填入分数":"Apply to score"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[100px_1fr_auto] gap-2 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:`score-${s.itemId}`,className:"block text-2xs font-semibold text-muted mb-1",children:t?"得分":"Score"}),e.jsx("input",{id:`score-${s.itemId}`,type:"number",min:0,max:s.maxScore,step:.5,value:v[s.itemId]??"",onChange:d=>u(B=>({...B,[s.itemId]:d.target.value})),className:se})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:`feedback-${s.itemId}`,className:"block text-2xs font-semibold text-muted mb-1",children:t?"评语(可选)":"Feedback (optional)"}),e.jsx("input",{id:`feedback-${s.itemId}`,type:"text",value:w[s.itemId]??"",onChange:d=>C(B=>({...B,[s.itemId]:d.target.value})),className:se})]}),e.jsxs("button",{type:"button",onClick:()=>void Z(s),disabled:j===s.itemId,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 disabled:opacity-50 cursor-pointer",children:[j===s.itemId&&e.jsx(T,{size:13,className:"animate-spin"}),t?"保存评分":"Save"]})]})]},s.itemId))}):e.jsx("p",{className:"text-xs text-muted",children:t?"从左侧选择一份作答。":"Pick an attempt on the left."})]})]})]})}function Ne(l){return{id:l.id,kind:l.kind,title:l.title,description:l.description,status:l.status,itemCount:l.itemCount,totalScore:l.totalScore,settings:l.settings,createdAt:l.createdAt,updatedAt:l.updatedAt}}function ke(l){return{attemptCount:l.attemptCount,submittedCount:l.submittedCount,gradedCount:l.gradedCount,needsManualReviewCount:l.needsManualReviewCount,averageScore:l.averageScore,averagePercent:l.averagePercent,maxScore:l.maxScore,items:l.items.map(i=>({itemId:i.itemId,type:i.type,stem:i.stem,maxScore:i.maxScore,answered:i.answered,graded:i.graded,correct:i.correct,correctRate:i.correctRate,avgScore:i.avgScore,distribution:i.distribution}))}}function Se({assignment:l,lang:i,onBack:c}){const t=i==="zh",[h,f]=n.useState(null),[b,y]=n.useState(!1),[x,o]=n.useState(null),v=n.useCallback(async()=>{y(!0),o(null);try{f(await k.stats(l.id))}catch(u){o(u instanceof U?u.message:String(u?.message??u))}finally{y(!1)}},[l.id]);return n.useEffect(()=>{v()},[v]),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[e.jsx("button",{type:"button",onClick:c,className:"p-1.5 rounded-lg border border-theme bg-surface text-muted hover:text-main cursor-pointer","aria-label":t?"返回试卷":"Back to assessment",children:e.jsx(X,{size:15})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("h1",{className:"text-sm font-bold text-main truncate",children:[t?"统计":"Statistics"," · ",l.className??l.classId]})}),e.jsxs("a",{href:k.exportCsvUrl(l.id),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface text-xs font-semibold text-main hover:bg-surface-secondary",children:[e.jsx(de,{size:13}),t?"导出 CSV":"Export CSV"]}),e.jsxs("button",{type:"button",onClick:()=>void v(),disabled:b,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface text-xs font-semibold text-main disabled:opacity-50 cursor-pointer",children:[e.jsx(Y,{size:13,className:b?"animate-spin":""}),t?"刷新":"Refresh"]})]}),x&&e.jsx("p",{role:"alert",className:"mx-5 mt-3 px-3 py-2 rounded-xl border border-rose-200 bg-rose-50 text-rose-700 text-xs",children:x}),e.jsx("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[[{label:t?"作答数":"Attempts",value:h.attemptCount},{label:t?"已交卷":"Submitted",value:h.submittedCount},{label:t?"待人工批改":"Pending review",value:h.needsManualReviewCount},{label:t?"平均分":"Average",value:h.averageScore===null?"—":`${h.averageScore}${h.averagePercent!==null?` (${h.averagePercent}%)`:""}`}].map(u=>e.jsxs("div",{className:"border border-theme rounded-xl px-3 py-2 bg-surface-secondary/40",children:[e.jsx("p",{className:"text-2xs text-muted",children:u.label}),e.jsx("p",{className:"text-sm font-bold text-main",children:u.value})]},u.label)),e.jsx(ae,{slot:"assessment.stats.card",slotProps:{assignmentId:l.id,stats:ke(h),lang:i},lang:i})]}),e.jsxs("table",{"data-testid":"stats-table",className:"w-full text-xs border border-theme rounded-xl overflow-hidden",children:[e.jsx("caption",{className:"sr-only",children:t?"逐题统计":"Per-item statistics"}),e.jsx("thead",{className:"bg-surface-secondary text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"text-left px-3 py-2 font-semibold",children:"#"}),e.jsx("th",{scope:"col",className:"text-left px-3 py-2 font-semibold",children:t?"题干":"Stem"}),e.jsx("th",{scope:"col",className:"text-right px-3 py-2 font-semibold",children:t?"作答":"Answered"}),e.jsx("th",{scope:"col",className:"text-right px-3 py-2 font-semibold",children:t?"正确率":"Correct rate"}),e.jsx("th",{scope:"col",className:"text-right px-3 py-2 font-semibold",children:t?"均分":"Avg score"})]})}),e.jsx("tbody",{children:h.items.map((u,w)=>e.jsxs("tr",{className:"border-t border-theme",children:[e.jsx("td",{className:"px-3 py-2 text-muted",children:w+1}),e.jsx("td",{className:"px-3 py-2 text-main max-w-[320px] truncate",title:u.stem,children:u.stem}),e.jsx("td",{className:"px-3 py-2 text-right text-main",children:u.answered}),e.jsx("td",{className:"px-3 py-2 text-right text-main",children:u.correctRate===null?"—":`${u.correctRate}%`}),e.jsx("td",{className:"px-3 py-2 text-right text-main",children:u.avgScore===null?"—":`${u.avgScore}/${u.maxScore}`})]},u.itemId))})]}),e.jsx("p",{className:"text-2xs text-muted",children:t?"待人工批改的题不计入正确率与均分;匿名问卷的导出不含身份信息。":"Items awaiting manual review are excluded from correct-rate and averages. Anonymous exports contain no identity."})]}):e.jsxs("p",{className:"text-xs text-muted flex items-center gap-2",children:[e.jsx(T,{size:13,className:"animate-spin"}),t?"正在统计…":"Computing…"]})})]})}const q="w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500";function we({assessmentId:l,lang:i,onBack:c}){const t=i==="zh",f=re()?.classes??[],[b,y]=n.useState(null),[x,o]=n.useState([]),[v,u]=n.useState([]),[w,C]=n.useState(!0),[A,g]=n.useState(null),[j,S]=n.useState(null),[$,a]=n.useState(null),[N,P]=n.useState(null),[I,E]=n.useState(null),[L,m]=n.useState(null),p=b?.status==="draft",M=n.useMemo(()=>(K.subscribe(()=>{}),K.list().filter(s=>s.supports.includes(b?.kind??"quiz"))),[b?.kind]),F=n.useCallback(async()=>{C(!0),S(null);try{const s=await k.get(l);y(s),o(s.items.map(d=>({id:d.id,type:d.type,stem:d.stem,config:d.config??{},answerKey:d.answerKey??null,maxScore:d.maxScore})));const r=await k.getAssignments(l).catch(()=>({items:[]}));u(r.items)}catch(s){S(s instanceof U?s.message:String(s?.message??s))}finally{C(!1)}},[l]);n.useEffect(()=>{F()},[F]);const _=async s=>{g("settings"),S(null);try{const r=await k.update(l,{settings:s});y(r),a(t?"设置已保存":"Settings saved")}catch(r){S(r?.message??String(r))}finally{g(null)}},Q=async()=>{g("items"),S(null);try{const s=await k.replaceItems(l,x.map((r,d)=>({id:r.id,type:r.type,stem:r.stem,config:r.config,answerKey:r.answerKey,maxScore:r.maxScore,sortOrder:d})));y(s),o(s.items.map(r=>({id:r.id,type:r.type,stem:r.stem,config:r.config??{},answerKey:r.answerKey??null,maxScore:r.maxScore}))),a(t?"题目已保存":"Items saved")}catch(s){S(s?.message??String(s))}finally{g(null)}},J=s=>{const r=K.get(s);o(d=>[...d,{id:`new-${Date.now()}-${d.length}`,type:s,stem:"",config:r?.createDefaultConfig?.()??{},answerKey:r?.createDefaultAnswerKey?.()??null,maxScore:5}])},Z=async()=>{try{const s=await k.listBank();m(s.items)}catch(s){S(s?.message??String(s))}};return w?e.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 py-16 text-sm text-muted",children:[e.jsx(T,{size:16,className:"animate-spin"}),t?"正在加载试卷…":"Loading assessment…"]}):b?N?e.jsx(ve,{assignment:N,lang:i,onBack:()=>{P(null),F()}}):I?e.jsx(Se,{assignment:I,lang:i,onBack:()=>E(null)}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[e.jsx("button",{type:"button",onClick:c,className:"p-1.5 rounded-lg border border-theme bg-surface hover:bg-surface-secondary text-muted hover:text-main cursor-pointer","aria-label":t?"返回测评列表":"Back to assessment list",children:e.jsx(X,{size:15})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h1",{className:"text-sm font-bold text-main truncate",children:b.title}),e.jsxs("p",{className:"text-2xs text-muted",children:[t?"类型":"Kind",":",b.kind," · ",t?"状态":"Status",":",b.status," · ",x.length," ",t?"题":"items"," · ",t?"满分":"total"," ",x.reduce((s,r)=>s+r.maxScore,0)]})]}),p&&e.jsxs("button",{type:"button",onClick:()=>void Q(),disabled:A!==null,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 disabled:opacity-50 cursor-pointer",children:[A==="items"?e.jsx(T,{size:13,className:"animate-spin"}):e.jsx(ce,{size:13}),t?"保存题目":"Save items"]})]}),(j||$)&&e.jsx("div",{role:j?"alert":"status",className:`mx-5 mt-3 px-3 py-2 rounded-xl border text-xs ${j?"border-rose-200 bg-rose-50 text-rose-700":"border-emerald-200 bg-emerald-50 text-emerald-700"}`,children:j??$}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-5",children:[e.jsxs("section",{"aria-labelledby":"settings-heading",className:"border border-theme rounded-xl p-4",children:[e.jsxs("h2",{id:"settings-heading",className:"text-xs font-bold text-main flex items-center gap-1.5 mb-3",children:[e.jsx(xe,{size:13}),t?"测评设置":"Settings",!p&&e.jsxs("span",{className:"text-2xs font-normal text-muted",children:["(",t?"已发布,只读":"published, read-only",")"]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"set-attempts",className:"block text-2xs font-semibold text-muted mb-1",children:t?"允许作答次数":"Max attempts"}),e.jsx("input",{id:"set-attempts",type:"number",min:1,max:10,value:b.settings.maxAttempts,disabled:!p||b.kind!=="quiz",onChange:s=>void _({maxAttempts:Number(s.target.value)||1}),className:q})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"set-policy",className:"block text-2xs font-semibold text-muted mb-1",children:t?"多次作答取哪次":"Score policy"}),e.jsxs("select",{id:"set-policy",value:b.settings.scorePolicy,disabled:!p||b.kind!=="quiz",onChange:s=>void _({scorePolicy:s.target.value}),className:q,children:[e.jsx("option",{value:"last",children:t?"最后一次":"Last"}),e.jsx("option",{value:"first",children:t?"第一次":"First"}),e.jsx("option",{value:"highest",children:t?"最高分":"Highest"}),e.jsx("option",{value:"average",children:t?"平均分":"Average"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"set-visibility",className:"block text-2xs font-semibold text-muted mb-1",children:t?"结果可见性":"Result visibility"}),e.jsxs("select",{id:"set-visibility",value:b.settings.resultVisibility,disabled:!p||b.kind==="survey",onChange:s=>void _({resultVisibility:s.target.value}),className:q,children:[e.jsx("option",{value:"immediate",children:t?"交卷即显示":"Immediately"}),e.jsx("option",{value:"after_release",children:t?"教师发布成绩后":"After release"}),e.jsx("option",{value:"score_only",children:t?"只显示分数":"Score only"})]})]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-4",children:[{key:"singleAttempt",zh:"严格单次作答(禁止重考)",en:"Single attempt only",disabled:!p},{key:"shuffleItems",zh:"题目乱序",en:"Shuffle items",disabled:!p},{key:"shuffleOptions",zh:"选项乱序",en:"Shuffle options",disabled:!p},{key:"strictProctor",zh:"严格监考(切屏/失焦/防复制)",en:"Strict proctoring",disabled:!p},{key:"partialCredit",zh:"多选少选给部分分",en:"Partial credit for multi-choice",disabled:!p},{key:"caseSensitive",zh:"填空题区分大小写",en:"Case-sensitive blanks",disabled:!p},{key:"showItemAnalysis",zh:"允许查看逐题解析",en:"Show item analysis",disabled:!p||b.kind==="survey"},{key:"anonymous",zh:"匿名问卷",en:"Anonymous survey",disabled:!p||b.kind!=="survey"}].map(s=>e.jsxs("label",{className:"inline-flex items-center gap-1.5 text-xs text-main",children:[e.jsx("input",{type:"checkbox",checked:!!b.settings[s.key],disabled:s.disabled||!p,onChange:r=>void _({[s.key]:r.target.checked}),className:"accent-indigo-600"}),s[t?"zh":"en"]]},s.key))})]}),e.jsxs("section",{"aria-labelledby":"items-heading",className:"border border-theme rounded-xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("h2",{id:"items-heading",className:"text-xs font-bold text-main",children:[t?"题目列表":"Items","(",x.length,")"]}),p&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[M.map(s=>e.jsxs("button",{type:"button",onClick:()=>J(s.type),className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:[e.jsx(G,{size:11}),s.label[t?"zh":"en"]]},s.type)),e.jsxs("button",{type:"button",onClick:()=>void Z(),className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:[e.jsx(ne,{size:11}),t?"从题库添加":"From bank"]})]})]}),x.length===0?e.jsx("p",{className:"text-xs text-muted py-6 text-center",children:t?"还没有题目。用上方按钮添加第一道题。":"No items yet — add your first question above."}):e.jsx("ol",{className:"space-y-3",children:x.map((s,r)=>{const d=K.get(s.type),B=d?.Editor;return e.jsxs("li",{"data-testid":`item-row-${r}`,className:"border border-theme rounded-xl p-3 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-2xs font-bold text-muted",children:["#",r+1]}),e.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-secondary border border-theme text-2xs font-semibold text-main",children:d?.label[t?"zh":"en"]??s.type}),e.jsx("label",{htmlFor:`item-score-${s.id}`,className:"ml-auto text-2xs text-muted",children:t?"分值":"Score"}),e.jsx("input",{id:`item-score-${s.id}`,type:"number",min:1,value:s.maxScore,disabled:!p,onChange:D=>o(z=>z.map((R,O)=>O===r?{...R,maxScore:Number(D.target.value)||1}:R)),className:"w-16 px-2 py-1 border border-theme rounded-lg text-xs bg-surface text-main"}),p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:r===0,onClick:()=>o(D=>{const z=[...D];return[z[r-1],z[r]]=[z[r],z[r-1]],z}),"aria-label":t?`上移第 ${r+1} 题`:`Move item ${r+1} up`,className:"p-1 rounded-md text-muted hover:text-main hover:bg-surface-secondary disabled:opacity-30 cursor-pointer",children:e.jsx(me,{size:12})}),e.jsx("button",{type:"button",disabled:r===x.length-1,onClick:()=>o(D=>{const z=[...D];return[z[r+1],z[r]]=[z[r],z[r+1]],z}),"aria-label":t?`下移第 ${r+1} 题`:`Move item ${r+1} down`,className:"p-1 rounded-md text-muted hover:text-main hover:bg-surface-secondary disabled:opacity-30 cursor-pointer",children:e.jsx(ue,{size:12})}),e.jsx("button",{type:"button",onClick:()=>o(D=>D.filter((z,R)=>R!==r)),"aria-label":t?`删除第 ${r+1} 题`:`Delete item ${r+1}`,className:"p-1 rounded-md text-muted hover:text-rose-500 hover:bg-rose-500/10 cursor-pointer",children:e.jsx(ee,{size:12})})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:`item-stem-${s.id}`,className:"block text-2xs font-semibold text-muted mb-1",children:t?"题干":"Stem"}),e.jsx("textarea",{id:`item-stem-${s.id}`,rows:2,value:s.stem,disabled:!p,onChange:D=>o(z=>z.map((R,O)=>O===r?{...R,stem:D.target.value}:R)),className:`${q} resize-none`})]}),B?e.jsx(B,{config:s.config,answerKey:s.answerKey,lang:i,disabled:!p,onChange:({config:D,answerKey:z})=>o(R=>R.map((O,le)=>le===r?{...O,config:D,answerKey:z}:O))}):e.jsx("p",{className:"text-2xs text-amber-700 dark:text-amber-300",children:t?`题型「${s.type}」没有注册出题编辑器(可能来自未启用/已卸载的插件)。`:`No editor registered for "${s.type}" (plugin missing or disabled).`})]},s.id)})})]}),e.jsx(Ce,{lang:i,detail:b,classes:f,assignments:v,disabled:!p,onPublished:async()=>{await F()},onGrading:P,onStats:E,onError:S})]}),L&&e.jsx(ze,{lang:i,items:L,allowedTypes:M.map(s=>s.type),onClose:()=>m(null),onPick:s=>{o(r=>[...r,{id:`new-${Date.now()}-${r.length}`,type:s.type,stem:s.stem,config:s.config??{},answerKey:s.answerKey??null,maxScore:5}]),m(null)}})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 py-16",children:[e.jsx("p",{role:"alert",className:"text-sm text-rose-600",children:j??(t?"加载失败":"Failed to load")}),e.jsx("button",{type:"button",onClick:c,className:"text-xs font-semibold text-indigo-600 underline cursor-pointer",children:t?"返回列表":"Back to list"})]})}function Ce({lang:l,detail:i,classes:c,assignments:t,disabled:h,onPublished:f,onGrading:b,onStats:y,onError:x}){const o=l==="zh",[v,u]=n.useState(""),[w,C]=n.useState(""),[A,g]=n.useState(""),[j,S]=n.useState(!1),$=async()=>{if(!v){x(o?"请选择班级":"Pick a class first");return}S(!0);try{await k.publish(i.id,{classId:v,durationSec:w?Number(w)*60:null,closesAt:A?new Date(A).getTime():null}),await f()}catch(a){x(a?.message??String(a))}finally{S(!1)}};return e.jsxs("section",{"aria-labelledby":"publish-heading",className:"border border-theme rounded-xl p-4 space-y-3",children:[e.jsxs("h2",{id:"publish-heading",className:"text-xs font-bold text-main flex items-center gap-1.5",children:[e.jsx(be,{size:13}),o?"发布到班级":"Publish to a class"]}),h?e.jsx("p",{className:"text-2xs text-muted",children:o?"试卷已发布,内容只读。需要改题请新建一份试卷。":"Published papers are read-only. Create a new one to change items."}):e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1.2fr_1fr_1fr_auto] gap-2 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"pub-class",className:"block text-2xs font-semibold text-muted mb-1",children:o?"班级":"Class"}),e.jsxs("select",{id:"pub-class",value:v,onChange:a=>u(a.target.value),className:q,children:[e.jsx("option",{value:"",children:o?"请选择班级":"Select a class"}),c.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"pub-duration",className:"block text-2xs font-semibold text-muted mb-1",children:o?"限时(分钟,可选)":"Time limit (min)"}),e.jsx("input",{id:"pub-duration",type:"number",min:1,value:w,onChange:a=>C(a.target.value),className:q})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"pub-closes",className:"block text-2xs font-semibold text-muted mb-1",children:o?"截止时间(可选)":"Closes at"}),e.jsx("input",{id:"pub-closes",type:"datetime-local",value:A,onChange:a=>g(a.target.value),className:q})]}),e.jsxs("button",{type:"button",onClick:()=>void $(),disabled:j,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-emerald-600 text-white text-xs font-bold hover:bg-emerald-700 disabled:opacity-50 cursor-pointer",children:[j&&e.jsx(T,{size:13,className:"animate-spin"}),o?"发布":"Publish"]})]}),t.length>0&&e.jsx("ul",{"data-testid":"assignment-list",className:"space-y-2 pt-1",children:t.map(a=>e.jsxs("li",{"data-testid":`assignment-row-${a.id}`,className:"flex flex-wrap items-center gap-2 border border-theme rounded-xl px-3 py-2",children:[e.jsx(pe,{size:13,className:"text-muted"}),e.jsx("span",{className:"text-xs font-semibold text-main",children:a.className??a.classId}),e.jsx("span",{className:`px-2 py-0.5 rounded-full text-2xs font-semibold border ${a.status==="open"?"bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950/40 dark:text-emerald-300 dark:border-emerald-800":"bg-surface-secondary text-muted border-theme"}`,children:a.status==="open"?o?"进行中":"Open":o?"已关闭":"Closed"}),e.jsxs("span",{className:"text-2xs text-muted",children:[o?"已交卷":"Submitted"," ",a.submittedCount,"/",a.attemptCount," ·"," ",o?"待批改":"Pending"," ",a.pendingReviewCount]}),a.scoreReleased&&e.jsx("span",{className:"text-2xs text-indigo-600",children:o?"成绩已发布":"Scores released"}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[e.jsxs("a",{href:k.exportCsvUrl(a.id),className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary",children:[e.jsx(he,{size:11}),"CSV"]}),e.jsx("button",{type:"button",onClick:()=>y(a),className:"px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:o?"统计":"Stats"}),e.jsx("button",{type:"button",onClick:()=>b(a),className:"px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:o?"批改":"Grade"}),a.scoreReleased?e.jsx("button",{type:"button",onClick:async()=>{try{await k.syncGradebook(a.id),await f()}catch(N){x(N?.message??String(N))}},title:o?"将本场成绩同步至系统成绩单":"Sync scores to gradebook",className:"px-2 py-1 rounded-lg border border-indigo-200 text-indigo-700 bg-indigo-50/50 hover:bg-indigo-100 dark:border-indigo-800 dark:text-indigo-300 dark:bg-indigo-950/40 text-2xs font-semibold cursor-pointer",children:o?"同步成绩单":"Sync Grades"}):e.jsx("button",{type:"button",onClick:async()=>{try{await k.releaseScores(a.id),await f()}catch(N){x(N?.message??String(N))}},title:o?"发布成绩并自动同步至成绩单":"Release scores and sync to gradebook",className:"px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:o?"发布成绩":"Release"}),a.status==="open"&&e.jsx("button",{type:"button",onClick:async()=>{try{await k.closeAssignment(a.id),await f()}catch(N){x(N?.message??String(N))}},className:"px-2 py-1 rounded-lg border border-amber-300 text-2xs font-semibold text-amber-700 hover:bg-amber-50 cursor-pointer",children:o?"关闭":"Close"})]})]},a.id))})]})}function ze({lang:l,items:i,allowedTypes:c,onClose:t,onPick:h}){const f=l==="zh",b=i.filter(y=>c.includes(y.type));return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"bank-picker-title",className:"w-full max-w-lg max-h-[80vh] flex flex-col bg-surface border border-theme rounded-2xl shadow-2xl",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-theme flex items-center justify-between",children:[e.jsx("h2",{id:"bank-picker-title",className:"text-sm font-bold text-main",children:f?"从题库添加":"Add from question bank"}),e.jsx("button",{type:"button",onClick:t,className:"text-xs font-semibold text-muted hover:text-main cursor-pointer",children:f?"关闭":"Close"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-2",children:b.length===0?e.jsx("p",{className:"text-xs text-muted py-6 text-center",children:f?"题库里还没有可用于本测评类型的题目。":"No bank items usable for this assessment kind."}):b.map(y=>e.jsxs("button",{type:"button",onClick:()=>h(y),className:"w-full text-left border border-theme rounded-xl px-3 py-2 hover:border-indigo-300 hover:bg-surface-secondary cursor-pointer",children:[e.jsx("p",{className:"text-xs font-semibold text-main line-clamp-2",children:y.stem}),e.jsx("p",{className:"text-2xs text-muted mt-0.5",children:y.type})]},y.id))})]})})}const W="w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500";function Ae({lang:l}){const i=l==="zh",[c,t]=n.useState(null),[h,f]=n.useState(null),[b,y]=n.useState(!1),[x,o]=n.useState("single_choice"),[v,u]=n.useState(""),[w,C]=n.useState({}),[A,g]=n.useState(null),[j,S]=n.useState("private"),[$,a]=n.useState(!1),N=K.list(),I=K.get(x)?.Editor,E=n.useCallback(async()=>{y(!0),f(null);try{const m=await k.listBank();t(m.items)}catch(m){f(m instanceof U?m.message:String(m?.message??m))}finally{y(!1)}},[]);n.useEffect(()=>{E()},[E]),n.useEffect(()=>{const m=K.get(x);C(m?.createDefaultConfig?.()??{}),g(m?.createDefaultAnswerKey?.()??null)},[x]);const L=async m=>{if(m.preventDefault(),!v.trim()){f(i?"题干不能为空":"Stem is required");return}a(!0),f(null);try{await k.createBankItem({type:x,stem:v.trim(),config:w,answerKey:A,visibility:j}),u(""),await E()}catch(p){f(p?.message??String(p))}finally{a(!1)}};return e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("section",{"aria-labelledby":"bank-create-heading",className:"border border-theme rounded-xl p-4 max-w-3xl mx-auto",children:[e.jsxs("h2",{id:"bank-create-heading",className:"text-xs font-bold text-main flex items-center gap-1.5 mb-3",children:[e.jsx(G,{size:13}),i?"新增题库题目":"New bank item"]}),e.jsxs("form",{onSubmit:L,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bank-type",className:"block text-2xs font-semibold text-muted mb-1",children:i?"题型":"Type"}),e.jsx("select",{id:"bank-type",value:x,onChange:m=>o(m.target.value),className:W,children:N.map(m=>e.jsx("option",{value:m.type,children:m.label[i?"zh":"en"]},m.type))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bank-stem",className:"block text-2xs font-semibold text-muted mb-1",children:i?"题干":"Stem"}),e.jsx("textarea",{id:"bank-stem",rows:2,value:v,onChange:m=>u(m.target.value),className:`${W} resize-none`})]}),I&&e.jsx(I,{config:w,answerKey:A,lang:l,onChange:({config:m,answerKey:p})=>{C(m),g(p)}}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bank-visibility",className:"block text-2xs font-semibold text-muted mb-1",children:i?"可见范围":"Visibility"}),e.jsxs("select",{id:"bank-visibility",value:j,onChange:m=>S(m.target.value==="school"?"school":"private"),className:W,children:[e.jsx("option",{value:"private",children:i?"仅自己":"Private"}),e.jsx("option",{value:"school",children:i?"同校教师可见":"Teachers on this instance"})]})]}),h&&e.jsx("p",{role:"alert",className:"text-xs text-rose-600",children:h}),e.jsxs("button",{type:"submit",disabled:$,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 disabled:opacity-50 cursor-pointer",children:[$&&e.jsx(T,{size:13,className:"animate-spin"}),i?"存入题库":"Save to bank"]})]})]}),e.jsxs("section",{"aria-labelledby":"bank-list-heading",className:"max-w-3xl mx-auto",children:[e.jsxs("h2",{id:"bank-list-heading",className:"text-xs font-bold text-main mb-2 flex items-center gap-1.5",children:[e.jsx(ne,{size:13}),i?"题库题目":"Bank items","(",c?.length??0,")"]}),c===null&&b?e.jsxs("p",{className:"text-xs text-muted flex items-center gap-2",children:[e.jsx(T,{size:13,className:"animate-spin"}),i?"加载中…":"Loading…"]}):(c?.length??0)===0?e.jsx("p",{className:"text-xs text-muted",children:i?"题库还是空的。":"The bank is empty."}):e.jsx("ul",{"data-testid":"bank-list",className:"space-y-2",children:c.map(m=>e.jsxs("li",{"data-testid":`bank-row-${m.id}`,className:"flex items-start gap-2 border border-theme rounded-xl px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-semibold text-main line-clamp-2",children:m.stem}),e.jsx("p",{className:"text-2xs text-muted mt-0.5",children:K.get(m.type)?.label[i?"zh":"en"]??m.type})]}),e.jsx("button",{type:"button",onClick:async()=>{if(window.confirm(i?"从题库删除该题?":"Delete this bank item?"))try{await k.removeBankItem(m.id),await E()}catch(p){f(p?.message??String(p))}},"aria-label":i?`删除题库题目:${m.stem.slice(0,20)}`:"Delete bank item",className:"p-1 rounded-md text-muted hover:text-rose-500 hover:bg-rose-500/10 cursor-pointer shrink-0",children:e.jsx(ee,{size:13})})]},m.id))})]})]})}const V={quiz:{zh:"测试",en:"Quiz",cls:"bg-indigo-50 text-indigo-700 border-indigo-200 dark:bg-indigo-950/40 dark:text-indigo-300 dark:border-indigo-800"},exam:{zh:"考试",en:"Exam",cls:"bg-rose-50 text-rose-700 border-rose-200 dark:bg-rose-950/40 dark:text-rose-300 dark:border-rose-800"},survey:{zh:"问卷",en:"Survey",cls:"bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950/40 dark:text-emerald-300 dark:border-emerald-800"}},te={draft:{zh:"草稿",en:"Draft",cls:"bg-surface-secondary text-muted border-theme"},published:{zh:"已发布",en:"Published",cls:"bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950/40 dark:text-emerald-300 dark:border-emerald-800"},closed:{zh:"已关闭",en:"Closed",cls:"bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-950/40 dark:text-amber-300 dark:border-amber-800"},archived:{zh:"已归档",en:"Archived",cls:"bg-surface-secondary text-muted border-theme"}};function Re(){const i=re()?.lang==="en"?"en":"zh",c=i==="zh",[t,h]=n.useState("papers"),[f,b]=n.useState(null),[y,x]=n.useState(!1),[o,v]=n.useState(null),[u,w]=n.useState(null),[C,A]=n.useState("all"),[g,j]=n.useState(!1),S=n.useCallback(async()=>{x(!0),v(null);try{const a=await k.list(C==="all"?{}:{kind:C});b(a.items)}catch(a){v(a instanceof U?a.message:String(a?.message??a))}finally{x(!1)}},[C]);n.useEffect(()=>{t==="papers"&&u===null&&S()},[t,u,S]);const $=n.useMemo(()=>[...f??[]].sort((N,P)=>P.updatedAt-N.updatedAt),[f]);return u?e.jsx(we,{assessmentId:u,lang:i,onBack:()=>{w(null),S()}}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-theme bg-surface-secondary/70 flex flex-col lg:flex-row lg:items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h1",{className:"text-base font-bold text-main flex items-center gap-2",children:[e.jsx(H,{size:18,className:"text-indigo-500"}),c?"测评中心":"Assessment Center"]}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:c?"组卷、发布到班级、批改与统计。测试 / 考试 / 问卷共用同一套题目与判分模型。":"Build papers, publish to classes, grade and analyse. Quizzes, exams and surveys share one item model."})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:"inline-flex p-1 bg-surface-secondary border border-theme rounded-xl text-xs font-semibold",children:[{id:"papers",label:c?"试卷":"Papers",icon:H},{id:"bank",label:c?"题库":"Question bank",icon:ge}].map(a=>{const N=a.icon,P=t===a.id;return e.jsxs("button",{type:"button",onClick:()=>h(a.id),"aria-pressed":P,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg transition-colors cursor-pointer ${P?"bg-surface text-main shadow-3xs font-bold":"text-muted hover:text-main"}`,children:[e.jsx(N,{size:13}),a.label]},a.id)})}),e.jsxs("button",{type:"button",onClick:()=>void S(),disabled:y||t!=="papers",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-xs font-semibold text-main disabled:opacity-50 cursor-pointer",children:[e.jsx(Y,{size:13,className:y?"animate-spin":""}),c?"刷新":"Refresh"]}),t==="papers"&&e.jsxs("button",{type:"button",onClick:()=>j(!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 cursor-pointer",children:[e.jsx(G,{size:13}),c?"新建测评":"New assessment"]})]})]}),o&&e.jsxs("div",{role:"alert",className:"mx-6 mt-4 px-3 py-2 rounded-xl border border-rose-200 bg-rose-50 text-rose-700 text-xs flex items-center gap-2",children:[e.jsx(fe,{size:14}),o]}),t==="bank"?e.jsx(Ae,{lang:i}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-6 py-3 border-b border-theme flex flex-wrap items-center gap-2 shrink-0",children:[e.jsx("span",{className:"text-xs font-semibold text-muted",children:c?"类型筛选":"Filter by kind"}),["all","quiz","exam","survey"].map(a=>e.jsx("button",{type:"button",onClick:()=>A(a),"aria-pressed":C===a,className:`px-2.5 py-1 rounded-full text-xs font-semibold border cursor-pointer ${C===a?"bg-indigo-600 text-white border-indigo-600":"bg-surface text-muted border-theme hover:text-main"}`,children:a==="all"?c?"全部":"All":V[a]?.[c?"zh":"en"]??a},a))]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:f===null&&y?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted",children:[e.jsx(T,{size:16,className:"animate-spin"}),c?"正在加载试卷…":"Loading papers…"]}):$.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-16 text-center",children:[e.jsx(H,{size:40,className:"text-muted opacity-40"}),e.jsx("p",{className:"text-sm font-semibold text-main",children:c?"还没有任何测评":"No assessments yet"}),e.jsx("p",{className:"text-xs text-muted max-w-sm",children:c?"新建一份测试、考试或问卷,组卷后发布到班级,学生就能在「我的测评」里作答。":"Create a quiz, exam or survey, add questions, then publish it to a class."}),e.jsxs("button",{type:"button",onClick:()=>j(!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 cursor-pointer",children:[e.jsx(G,{size:13}),c?"新建测评":"New assessment"]})]}):e.jsx("ul",{"data-testid":"assessment-list",className:"grid grid-cols-1 xl:grid-cols-2 gap-3 max-w-[1400px] mx-auto",children:$.map(a=>{const N=V[a.kind]??V.quiz,P=te[a.status]??te.draft;return e.jsxs("li",{"data-testid":`assessment-row-${a.id}`,className:"bg-surface border border-theme rounded-xl p-4 flex flex-col gap-2.5 hover:border-indigo-300 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-bold text-sm text-main truncate",title:a.title,children:a.title}),a.description&&e.jsx("p",{className:"text-xs text-muted mt-0.5 line-clamp-2",children:a.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx("span",{className:`px-2 py-0.5 rounded-full text-2xs font-bold border ${N.cls}`,children:N[c?"zh":"en"]}),e.jsx("span",{className:`px-2 py-0.5 rounded-full text-2xs font-semibold border ${P.cls}`,children:P[c?"zh":"en"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-2xs text-muted flex-wrap",children:[e.jsxs("span",{children:[a.itemCount," ",c?"题":"items"]}),e.jsxs("span",{children:[c?"满分":"Total"," ",a.totalScore]}),a.settings.anonymous&&e.jsxs("span",{children:["🔒 ",c?"匿名":"Anonymous"]}),a.settings.maxAttempts>1&&e.jsx("span",{children:c?`可作答 ${a.settings.maxAttempts} 次`:`${a.settings.maxAttempts} attempts`}),e.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[a.status==="draft"&&e.jsx("button",{type:"button",onClick:async()=>{if(window.confirm(c?`删除「${a.title}」?`:`Delete "${a.title}"?`))try{await k.remove(a.id),S()}catch(I){v(I?.message??String(I))}},"aria-label":c?`删除 ${a.title}`:`Delete ${a.title}`,className:"p-1 rounded-md text-muted hover:text-rose-500 hover:bg-rose-500/10 cursor-pointer",children:e.jsx(ee,{size:13})}),e.jsxs("button",{type:"button",onClick:()=>w(a.id),className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:[a.status==="draft"?c?"继续编辑":"Edit":c?"查看与批改":"Open",e.jsx(ye,{size:12})]})]})]}),e.jsx(ae,{slot:"assessment.list.card",slotProps:{assessment:Ne(a),viewer:"teacher",lang:i},lang:i})]},a.id)})})})]}),g&&e.jsx(Ie,{lang:i,onClose:()=>j(!1),onCreated:a=>{j(!1),w(a)}})]})}function Ie({lang:l,onClose:i,onCreated:c}){const t=l==="zh",[h,f]=n.useState("quiz"),[b,y]=n.useState(""),[x,o]=n.useState(""),[v,u]=n.useState(!1),[w,C]=n.useState(null),A=async g=>{if(g.preventDefault(),!b.trim()){C(t?"请填写标题":"Title is required");return}u(!0),C(null);try{const j=await k.create({kind:h,title:b.trim(),description:x.trim()||null});c(j.id)}catch(j){C(j?.message??String(j))}finally{u(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"create-assessment-title",className:"w-full max-w-md bg-surface border border-theme rounded-2xl shadow-2xl p-5 space-y-4",children:[e.jsx("h2",{id:"create-assessment-title",className:"text-sm font-bold text-main",children:t?"新建测评":"New assessment"}),e.jsxs("form",{onSubmit:A,className:"space-y-3",children:[e.jsxs("fieldset",{children:[e.jsx("legend",{className:"text-xs font-semibold text-muted mb-1",children:t?"类型":"Kind"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["quiz","exam","survey"].map(g=>e.jsxs("label",{className:`flex flex-col items-center gap-1 px-2 py-2 rounded-xl border text-xs cursor-pointer ${h===g?"border-indigo-500 bg-indigo-50 text-indigo-700 dark:bg-indigo-950/40 dark:text-indigo-300":"border-theme text-muted hover:text-main"}`,children:[e.jsx("input",{type:"radio",name:"assessment-kind",value:g,checked:h===g,onChange:()=>f(g),className:"sr-only"}),e.jsx("span",{className:"font-bold",children:V[g][t?"zh":"en"]}),e.jsx("span",{className:"text-2xs text-center leading-snug",children:g==="quiz"?t?"计分,可多次作答":"Scored, retakes allowed":g==="exam"?t?"一次作答,发布成绩后可见":"Single attempt, released later":t?"不计分,可匿名":"Not scored, can be anonymous"})]},g))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"assessment-title",className:"block text-xs font-semibold text-muted mb-1",children:t?"标题":"Title"}),e.jsx("input",{id:"assessment-title",value:b,onChange:g=>y(g.target.value),className:"w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500",placeholder:t?"例如:第三单元小测":"e.g. Unit 3 quiz"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"assessment-description",className:"block text-xs font-semibold text-muted mb-1",children:t?"说明(可选)":"Description (optional)"}),e.jsx("textarea",{id:"assessment-description",value:x,onChange:g=>o(g.target.value),rows:2,className:"w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500 resize-none"})]}),w&&e.jsx("p",{role:"alert",className:"text-xs text-rose-600",children:w}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:i,className:"px-3 py-1.5 rounded-xl border border-theme text-xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:t?"取消":"Cancel"}),e.jsxs("button",{type:"submit",disabled:v,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 disabled:opacity-50 cursor-pointer",children:[v&&e.jsx(T,{size:13,className:"animate-spin"}),t?"创建并开始组卷":"Create & build"]})]})]})]})})}export{Re as AssessmentCenter};
1
+ import{r as n,j as e}from"./vendor-react-DHoBZpn2.js";import{a as k,ae as U,E as ae,c as re,af as K}from"./index-Bc9003lB.js";import{aD as X,R as Y,c as T,h as ie,V as oe,J as de,ah as ce,av as xe,an as G,aw as ne,cj as me,bR as ue,af as ee,Z as be,U as pe,E as he,aq as Z,N as ge,T as fe,k as ye}from"./vendor-icons-CaXLq01o.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-DVWGghIL.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-skggaP9D.js";const se="w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500";function je(l){return l==null?"(未作答)":Array.isArray(l)?l.map(i=>String(i)).join(" | "):typeof l=="object"?JSON.stringify(l):String(l)}function ve({assignment:l,lang:i,onBack:c}){const t=i==="zh",[h,f]=n.useState(null),[b,y]=n.useState(null),[x,o]=n.useState(null),[v,u]=n.useState({}),[w,C]=n.useState({}),[A,g]=n.useState(!1),[j,S]=n.useState(null),[$,a]=n.useState(null),[N,P]=n.useState(null),[I,E]=n.useState({}),[L,m]=n.useState(null),[p,M]=n.useState(new Set),F=n.useCallback(async()=>{g(!0),a(null);try{const s=await k.listAttempts(l.id);f(s.items)}catch(s){a(s instanceof U?s.message:String(s?.message??s))}finally{g(!1)}},[l.id]);n.useEffect(()=>{F()},[F]);const _=async s=>{y(s),o(null),a(null),E({}),M(new Set);try{const r=await k.getTeacherView(s);o(r),u(Object.fromEntries(r.items.map(d=>[d.itemId,d.score===null?"":String(d.score)]))),C(Object.fromEntries(r.items.map(d=>[d.itemId,d.feedback??""])))}catch(r){a(r?.message??String(r))}},Q=async s=>{if(x){m(s.itemId),a(null);try{const r=await k.aiSuggestGrade(x.attempt.id,s.itemId);E(d=>({...d,[s.itemId]:r})),M(d=>{const B=new Set(d);return B.delete(s.itemId),B})}catch(r){a(t?"AI 建议不可用:"+(r?.message??String(r)):"AI suggestion unavailable: "+(r?.message??String(r)))}finally{m(null)}}},J=s=>{const r=I[s.itemId];r&&(u(d=>({...d,[s.itemId]:String(r.suggestedScore)})),M(d=>new Set(d).add(s.itemId)))},H=async s=>{if(!x)return;const r=v[s.itemId];if(r===""||r===void 0){a(t?"请填写分数":"Score is required");return}S(s.itemId),a(null);try{await k.gradeAnswer(x.attempt.id,s.itemId,{score:Number(r),feedback:w[s.itemId]||null,acceptedAiSuggestion:p.has(s.itemId),suggestedScore:I[s.itemId]?.suggestedScore});const d=await k.getTeacherView(x.attempt.id);o(d),P(t?"已保存该题评分(自动判分不再覆盖)":"Score saved — auto-grading will not override it."),await F()}catch(d){a(d?.message??String(d))}finally{S(null)}};return e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[e.jsx("button",{type:"button",onClick:c,className:"p-1.5 rounded-lg border border-theme bg-surface text-muted hover:text-main cursor-pointer","aria-label":t?"返回试卷":"Back to assessment",children:e.jsx(X,{size:15})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("h1",{className:"text-sm font-bold text-main truncate",children:[t?"人工批改":"Manual grading"," · ",l.className??l.classId]}),e.jsx("p",{className:"text-2xs text-muted",children:t?"简答题与「无法自动判分」的题在这里给分;保存后该题不再被自动判分覆盖。":"Grade short answers and any item the grader could not score. Saved scores are never auto-overwritten."})]}),e.jsxs("button",{type:"button",onClick:()=>void F(),disabled:A,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface text-xs font-semibold text-main disabled:opacity-50 cursor-pointer",children:[e.jsx(Y,{size:13,className:A?"animate-spin":""}),t?"刷新":"Refresh"]})]}),($||N)&&e.jsx("div",{role:$?"alert":"status",className:`mx-5 mt-3 px-3 py-2 rounded-xl border text-xs ${$?"border-rose-200 bg-rose-50 text-rose-700":"border-emerald-200 bg-emerald-50 text-emerald-700"}`,children:$??N}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-5 grid grid-cols-1 lg:grid-cols-[280px_1fr] gap-4",children:[e.jsxs("section",{"aria-labelledby":"attempts-heading",children:[e.jsxs("h2",{id:"attempts-heading",className:"text-xs font-bold text-main mb-2",children:[t?"作答列表":"Attempts","(",h?.length??0,")"]}),h===null&&A?e.jsxs("p",{className:"text-xs text-muted flex items-center gap-2",children:[e.jsx(T,{size:13,className:"animate-spin"}),t?"加载中…":"Loading…"]}):(h?.length??0)===0?e.jsx("p",{className:"text-xs text-muted",children:t?"还没有人交卷。":"No submissions yet."}):e.jsx("ul",{"data-testid":"grading-attempt-list",className:"space-y-1.5",children:h.map(s=>{const r=b===s.id,d=Number(s.proctor?.summary?.total??0);return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void _(s.id),"aria-pressed":r,className:`w-full text-left px-3 py-2 rounded-xl border text-xs cursor-pointer ${r?"border-indigo-400 bg-indigo-50 dark:bg-indigo-950/40":"border-theme hover:bg-surface-secondary"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("span",{className:"font-semibold text-main block truncate",children:s.anonymousLabel??s.studentId??s.id}),d>0&&e.jsxs("span",{className:"px-1.5 py-0.2 rounded text-3xs font-bold bg-rose-100 text-rose-700 dark:bg-rose-950/50 dark:text-rose-300 shrink-0",title:t?`监考异常事件 ${d} 次`:`${d} proctor violations`,children:["⚠️ ",d]})]}),e.jsxs("span",{className:"text-2xs text-muted",children:[s.status," · ",s.score??"—","/",s.maxScore??"—",s.needsManualReview&&e.jsx("span",{className:"ml-1 text-amber-700 dark:text-amber-300",children:t?"待批改":"pending"})]})]})},s.id)})})]}),e.jsxs("section",{"aria-labelledby":"grade-heading",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h2",{id:"grade-heading",className:"text-xs font-bold text-main",children:t?"逐题批改":"Grade items"}),x&&Number(x.attempt.proctor?.summary?.total??0)>0&&e.jsxs("div",{className:"px-2 py-0.5 rounded-lg border border-rose-200 bg-rose-50 text-rose-700 dark:bg-rose-950/40 dark:text-rose-300 dark:border-rose-800 text-2xs font-semibold",children:["⚠️ ",t?"监考异常":"Proctor alert",":",t?"切屏":"tab switch"," ",x.attempt.proctor?.summary?.visibility_hidden??0," · ",t?"失焦":"blur"," ",x.attempt.proctor?.summary?.blur??0," · ",t?"退出全屏":"exit fullscreen"," ",x.attempt.proctor?.summary?.fullscreen_exit??0]})]}),x?e.jsx("ul",{className:"space-y-3",children:x.items.map((s,r)=>e.jsxs("li",{"data-testid":`grading-item-${s.itemId}`,className:"border border-theme rounded-xl p-3 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-2xs font-bold text-muted",children:["#",r+1]}),e.jsx("span",{className:"text-xs font-semibold text-main flex-1 min-w-0 line-clamp-2",children:s.stem}),e.jsxs("span",{className:"text-2xs text-muted",children:[s.score??"—","/",s.maxScore]}),s.manualOverride&&e.jsxs("span",{className:"text-2xs text-indigo-600 inline-flex items-center gap-0.5",children:[e.jsx(ie,{size:11}),t?"已人工批改":"manual"]})]}),e.jsx("p",{className:"text-xs text-main bg-surface-secondary rounded-lg px-2 py-1.5 whitespace-pre-wrap break-words",children:je(s.answer)}),s.needsManualReview&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void Q(s),disabled:L===s.itemId,className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary disabled:opacity-50 cursor-pointer",children:[L===s.itemId?e.jsx(T,{size:11,className:"animate-spin"}):e.jsx(oe,{size:11}),t?"AI 建议":"AI suggestion"]}),I[s.itemId]&&e.jsxs("div",{className:"text-2xs text-muted bg-indigo-50 dark:bg-indigo-950/30 border border-indigo-200 dark:border-indigo-900 rounded-lg px-2 py-1.5 space-y-1",children:[e.jsxs("p",{className:"text-main",children:[t?"建议分":"Suggested"," ",I[s.itemId].suggestedScore,"/",s.maxScore,I[s.itemId].confidence!==null&&" · "+(t?"置信度":"confidence")+" "+Math.round(I[s.itemId].confidence*100)+"%",p.has(s.itemId)&&" · "+(t?"已填入,待保存":"applied, pending save")]}),e.jsx("p",{className:"whitespace-pre-wrap break-words",children:I[s.itemId].rationale}),e.jsx("button",{type:"button",onClick:()=>J(s),className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-indigo-600 text-white text-2xs font-bold hover:bg-indigo-700 cursor-pointer",children:t?"采纳并填入分数":"Apply to score"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[100px_1fr_auto] gap-2 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:`score-${s.itemId}`,className:"block text-2xs font-semibold text-muted mb-1",children:t?"得分":"Score"}),e.jsx("input",{id:`score-${s.itemId}`,type:"number",min:0,max:s.maxScore,step:.5,value:v[s.itemId]??"",onChange:d=>u(B=>({...B,[s.itemId]:d.target.value})),className:se})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:`feedback-${s.itemId}`,className:"block text-2xs font-semibold text-muted mb-1",children:t?"评语(可选)":"Feedback (optional)"}),e.jsx("input",{id:`feedback-${s.itemId}`,type:"text",value:w[s.itemId]??"",onChange:d=>C(B=>({...B,[s.itemId]:d.target.value})),className:se})]}),e.jsxs("button",{type:"button",onClick:()=>void H(s),disabled:j===s.itemId,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 disabled:opacity-50 cursor-pointer",children:[j===s.itemId&&e.jsx(T,{size:13,className:"animate-spin"}),t?"保存评分":"Save"]})]})]},s.itemId))}):e.jsx("p",{className:"text-xs text-muted",children:t?"从左侧选择一份作答。":"Pick an attempt on the left."})]})]})]})}function Ne(l){return{id:l.id,kind:l.kind,title:l.title,description:l.description,status:l.status,itemCount:l.itemCount,totalScore:l.totalScore,settings:l.settings,createdAt:l.createdAt,updatedAt:l.updatedAt}}function ke(l){return{attemptCount:l.attemptCount,submittedCount:l.submittedCount,gradedCount:l.gradedCount,needsManualReviewCount:l.needsManualReviewCount,averageScore:l.averageScore,averagePercent:l.averagePercent,maxScore:l.maxScore,items:l.items.map(i=>({itemId:i.itemId,type:i.type,stem:i.stem,maxScore:i.maxScore,answered:i.answered,graded:i.graded,correct:i.correct,correctRate:i.correctRate,avgScore:i.avgScore,distribution:i.distribution}))}}function Se({assignment:l,lang:i,onBack:c}){const t=i==="zh",[h,f]=n.useState(null),[b,y]=n.useState(!1),[x,o]=n.useState(null),v=n.useCallback(async()=>{y(!0),o(null);try{f(await k.stats(l.id))}catch(u){o(u instanceof U?u.message:String(u?.message??u))}finally{y(!1)}},[l.id]);return n.useEffect(()=>{v()},[v]),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[e.jsx("button",{type:"button",onClick:c,className:"p-1.5 rounded-lg border border-theme bg-surface text-muted hover:text-main cursor-pointer","aria-label":t?"返回试卷":"Back to assessment",children:e.jsx(X,{size:15})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("h1",{className:"text-sm font-bold text-main truncate",children:[t?"统计":"Statistics"," · ",l.className??l.classId]})}),e.jsxs("a",{href:k.exportCsvUrl(l.id),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface text-xs font-semibold text-main hover:bg-surface-secondary",children:[e.jsx(de,{size:13}),t?"导出 CSV":"Export CSV"]}),e.jsxs("button",{type:"button",onClick:()=>void v(),disabled:b,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface text-xs font-semibold text-main disabled:opacity-50 cursor-pointer",children:[e.jsx(Y,{size:13,className:b?"animate-spin":""}),t?"刷新":"Refresh"]})]}),x&&e.jsx("p",{role:"alert",className:"mx-5 mt-3 px-3 py-2 rounded-xl border border-rose-200 bg-rose-50 text-rose-700 text-xs",children:x}),e.jsx("div",{className:"flex-1 overflow-y-auto p-5 space-y-4",children:h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[[{label:t?"作答数":"Attempts",value:h.attemptCount},{label:t?"已交卷":"Submitted",value:h.submittedCount},{label:t?"待人工批改":"Pending review",value:h.needsManualReviewCount},{label:t?"平均分":"Average",value:h.averageScore===null?"—":`${h.averageScore}${h.averagePercent!==null?` (${h.averagePercent}%)`:""}`}].map(u=>e.jsxs("div",{className:"border border-theme rounded-xl px-3 py-2 bg-surface-secondary/40",children:[e.jsx("p",{className:"text-2xs text-muted",children:u.label}),e.jsx("p",{className:"text-sm font-bold text-main",children:u.value})]},u.label)),e.jsx(ae,{slot:"assessment.stats.card",slotProps:{assignmentId:l.id,stats:ke(h),lang:i},lang:i})]}),e.jsxs("table",{"data-testid":"stats-table",className:"w-full text-xs border border-theme rounded-xl overflow-hidden",children:[e.jsx("caption",{className:"sr-only",children:t?"逐题统计":"Per-item statistics"}),e.jsx("thead",{className:"bg-surface-secondary text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"text-left px-3 py-2 font-semibold",children:"#"}),e.jsx("th",{scope:"col",className:"text-left px-3 py-2 font-semibold",children:t?"题干":"Stem"}),e.jsx("th",{scope:"col",className:"text-right px-3 py-2 font-semibold",children:t?"作答":"Answered"}),e.jsx("th",{scope:"col",className:"text-right px-3 py-2 font-semibold",children:t?"正确率":"Correct rate"}),e.jsx("th",{scope:"col",className:"text-right px-3 py-2 font-semibold",children:t?"均分":"Avg score"})]})}),e.jsx("tbody",{children:h.items.map((u,w)=>e.jsxs("tr",{className:"border-t border-theme",children:[e.jsx("td",{className:"px-3 py-2 text-muted",children:w+1}),e.jsx("td",{className:"px-3 py-2 text-main max-w-[320px] truncate",title:u.stem,children:u.stem}),e.jsx("td",{className:"px-3 py-2 text-right text-main",children:u.answered}),e.jsx("td",{className:"px-3 py-2 text-right text-main",children:u.correctRate===null?"—":`${u.correctRate}%`}),e.jsx("td",{className:"px-3 py-2 text-right text-main",children:u.avgScore===null?"—":`${u.avgScore}/${u.maxScore}`})]},u.itemId))})]}),e.jsx("p",{className:"text-2xs text-muted",children:t?"待人工批改的题不计入正确率与均分;匿名问卷的导出不含身份信息。":"Items awaiting manual review are excluded from correct-rate and averages. Anonymous exports contain no identity."})]}):e.jsxs("p",{className:"text-xs text-muted flex items-center gap-2",children:[e.jsx(T,{size:13,className:"animate-spin"}),t?"正在统计…":"Computing…"]})})]})}const q="w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500";function we({assessmentId:l,lang:i,onBack:c}){const t=i==="zh",f=re()?.classes??[],[b,y]=n.useState(null),[x,o]=n.useState([]),[v,u]=n.useState([]),[w,C]=n.useState(!0),[A,g]=n.useState(null),[j,S]=n.useState(null),[$,a]=n.useState(null),[N,P]=n.useState(null),[I,E]=n.useState(null),[L,m]=n.useState(null),p=b?.status==="draft",M=n.useMemo(()=>(K.subscribe(()=>{}),K.list().filter(s=>s.supports.includes(b?.kind??"quiz"))),[b?.kind]),F=n.useCallback(async()=>{C(!0),S(null);try{const s=await k.get(l);y(s),o(s.items.map(d=>({id:d.id,type:d.type,stem:d.stem,config:d.config??{},answerKey:d.answerKey??null,maxScore:d.maxScore})));const r=await k.getAssignments(l).catch(()=>({items:[]}));u(r.items)}catch(s){S(s instanceof U?s.message:String(s?.message??s))}finally{C(!1)}},[l]);n.useEffect(()=>{F()},[F]);const _=async s=>{g("settings"),S(null);try{const r=await k.update(l,{settings:s});y(r),a(t?"设置已保存":"Settings saved")}catch(r){S(r?.message??String(r))}finally{g(null)}},Q=async()=>{g("items"),S(null);try{const s=await k.replaceItems(l,x.map((r,d)=>({id:r.id,type:r.type,stem:r.stem,config:r.config,answerKey:r.answerKey,maxScore:r.maxScore,sortOrder:d})));y(s),o(s.items.map(r=>({id:r.id,type:r.type,stem:r.stem,config:r.config??{},answerKey:r.answerKey??null,maxScore:r.maxScore}))),a(t?"题目已保存":"Items saved")}catch(s){S(s?.message??String(s))}finally{g(null)}},J=s=>{const r=K.get(s);o(d=>[...d,{id:`new-${Date.now()}-${d.length}`,type:s,stem:"",config:r?.createDefaultConfig?.()??{},answerKey:r?.createDefaultAnswerKey?.()??null,maxScore:5}])},H=async()=>{try{const s=await k.listBank();m(s.items)}catch(s){S(s?.message??String(s))}};return w?e.jsxs("div",{className:"flex-1 flex items-center justify-center gap-2 py-16 text-sm text-muted",children:[e.jsx(T,{size:16,className:"animate-spin"}),t?"正在加载试卷…":"Loading assessment…"]}):b?N?e.jsx(ve,{assignment:N,lang:i,onBack:()=>{P(null),F()}}):I?e.jsx(Se,{assignment:I,lang:i,onBack:()=>E(null)}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-theme bg-surface-secondary/70 flex flex-wrap items-center gap-3 shrink-0",children:[e.jsx("button",{type:"button",onClick:c,className:"p-1.5 rounded-lg border border-theme bg-surface hover:bg-surface-secondary text-muted hover:text-main cursor-pointer","aria-label":t?"返回测评列表":"Back to assessment list",children:e.jsx(X,{size:15})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h1",{className:"text-sm font-bold text-main truncate",children:b.title}),e.jsxs("p",{className:"text-2xs text-muted",children:[t?"类型":"Kind",":",b.kind," · ",t?"状态":"Status",":",b.status," · ",x.length," ",t?"题":"items"," · ",t?"满分":"total"," ",x.reduce((s,r)=>s+r.maxScore,0)]})]}),p&&e.jsxs("button",{type:"button",onClick:()=>void Q(),disabled:A!==null,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 disabled:opacity-50 cursor-pointer",children:[A==="items"?e.jsx(T,{size:13,className:"animate-spin"}):e.jsx(ce,{size:13}),t?"保存题目":"Save items"]})]}),(j||$)&&e.jsx("div",{role:j?"alert":"status",className:`mx-5 mt-3 px-3 py-2 rounded-xl border text-xs ${j?"border-rose-200 bg-rose-50 text-rose-700":"border-emerald-200 bg-emerald-50 text-emerald-700"}`,children:j??$}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-5",children:[e.jsxs("section",{"aria-labelledby":"settings-heading",className:"border border-theme rounded-xl p-4",children:[e.jsxs("h2",{id:"settings-heading",className:"text-xs font-bold text-main flex items-center gap-1.5 mb-3",children:[e.jsx(xe,{size:13}),t?"测评设置":"Settings",!p&&e.jsxs("span",{className:"text-2xs font-normal text-muted",children:["(",t?"已发布,只读":"published, read-only",")"]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"set-attempts",className:"block text-2xs font-semibold text-muted mb-1",children:t?"允许作答次数":"Max attempts"}),e.jsx("input",{id:"set-attempts",type:"number",min:1,max:10,value:b.settings.maxAttempts,disabled:!p||b.kind!=="quiz",onChange:s=>void _({maxAttempts:Number(s.target.value)||1}),className:q})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"set-policy",className:"block text-2xs font-semibold text-muted mb-1",children:t?"多次作答取哪次":"Score policy"}),e.jsxs("select",{id:"set-policy",value:b.settings.scorePolicy,disabled:!p||b.kind!=="quiz",onChange:s=>void _({scorePolicy:s.target.value}),className:q,children:[e.jsx("option",{value:"last",children:t?"最后一次":"Last"}),e.jsx("option",{value:"first",children:t?"第一次":"First"}),e.jsx("option",{value:"highest",children:t?"最高分":"Highest"}),e.jsx("option",{value:"average",children:t?"平均分":"Average"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"set-visibility",className:"block text-2xs font-semibold text-muted mb-1",children:t?"结果可见性":"Result visibility"}),e.jsxs("select",{id:"set-visibility",value:b.settings.resultVisibility,disabled:!p||b.kind==="survey",onChange:s=>void _({resultVisibility:s.target.value}),className:q,children:[e.jsx("option",{value:"immediate",children:t?"交卷即显示":"Immediately"}),e.jsx("option",{value:"after_release",children:t?"教师发布成绩后":"After release"}),e.jsx("option",{value:"score_only",children:t?"只显示分数":"Score only"})]})]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-4",children:[{key:"singleAttempt",zh:"严格单次作答(禁止重考)",en:"Single attempt only",disabled:!p},{key:"shuffleItems",zh:"题目乱序",en:"Shuffle items",disabled:!p},{key:"shuffleOptions",zh:"选项乱序",en:"Shuffle options",disabled:!p},{key:"strictProctor",zh:"严格监考(切屏/失焦/防复制)",en:"Strict proctoring",disabled:!p},{key:"partialCredit",zh:"多选少选给部分分",en:"Partial credit for multi-choice",disabled:!p},{key:"caseSensitive",zh:"填空题区分大小写",en:"Case-sensitive blanks",disabled:!p},{key:"showItemAnalysis",zh:"允许查看逐题解析",en:"Show item analysis",disabled:!p||b.kind==="survey"},{key:"anonymous",zh:"匿名问卷",en:"Anonymous survey",disabled:!p||b.kind!=="survey"}].map(s=>e.jsxs("label",{className:"inline-flex items-center gap-1.5 text-xs text-main",children:[e.jsx("input",{type:"checkbox",checked:!!b.settings[s.key],disabled:s.disabled||!p,onChange:r=>void _({[s.key]:r.target.checked}),className:"accent-indigo-600"}),s[t?"zh":"en"]]},s.key))})]}),e.jsxs("section",{"aria-labelledby":"items-heading",className:"border border-theme rounded-xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("h2",{id:"items-heading",className:"text-xs font-bold text-main",children:[t?"题目列表":"Items","(",x.length,")"]}),p&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[M.map(s=>e.jsxs("button",{type:"button",onClick:()=>J(s.type),className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:[e.jsx(G,{size:11}),s.label[t?"zh":"en"]]},s.type)),e.jsxs("button",{type:"button",onClick:()=>void H(),className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:[e.jsx(ne,{size:11}),t?"从题库添加":"From bank"]})]})]}),x.length===0?e.jsx("p",{className:"text-xs text-muted py-6 text-center",children:t?"还没有题目。用上方按钮添加第一道题。":"No items yet — add your first question above."}):e.jsx("ol",{className:"space-y-3",children:x.map((s,r)=>{const d=K.get(s.type),B=d?.Editor;return e.jsxs("li",{"data-testid":`item-row-${r}`,className:"border border-theme rounded-xl p-3 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-2xs font-bold text-muted",children:["#",r+1]}),e.jsx("span",{className:"px-2 py-0.5 rounded-full bg-surface-secondary border border-theme text-2xs font-semibold text-main",children:d?.label[t?"zh":"en"]??s.type}),e.jsx("label",{htmlFor:`item-score-${s.id}`,className:"ml-auto text-2xs text-muted",children:t?"分值":"Score"}),e.jsx("input",{id:`item-score-${s.id}`,type:"number",min:1,value:s.maxScore,disabled:!p,onChange:D=>o(z=>z.map((R,O)=>O===r?{...R,maxScore:Number(D.target.value)||1}:R)),className:"w-16 px-2 py-1 border border-theme rounded-lg text-xs bg-surface text-main"}),p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:r===0,onClick:()=>o(D=>{const z=[...D];return[z[r-1],z[r]]=[z[r],z[r-1]],z}),"aria-label":t?`上移第 ${r+1} 题`:`Move item ${r+1} up`,className:"p-1 rounded-md text-muted hover:text-main hover:bg-surface-secondary disabled:opacity-30 cursor-pointer",children:e.jsx(me,{size:12})}),e.jsx("button",{type:"button",disabled:r===x.length-1,onClick:()=>o(D=>{const z=[...D];return[z[r+1],z[r]]=[z[r],z[r+1]],z}),"aria-label":t?`下移第 ${r+1} 题`:`Move item ${r+1} down`,className:"p-1 rounded-md text-muted hover:text-main hover:bg-surface-secondary disabled:opacity-30 cursor-pointer",children:e.jsx(ue,{size:12})}),e.jsx("button",{type:"button",onClick:()=>o(D=>D.filter((z,R)=>R!==r)),"aria-label":t?`删除第 ${r+1} 题`:`Delete item ${r+1}`,className:"p-1 rounded-md text-muted hover:text-rose-500 hover:bg-rose-500/10 cursor-pointer",children:e.jsx(ee,{size:12})})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:`item-stem-${s.id}`,className:"block text-2xs font-semibold text-muted mb-1",children:t?"题干":"Stem"}),e.jsx("textarea",{id:`item-stem-${s.id}`,rows:2,value:s.stem,disabled:!p,onChange:D=>o(z=>z.map((R,O)=>O===r?{...R,stem:D.target.value}:R)),className:`${q} resize-none`})]}),B?e.jsx(B,{config:s.config,answerKey:s.answerKey,lang:i,disabled:!p,onChange:({config:D,answerKey:z})=>o(R=>R.map((O,le)=>le===r?{...O,config:D,answerKey:z}:O))}):e.jsx("p",{className:"text-2xs text-amber-700 dark:text-amber-300",children:t?`题型「${s.type}」没有注册出题编辑器(可能来自未启用/已卸载的插件)。`:`No editor registered for "${s.type}" (plugin missing or disabled).`})]},s.id)})})]}),e.jsx(Ce,{lang:i,detail:b,classes:f,assignments:v,disabled:!p,onPublished:async()=>{await F()},onGrading:P,onStats:E,onError:S})]}),L&&e.jsx(ze,{lang:i,items:L,allowedTypes:M.map(s=>s.type),onClose:()=>m(null),onPick:s=>{o(r=>[...r,{id:`new-${Date.now()}-${r.length}`,type:s.type,stem:s.stem,config:s.config??{},answerKey:s.answerKey??null,maxScore:5}]),m(null)}})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 py-16",children:[e.jsx("p",{role:"alert",className:"text-sm text-rose-600",children:j??(t?"加载失败":"Failed to load")}),e.jsx("button",{type:"button",onClick:c,className:"text-xs font-semibold text-indigo-600 underline cursor-pointer",children:t?"返回列表":"Back to list"})]})}function Ce({lang:l,detail:i,classes:c,assignments:t,disabled:h,onPublished:f,onGrading:b,onStats:y,onError:x}){const o=l==="zh",[v,u]=n.useState(""),[w,C]=n.useState(""),[A,g]=n.useState(""),[j,S]=n.useState(!1),$=async()=>{if(!v){x(o?"请选择班级":"Pick a class first");return}S(!0);try{await k.publish(i.id,{classId:v,durationSec:w?Number(w)*60:null,closesAt:A?new Date(A).getTime():null}),await f()}catch(a){x(a?.message??String(a))}finally{S(!1)}};return e.jsxs("section",{"aria-labelledby":"publish-heading",className:"border border-theme rounded-xl p-4 space-y-3",children:[e.jsxs("h2",{id:"publish-heading",className:"text-xs font-bold text-main flex items-center gap-1.5",children:[e.jsx(be,{size:13}),o?"发布到班级":"Publish to a class"]}),h?e.jsx("p",{className:"text-2xs text-muted",children:o?"试卷已发布,内容只读。需要改题请新建一份试卷。":"Published papers are read-only. Create a new one to change items."}):e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1.2fr_1fr_1fr_auto] gap-2 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"pub-class",className:"block text-2xs font-semibold text-muted mb-1",children:o?"班级":"Class"}),e.jsxs("select",{id:"pub-class",value:v,onChange:a=>u(a.target.value),className:q,children:[e.jsx("option",{value:"",children:o?"请选择班级":"Select a class"}),c.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"pub-duration",className:"block text-2xs font-semibold text-muted mb-1",children:o?"限时(分钟,可选)":"Time limit (min)"}),e.jsx("input",{id:"pub-duration",type:"number",min:1,value:w,onChange:a=>C(a.target.value),className:q})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"pub-closes",className:"block text-2xs font-semibold text-muted mb-1",children:o?"截止时间(可选)":"Closes at"}),e.jsx("input",{id:"pub-closes",type:"datetime-local",value:A,onChange:a=>g(a.target.value),className:q})]}),e.jsxs("button",{type:"button",onClick:()=>void $(),disabled:j,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-emerald-600 text-white text-xs font-bold hover:bg-emerald-700 disabled:opacity-50 cursor-pointer",children:[j&&e.jsx(T,{size:13,className:"animate-spin"}),o?"发布":"Publish"]})]}),t.length>0&&e.jsx("ul",{"data-testid":"assignment-list",className:"space-y-2 pt-1",children:t.map(a=>e.jsxs("li",{"data-testid":`assignment-row-${a.id}`,className:"flex flex-wrap items-center gap-2 border border-theme rounded-xl px-3 py-2",children:[e.jsx(pe,{size:13,className:"text-muted"}),e.jsx("span",{className:"text-xs font-semibold text-main",children:a.className??a.classId}),e.jsx("span",{className:`px-2 py-0.5 rounded-full text-2xs font-semibold border ${a.status==="open"?"bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950/40 dark:text-emerald-300 dark:border-emerald-800":"bg-surface-secondary text-muted border-theme"}`,children:a.status==="open"?o?"进行中":"Open":o?"已关闭":"Closed"}),e.jsxs("span",{className:"text-2xs text-muted",children:[o?"已交卷":"Submitted"," ",a.submittedCount,"/",a.attemptCount," ·"," ",o?"待批改":"Pending"," ",a.pendingReviewCount]}),a.scoreReleased&&e.jsx("span",{className:"text-2xs text-indigo-600",children:o?"成绩已发布":"Scores released"}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[e.jsxs("a",{href:k.exportCsvUrl(a.id),className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary",children:[e.jsx(he,{size:11}),"CSV"]}),e.jsx("button",{type:"button",onClick:()=>y(a),className:"px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:o?"统计":"Stats"}),e.jsx("button",{type:"button",onClick:()=>b(a),className:"px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:o?"批改":"Grade"}),a.scoreReleased?e.jsx("button",{type:"button",onClick:async()=>{try{await k.syncGradebook(a.id),await f()}catch(N){x(N?.message??String(N))}},title:o?"将本场成绩同步至系统成绩单":"Sync scores to gradebook",className:"px-2 py-1 rounded-lg border border-indigo-200 text-indigo-700 bg-indigo-50/50 hover:bg-indigo-100 dark:border-indigo-800 dark:text-indigo-300 dark:bg-indigo-950/40 text-2xs font-semibold cursor-pointer",children:o?"同步成绩单":"Sync Grades"}):e.jsx("button",{type:"button",onClick:async()=>{try{await k.releaseScores(a.id),await f()}catch(N){x(N?.message??String(N))}},title:o?"发布成绩并自动同步至成绩单":"Release scores and sync to gradebook",className:"px-2 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:o?"发布成绩":"Release"}),a.status==="open"&&e.jsx("button",{type:"button",onClick:async()=>{try{await k.closeAssignment(a.id),await f()}catch(N){x(N?.message??String(N))}},className:"px-2 py-1 rounded-lg border border-amber-300 text-2xs font-semibold text-amber-700 hover:bg-amber-50 cursor-pointer",children:o?"关闭":"Close"})]})]},a.id))})]})}function ze({lang:l,items:i,allowedTypes:c,onClose:t,onPick:h}){const f=l==="zh",b=i.filter(y=>c.includes(y.type));return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"bank-picker-title",className:"w-full max-w-lg max-h-[80vh] flex flex-col bg-surface border border-theme rounded-2xl shadow-2xl",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-theme flex items-center justify-between",children:[e.jsx("h2",{id:"bank-picker-title",className:"text-sm font-bold text-main",children:f?"从题库添加":"Add from question bank"}),e.jsx("button",{type:"button",onClick:t,className:"text-xs font-semibold text-muted hover:text-main cursor-pointer",children:f?"关闭":"Close"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-2",children:b.length===0?e.jsx("p",{className:"text-xs text-muted py-6 text-center",children:f?"题库里还没有可用于本测评类型的题目。":"No bank items usable for this assessment kind."}):b.map(y=>e.jsxs("button",{type:"button",onClick:()=>h(y),className:"w-full text-left border border-theme rounded-xl px-3 py-2 hover:border-indigo-300 hover:bg-surface-secondary cursor-pointer",children:[e.jsx("p",{className:"text-xs font-semibold text-main line-clamp-2",children:y.stem}),e.jsx("p",{className:"text-2xs text-muted mt-0.5",children:y.type})]},y.id))})]})})}const W="w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500";function Ae({lang:l}){const i=l==="zh",[c,t]=n.useState(null),[h,f]=n.useState(null),[b,y]=n.useState(!1),[x,o]=n.useState("single_choice"),[v,u]=n.useState(""),[w,C]=n.useState({}),[A,g]=n.useState(null),[j,S]=n.useState("private"),[$,a]=n.useState(!1),N=K.list(),I=K.get(x)?.Editor,E=n.useCallback(async()=>{y(!0),f(null);try{const m=await k.listBank();t(m.items)}catch(m){f(m instanceof U?m.message:String(m?.message??m))}finally{y(!1)}},[]);n.useEffect(()=>{E()},[E]),n.useEffect(()=>{const m=K.get(x);C(m?.createDefaultConfig?.()??{}),g(m?.createDefaultAnswerKey?.()??null)},[x]);const L=async m=>{if(m.preventDefault(),!v.trim()){f(i?"题干不能为空":"Stem is required");return}a(!0),f(null);try{await k.createBankItem({type:x,stem:v.trim(),config:w,answerKey:A,visibility:j}),u(""),await E()}catch(p){f(p?.message??String(p))}finally{a(!1)}};return e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("section",{"aria-labelledby":"bank-create-heading",className:"border border-theme rounded-xl p-4 max-w-3xl mx-auto",children:[e.jsxs("h2",{id:"bank-create-heading",className:"text-xs font-bold text-main flex items-center gap-1.5 mb-3",children:[e.jsx(G,{size:13}),i?"新增题库题目":"New bank item"]}),e.jsxs("form",{onSubmit:L,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bank-type",className:"block text-2xs font-semibold text-muted mb-1",children:i?"题型":"Type"}),e.jsx("select",{id:"bank-type",value:x,onChange:m=>o(m.target.value),className:W,children:N.map(m=>e.jsx("option",{value:m.type,children:m.label[i?"zh":"en"]},m.type))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bank-stem",className:"block text-2xs font-semibold text-muted mb-1",children:i?"题干":"Stem"}),e.jsx("textarea",{id:"bank-stem",rows:2,value:v,onChange:m=>u(m.target.value),className:`${W} resize-none`})]}),I&&e.jsx(I,{config:w,answerKey:A,lang:l,onChange:({config:m,answerKey:p})=>{C(m),g(p)}}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bank-visibility",className:"block text-2xs font-semibold text-muted mb-1",children:i?"可见范围":"Visibility"}),e.jsxs("select",{id:"bank-visibility",value:j,onChange:m=>S(m.target.value==="school"?"school":"private"),className:W,children:[e.jsx("option",{value:"private",children:i?"仅自己":"Private"}),e.jsx("option",{value:"school",children:i?"同校教师可见":"Teachers on this instance"})]})]}),h&&e.jsx("p",{role:"alert",className:"text-xs text-rose-600",children:h}),e.jsxs("button",{type:"submit",disabled:$,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 disabled:opacity-50 cursor-pointer",children:[$&&e.jsx(T,{size:13,className:"animate-spin"}),i?"存入题库":"Save to bank"]})]})]}),e.jsxs("section",{"aria-labelledby":"bank-list-heading",className:"max-w-3xl mx-auto",children:[e.jsxs("h2",{id:"bank-list-heading",className:"text-xs font-bold text-main mb-2 flex items-center gap-1.5",children:[e.jsx(ne,{size:13}),i?"题库题目":"Bank items","(",c?.length??0,")"]}),c===null&&b?e.jsxs("p",{className:"text-xs text-muted flex items-center gap-2",children:[e.jsx(T,{size:13,className:"animate-spin"}),i?"加载中…":"Loading…"]}):(c?.length??0)===0?e.jsx("p",{className:"text-xs text-muted",children:i?"题库还是空的。":"The bank is empty."}):e.jsx("ul",{"data-testid":"bank-list",className:"space-y-2",children:c.map(m=>e.jsxs("li",{"data-testid":`bank-row-${m.id}`,className:"flex items-start gap-2 border border-theme rounded-xl px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-semibold text-main line-clamp-2",children:m.stem}),e.jsx("p",{className:"text-2xs text-muted mt-0.5",children:K.get(m.type)?.label[i?"zh":"en"]??m.type})]}),e.jsx("button",{type:"button",onClick:async()=>{if(window.confirm(i?"从题库删除该题?":"Delete this bank item?"))try{await k.removeBankItem(m.id),await E()}catch(p){f(p?.message??String(p))}},"aria-label":i?`删除题库题目:${m.stem.slice(0,20)}`:"Delete bank item",className:"p-1 rounded-md text-muted hover:text-rose-500 hover:bg-rose-500/10 cursor-pointer shrink-0",children:e.jsx(ee,{size:13})})]},m.id))})]})]})}const V={quiz:{zh:"测试",en:"Quiz",cls:"bg-indigo-50 text-indigo-700 border-indigo-200 dark:bg-indigo-950/40 dark:text-indigo-300 dark:border-indigo-800"},exam:{zh:"考试",en:"Exam",cls:"bg-rose-50 text-rose-700 border-rose-200 dark:bg-rose-950/40 dark:text-rose-300 dark:border-rose-800"},survey:{zh:"问卷",en:"Survey",cls:"bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950/40 dark:text-emerald-300 dark:border-emerald-800"}},te={draft:{zh:"草稿",en:"Draft",cls:"bg-surface-secondary text-muted border-theme"},published:{zh:"已发布",en:"Published",cls:"bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950/40 dark:text-emerald-300 dark:border-emerald-800"},closed:{zh:"已关闭",en:"Closed",cls:"bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-950/40 dark:text-amber-300 dark:border-amber-800"},archived:{zh:"已归档",en:"Archived",cls:"bg-surface-secondary text-muted border-theme"}};function Re(){const i=re()?.lang==="en"?"en":"zh",c=i==="zh",[t,h]=n.useState("papers"),[f,b]=n.useState(null),[y,x]=n.useState(!1),[o,v]=n.useState(null),[u,w]=n.useState(null),[C,A]=n.useState("all"),[g,j]=n.useState(!1),S=n.useCallback(async()=>{x(!0),v(null);try{const a=await k.list(C==="all"?{}:{kind:C});b(a.items)}catch(a){v(a instanceof U?a.message:String(a?.message??a))}finally{x(!1)}},[C]);n.useEffect(()=>{t==="papers"&&u===null&&S()},[t,u,S]);const $=n.useMemo(()=>[...f??[]].sort((N,P)=>P.updatedAt-N.updatedAt),[f]);return u?e.jsx(we,{assessmentId:u,lang:i,onBack:()=>{w(null),S()}}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-surface border border-theme rounded-2xl shadow-xl overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-theme bg-surface-secondary/70 flex flex-col lg:flex-row lg:items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h1",{className:"text-base font-bold text-main flex items-center gap-2",children:[e.jsx(Z,{size:18,className:"text-indigo-500"}),c?"测评中心":"Assessment Center"]}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:c?"组卷、发布到班级、批改与统计。测试 / 考试 / 问卷共用同一套题目与判分模型。":"Build papers, publish to classes, grade and analyse. Quizzes, exams and surveys share one item model."})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:"inline-flex p-1 bg-surface-secondary border border-theme rounded-xl text-xs font-semibold",children:[{id:"papers",label:c?"试卷":"Papers",icon:Z},{id:"bank",label:c?"题库":"Question bank",icon:ge}].map(a=>{const N=a.icon,P=t===a.id;return e.jsxs("button",{type:"button",onClick:()=>h(a.id),"aria-pressed":P,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg transition-colors cursor-pointer ${P?"bg-surface text-main shadow-3xs font-bold":"text-muted hover:text-main"}`,children:[e.jsx(N,{size:13}),a.label]},a.id)})}),e.jsxs("button",{type:"button",onClick:()=>void S(),disabled:y||t!=="papers",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl border border-theme bg-surface hover:bg-surface-secondary text-xs font-semibold text-main disabled:opacity-50 cursor-pointer",children:[e.jsx(Y,{size:13,className:y?"animate-spin":""}),c?"刷新":"Refresh"]}),t==="papers"&&e.jsxs("button",{type:"button",onClick:()=>j(!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 cursor-pointer",children:[e.jsx(G,{size:13}),c?"新建测评":"New assessment"]})]})]}),o&&e.jsxs("div",{role:"alert",className:"mx-6 mt-4 px-3 py-2 rounded-xl border border-rose-200 bg-rose-50 text-rose-700 text-xs flex items-center gap-2",children:[e.jsx(fe,{size:14}),o]}),t==="bank"?e.jsx(Ae,{lang:i}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-6 py-3 border-b border-theme flex flex-wrap items-center gap-2 shrink-0",children:[e.jsx("span",{className:"text-xs font-semibold text-muted",children:c?"类型筛选":"Filter by kind"}),["all","quiz","exam","survey"].map(a=>e.jsx("button",{type:"button",onClick:()=>A(a),"aria-pressed":C===a,className:`px-2.5 py-1 rounded-full text-xs font-semibold border cursor-pointer ${C===a?"bg-indigo-600 text-white border-indigo-600":"bg-surface text-muted border-theme hover:text-main"}`,children:a==="all"?c?"全部":"All":V[a]?.[c?"zh":"en"]??a},a))]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:f===null&&y?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted",children:[e.jsx(T,{size:16,className:"animate-spin"}),c?"正在加载试卷…":"Loading papers…"]}):$.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-16 text-center",children:[e.jsx(Z,{size:40,className:"text-muted opacity-40"}),e.jsx("p",{className:"text-sm font-semibold text-main",children:c?"还没有任何测评":"No assessments yet"}),e.jsx("p",{className:"text-xs text-muted max-w-sm",children:c?"新建一份测试、考试或问卷,组卷后发布到班级,学生就能在「我的测评」里作答。":"Create a quiz, exam or survey, add questions, then publish it to a class."}),e.jsxs("button",{type:"button",onClick:()=>j(!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 cursor-pointer",children:[e.jsx(G,{size:13}),c?"新建测评":"New assessment"]})]}):e.jsx("ul",{"data-testid":"assessment-list",className:"grid grid-cols-1 xl:grid-cols-2 gap-3 max-w-[1400px] mx-auto",children:$.map(a=>{const N=V[a.kind]??V.quiz,P=te[a.status]??te.draft;return e.jsxs("li",{"data-testid":`assessment-row-${a.id}`,className:"bg-surface border border-theme rounded-xl p-4 flex flex-col gap-2.5 hover:border-indigo-300 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-bold text-sm text-main truncate",title:a.title,children:a.title}),a.description&&e.jsx("p",{className:"text-xs text-muted mt-0.5 line-clamp-2",children:a.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx("span",{className:`px-2 py-0.5 rounded-full text-2xs font-bold border ${N.cls}`,children:N[c?"zh":"en"]}),e.jsx("span",{className:`px-2 py-0.5 rounded-full text-2xs font-semibold border ${P.cls}`,children:P[c?"zh":"en"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-2xs text-muted flex-wrap",children:[e.jsxs("span",{children:[a.itemCount," ",c?"题":"items"]}),e.jsxs("span",{children:[c?"满分":"Total"," ",a.totalScore]}),a.settings.anonymous&&e.jsxs("span",{children:["🔒 ",c?"匿名":"Anonymous"]}),a.settings.maxAttempts>1&&e.jsx("span",{children:c?`可作答 ${a.settings.maxAttempts} 次`:`${a.settings.maxAttempts} attempts`}),e.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[a.status==="draft"&&e.jsx("button",{type:"button",onClick:async()=>{if(window.confirm(c?`删除「${a.title}」?`:`Delete "${a.title}"?`))try{await k.remove(a.id),S()}catch(I){v(I?.message??String(I))}},"aria-label":c?`删除 ${a.title}`:`Delete ${a.title}`,className:"p-1 rounded-md text-muted hover:text-rose-500 hover:bg-rose-500/10 cursor-pointer",children:e.jsx(ee,{size:13})}),e.jsxs("button",{type:"button",onClick:()=>w(a.id),className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-lg border border-theme text-2xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:[a.status==="draft"?c?"继续编辑":"Edit":c?"查看与批改":"Open",e.jsx(ye,{size:12})]})]})]}),e.jsx(ae,{slot:"assessment.list.card",slotProps:{assessment:Ne(a),viewer:"teacher",lang:i},lang:i})]},a.id)})})})]}),g&&e.jsx(Ie,{lang:i,onClose:()=>j(!1),onCreated:a=>{j(!1),w(a)}})]})}function Ie({lang:l,onClose:i,onCreated:c}){const t=l==="zh",[h,f]=n.useState("quiz"),[b,y]=n.useState(""),[x,o]=n.useState(""),[v,u]=n.useState(!1),[w,C]=n.useState(null),A=async g=>{if(g.preventDefault(),!b.trim()){C(t?"请填写标题":"Title is required");return}u(!0),C(null);try{const j=await k.create({kind:h,title:b.trim(),description:x.trim()||null});c(j.id)}catch(j){C(j?.message??String(j))}finally{u(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"create-assessment-title",className:"w-full max-w-md bg-surface border border-theme rounded-2xl shadow-2xl p-5 space-y-4",children:[e.jsx("h2",{id:"create-assessment-title",className:"text-sm font-bold text-main",children:t?"新建测评":"New assessment"}),e.jsxs("form",{onSubmit:A,className:"space-y-3",children:[e.jsxs("fieldset",{children:[e.jsx("legend",{className:"text-xs font-semibold text-muted mb-1",children:t?"类型":"Kind"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["quiz","exam","survey"].map(g=>e.jsxs("label",{className:`flex flex-col items-center gap-1 px-2 py-2 rounded-xl border text-xs cursor-pointer ${h===g?"border-indigo-500 bg-indigo-50 text-indigo-700 dark:bg-indigo-950/40 dark:text-indigo-300":"border-theme text-muted hover:text-main"}`,children:[e.jsx("input",{type:"radio",name:"assessment-kind",value:g,checked:h===g,onChange:()=>f(g),className:"sr-only"}),e.jsx("span",{className:"font-bold",children:V[g][t?"zh":"en"]}),e.jsx("span",{className:"text-2xs text-center leading-snug",children:g==="quiz"?t?"计分,可多次作答":"Scored, retakes allowed":g==="exam"?t?"一次作答,发布成绩后可见":"Single attempt, released later":t?"不计分,可匿名":"Not scored, can be anonymous"})]},g))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"assessment-title",className:"block text-xs font-semibold text-muted mb-1",children:t?"标题":"Title"}),e.jsx("input",{id:"assessment-title",value:b,onChange:g=>y(g.target.value),className:"w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500",placeholder:t?"例如:第三单元小测":"e.g. Unit 3 quiz"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"assessment-description",className:"block text-xs font-semibold text-muted mb-1",children:t?"说明(可选)":"Description (optional)"}),e.jsx("textarea",{id:"assessment-description",value:x,onChange:g=>o(g.target.value),rows:2,className:"w-full px-2.5 py-1.5 border border-theme rounded-lg text-xs bg-surface text-main focus:outline-none focus:ring-1 focus:ring-indigo-500 resize-none"})]}),w&&e.jsx("p",{role:"alert",className:"text-xs text-rose-600",children:w}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:i,className:"px-3 py-1.5 rounded-xl border border-theme text-xs font-semibold text-main hover:bg-surface-secondary cursor-pointer",children:t?"取消":"Cancel"}),e.jsxs("button",{type:"submit",disabled:v,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-indigo-600 text-white text-xs font-bold hover:bg-indigo-700 disabled:opacity-50 cursor-pointer",children:[v&&e.jsx(T,{size:13,className:"animate-spin"}),t?"创建并开始组卷":"Create & build"]})]})]})]})})}export{Re as AssessmentCenter};
@@ -1,3 +1,3 @@
1
- import{r as d,j as e}from"./vendor-react-DHoBZpn2.js";import{aa as B,ab as k,d as M,p as w,z as E,ac as R,v,E as A,x as F,y as U}from"./index-XduPa2-x.js";import{D as P,J as _,X as I,c as X,T as H}from"./vendor-icons-DLOPlM4i.js";function $(r){return!r||r<0?"":r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/1024/1024).toFixed(1)} MB`}const V=({assignmentId:r,file:a,onClose:x,lang:j="zh"})=>{const i=j==="zh",[S,z]=d.useState(null),[p,y]=d.useState(null),[C,b]=d.useState(!1),l=a.original_name||a.name||"attachment",n=d.useMemo(()=>B({name:l}),[l]),N=`/api/assignments/${encodeURIComponent(r)}/files/${encodeURIComponent(a.id)}`,c=`${N}?disposition=inline`,f=N;d.useEffect(()=>{if(n.kind!=="text")return;let t=!1;return b(!0),y(null),fetch(c,{credentials:"same-origin"}).then(async s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.text();return o.length>k?`${o.slice(0,k)}
1
+ import{r as d,j as e}from"./vendor-react-DHoBZpn2.js";import{ab as B,ac as k,d as M,p as w,z as E,ad as R,v,E as A,x as F,y as U}from"./index-Bc9003lB.js";import{D as P,J as _,X as I,c as X,T as H}from"./vendor-icons-CaXLq01o.js";function $(r){return!r||r<0?"":r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/1024/1024).toFixed(1)} MB`}const V=({assignmentId:r,file:a,onClose:x,lang:j="zh"})=>{const i=j==="zh",[S,z]=d.useState(null),[p,y]=d.useState(null),[C,b]=d.useState(!1),l=a.original_name||a.name||"attachment",n=d.useMemo(()=>B({name:l}),[l]),N=`/api/assignments/${encodeURIComponent(r)}/files/${encodeURIComponent(a.id)}`,c=`${N}?disposition=inline`,f=N;d.useEffect(()=>{if(n.kind!=="text")return;let t=!1;return b(!0),y(null),fetch(c,{credentials:"same-origin"}).then(async s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);const o=await s.text();return o.length>k?`${o.slice(0,k)}
2
2
 
3
3
  …(内容过长,已截断)`:o}).then(s=>{t||z(s)}).catch(s=>{t||y(s?.message||"Failed to load preview")}).finally(()=>{t||b(!1)}),()=>{t=!0}},[c,n.kind]),d.useEffect(()=>{const t=s=>{s.key==="Escape"&&x()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[x]);const T=M(t=>t.extensionPoints),u=d.useMemo(()=>(T.get("assignment.file.preview")??[]).filter(s=>{const o=w(s.slotProps),m=E(o.extensions)??[];return R(m,n.extension)?!0:(E(o.mimeTypes)??[]).map(g=>g.toLowerCase()).includes(n.contentType)}),[T,n.extension,n.contentType]),L=async t=>{const s=u.find(g=>g.id===t);if(!s)return;const o=w(s.slotProps),m=v(o,"commandType");if(!m)return;const h=await F.post("/api/plugins/execute-command",{type:m,payload:{fileId:a.id,assignmentId:r,fileName:l,downloadUrl:f,inlineUrl:c}});h.success||U.getState().addToast({id:`file-preview-cmd-error-${Date.now()}`,type:"error",title:i?"插件预览命令执行失败":"Plugin preview command failed",message:h.error||m})},D=()=>n.kind==="image"?e.jsx("img",{src:c,alt:l,className:"max-h-[68vh] w-auto max-w-full mx-auto rounded-lg bg-white/60","data-testid":"assignment-file-preview-image"}):n.kind==="pdf"?e.jsx("iframe",{src:c,title:l,className:"w-full h-[68vh] rounded-lg border border-theme bg-white","data-testid":"assignment-file-preview-pdf"}):n.kind==="text"?C?e.jsxs("div",{className:"flex items-center justify-center h-[40vh] gap-2 text-sm text-muted",children:[e.jsx(X,{size:16,className:"animate-spin"}),i?"正在加载预览…":"Loading preview…"]}):p?e.jsxs("div",{className:"flex items-center justify-center h-[40vh] gap-2 text-sm text-red-600",children:[e.jsx(H,{size:16}),i?`预览失败:${p}`:`Preview failed: ${p}`]}):e.jsx("pre",{className:"w-full max-h-[68vh] overflow-auto rounded-lg bg-slate-900/90 p-3 text-xs leading-relaxed text-slate-100 whitespace-pre-wrap break-all","data-testid":"assignment-file-preview-text",children:S??""}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-[40vh] gap-3 text-center","data-testid":"assignment-file-preview-unsupported",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{className:"text-sm text-muted",children:i?`暂不支持预览 ${n.extension||"该"} 格式,可下载后查看`:`Preview for ${n.extension||"this"} format is not supported yet — download to view`}),u.length>0&&e.jsx("p",{className:"text-xs text-muted",children:i?"或使用插件提供的预览器:":"Or use a plugin previewer:"})]});return e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4",role:"dialog","aria-modal":"true","aria-label":l,"data-testid":"assignment-file-preview",onClick:t=>{t.target===t.currentTarget&&x()},children:e.jsxs("div",{className:"w-full max-w-4xl max-h-[88vh] flex flex-col rounded-xl bg-surface shadow-2xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-theme shrink-0",children:[e.jsx(P,{size:16,className:"text-muted shrink-0"}),e.jsx("span",{className:"flex-1 truncate text-sm font-medium text-main",children:l}),$(a.size)&&e.jsx("span",{className:"text-xs text-muted shrink-0",children:$(a.size)}),e.jsxs("a",{href:f,className:"flex items-center gap-1 rounded-lg border border-theme px-2 py-1 text-xs text-main hover:border-orange-300 shrink-0",title:i?"下载":"Download",children:[e.jsx(_,{size:13}),i?"下载":"Download"]}),e.jsx("button",{onClick:x,className:"rounded-lg p-1 text-muted hover:text-main shrink-0",title:i?"关闭":"Close","aria-label":i?"关闭":"Close",children:e.jsx(I,{size:16})})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto p-4",children:D()}),u.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-theme px-4 py-2 shrink-0",children:[e.jsx("span",{className:"text-xs text-muted",children:i?"插件预览器:":"Plugin previewers:"}),u.map(t=>{const s=w(t.slotProps);return v(s,"commandType")?e.jsx("button",{onClick:()=>void L(t.id),className:"rounded-lg border border-theme px-2 py-1 text-xs text-main hover:border-orange-300","data-testid":"assignment-file-preview-plugin",children:t.label||v(s,"title")||t.id},`${t.pluginId}/${t.id}`):null}),e.jsx(A,{slot:"assignment.file.preview",slotProps:{file:{id:a.id,name:l,size:a.size??null,mime:a.mime??null},fileExtension:n.extension,assignmentId:r,downloadUrl:f,inlineUrl:c,lang:j}})]})]})})};export{V as A};