openlearn-next 0.7.10 → 0.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/assets/{ActivityWorkspaceWidget-BU88GGUG.js → ActivityWorkspaceWidget-9DeXkxGk.js} +1 -1
- package/dist/assets/AdminDirectoryView-5gupeGAR.js +5 -0
- package/dist/assets/{AssessmentCenter-BoSWbJMt.js → AssessmentCenter-CPaqy0Xa.js} +1 -1
- package/dist/assets/{AssignmentFilePreview-D_POvLmv.js → AssignmentFilePreview-7fHtUuUL.js} +2 -2
- package/dist/assets/{BatchPickerModal-DiHd_6Tg.js → BatchPickerModal-0yIe1DXi.js} +1 -1
- package/dist/assets/{ClassesView-CWKqzWH0.js → ClassesView-CGpoW0IC.js} +5 -5
- package/dist/assets/{ClassroomCountdownWidget-B5-KUVU8.js → ClassroomCountdownWidget-B_5--dn_.js} +1 -1
- package/dist/assets/{CloudDriveModal-CjcvdDiw.js → CloudDriveModal-4Ts5Duh5.js} +1 -1
- package/dist/assets/{ComputerLabView-CNTcmWAh.js → ComputerLabView-DAEaKTBj.js} +1 -1
- package/dist/assets/{CourseManagement-ha_iSnLU.js → CourseManagement-CxIBH7lA.js} +1 -1
- package/dist/assets/{CourseWizardModal-oVT9mYSG.js → CourseWizardModal-R0xpa_Aw.js} +1 -1
- package/dist/assets/{CoursewareHubPanel-BuKp0mmW.js → CoursewareHubPanel-CpHptmSa.js} +1 -1
- package/dist/assets/{Dashboard-Vb9coh9_.js → Dashboard-DeBfP_Nc.js} +2 -2
- package/dist/assets/{ExportWeightModal-BEesz6rd.js → ExportWeightModal-DlnCOBlL.js} +1 -1
- package/dist/assets/{HelpTour-D3QcGDUz.js → HelpTour-Cztpqw_J.js} +1 -1
- package/dist/assets/{HelpView--Um9DFYx.js → HelpView-LPLAY9bq.js} +2 -2
- package/dist/assets/{ImportLessonsModal-DXGopj4j.js → ImportLessonsModal-BopEHmU_.js} +1 -1
- package/dist/assets/ImportModal-CYU3aMYY.js +3 -0
- package/dist/assets/{InteractiveCoursewareViewer-DzgF9_LU.js → InteractiveCoursewareViewer-CGc3P4HF.js} +1 -1
- package/dist/assets/InteractiveWhiteboard-DiyHrIGn.js +19 -0
- package/dist/assets/{LazyCourseware-6yb_QiYS.js → LazyCourseware-Bj1jm0nC.js} +2 -2
- package/dist/assets/LazyWhiteboard-NPD1EoyO.js +2 -0
- package/dist/assets/LessonEditorView-DqreBtFx.js +1 -0
- package/dist/assets/LiveClassroomView-eTc6Fb9g.js +64 -0
- package/dist/assets/{NotificationDetailModal-mUeIQP4R.js → NotificationDetailModal-B7G7ra9a.js} +1 -1
- package/dist/assets/{PluginView-CT3-zS2n.js → PluginView-DP6s-L70.js} +1 -1
- package/dist/assets/{ProcessLogsModal-DmsOrZnV.js → ProcessLogsModal-Dq5C4s7j.js} +1 -1
- package/dist/assets/{QuizGeneratorModal-ViKxNX5Q.js → QuizGeneratorModal-CoX9f8Wp.js} +1 -1
- package/dist/assets/RevealPresentationWrapper-wwlcfNWB.js +48 -0
- package/dist/assets/{StudentAssignmentEvalPanel-BRxHMABY.js → StudentAssignmentEvalPanel-DHb-asHQ.js} +1 -1
- package/dist/assets/{StudentAssignmentView-g-ewJIS3.js → StudentAssignmentView-AJpjQK3f.js} +1 -1
- package/dist/assets/{StudentLessonView-Dbvr3Xlo.js → StudentLessonView-Djd1T1QF.js} +1 -1
- package/dist/assets/{StudentView-20vfEk4v.js → StudentView-D41z7GY5.js} +2 -2
- package/dist/assets/{SystemResourceLibraryModal-CDKeaKf8.js → SystemResourceLibraryModal-CxmQh1HA.js} +1 -1
- package/dist/assets/TeacherView-DqSWaNuI.js +2 -0
- package/dist/assets/TimetableView-DrFs_xgc.js +6 -0
- package/dist/assets/{UTIF-BtQhea94.js → UTIF-u3Ct70K4.js} +1 -1
- package/dist/assets/index-7CK1B0tE.js +131 -0
- package/dist/assets/index-BaGZmpr6.css +1 -0
- package/dist/assets/{index.es-CijVATXs.js → index.es-CcQ2kcDj.js} +1 -1
- package/dist/assets/pluginParsers-BN3lQ7PJ.js +1 -0
- package/dist/assets/{student-workspace-DstiW0pM.js → student-workspace-DkTkcAGK.js} +1 -1
- package/dist/assets/{vendor-icons-DLOPlM4i.js → vendor-icons-CqLdl4B_.js} +1 -1
- package/dist/assets/{vendor-pdf-DVWGghIL.js → vendor-pdf-BMEc_Clb.js} +3 -3
- package/dist/assets/{vendor-pptx-BqU7v5zS.js → vendor-pptx-C0qaOH5T.js} +178 -178
- package/dist/index.html +3 -3
- package/dist/server.cjs +1666 -1846
- package/migrations/045_ai_providers_owner_and_scope.sql +20 -0
- package/migrations/README.md +1 -0
- package/migrations/schema-golden.json +13 -3
- package/package.json +5 -2
- package/dist/assets/AdminDirectoryView-Cdsk9Mdr.js +0 -5
- package/dist/assets/ImportModal-h5ShIMzO.js +0 -2
- package/dist/assets/InteractiveWhiteboard-DJqgP_tU.js +0 -65
- package/dist/assets/LazyWhiteboard-CsF9GB6J.js +0 -2
- package/dist/assets/LessonEditorView-CZTZ7Q0B.js +0 -1
- package/dist/assets/LiveClassroomView-D2ugupT9.js +0 -61
- package/dist/assets/TeacherView-KIKuhXGF.js +0 -2
- package/dist/assets/TimetableView-7V2AwWml.js +0 -6
- package/dist/assets/index-C4cHQZyx.css +0 -1
- package/dist/assets/index-XduPa2-x.js +0 -131
- package/dist/assets/pluginParsers-BO6U1E-h.js +0 -1
- package/dist/assets/vendor-reveal-DcQQzuI9.css +0 -1
package/dist/assets/{NotificationDetailModal-mUeIQP4R.js → NotificationDetailModal-B7G7ra9a.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-react-DHoBZpn2.js";import{m as n}from"./index-
|
|
1
|
+
import{j as e}from"./vendor-react-DHoBZpn2.js";import{m as n}from"./index-7CK1B0tE.js";import{a7 as d,h as o,a4 as l,aT as i}from"./vendor-icons-CqLdl4B_.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-BMEc_Clb.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-skggaP9D.js";function y({notification:s,onClose:t,lang:r,onOpenWorkspace:a}){return s?e.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50",children:e.jsxs(n.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-xl flex flex-col overflow-hidden max-h-[85vh] font-sans",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(d,{className:"text-indigo-600 font-sans shrink-0",size:20}),e.jsx("h2",{className:"font-bold text-gray-800 text-base font-sans truncate",children:s.title})]}),e.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 font-bold p-1 hover:bg-gray-200 rounded transition-colors text-lg",children:"×"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:[e.jsx("div",{className:"p-4 bg-indigo-50/50 rounded-xl border border-indigo-100 text-sm text-gray-700 leading-relaxed font-sans",children:s.message}),s.assignment&&e.jsxs("div",{className:"space-y-4 font-sans",children:[e.jsxs("div",{className:"border border-gray-150 rounded-xl p-4 bg-gray-50/50 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-gray-400 uppercase tracking-wider font-semibold font-sans",children:r==="zh"?"关联作业":"Associated Assignment"}),s.assignment.submission_status==="graded"&&e.jsx("span",{className:"bg-green-100 border border-green-200 text-green-800 text-xs font-bold px-2.5 py-1 rounded-full shadow-sm font-mono",children:r==="zh"?`得分:${s.assignment.score}%`:`Score: ${s.assignment.score}%`})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-base text-indigo-900 font-sans",children:s.assignment.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:s.assignment.class_name})]}),s.assignment.feedback&&e.jsxs("div",{className:"mt-3 bg-white p-3 rounded-lg border border-gray-150 space-y-1 font-sans",children:[e.jsxs("div",{className:"text-xs font-bold text-green-700 flex items-center justify-between gap-2 font-sans",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(o,{size:14,className:"font-sans"}),e.jsx("span",{children:r==="zh"?"教师评审意见与反馈":"Teacher Feedback & Recommendations"})]}),s.assignment.graded_at&&e.jsxs("div",{className:"text-xs text-gray-400 font-mono flex items-center gap-1 font-normal select-none",children:[e.jsx(l,{size:11,className:"text-neutral-400"}),e.jsx("span",{children:new Date(s.assignment.graded_at).toLocaleString(r==="zh"?"zh-CN":"en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]})]}),e.jsx("div",{className:"text-xs text-gray-600 italic bg-green-50/30 p-2 rounded border border-green-50 mt-1 leading-relaxed whitespace-pre-wrap font-sans",children:s.assignment.feedback})]})]}),s.assignment.submission_content&&e.jsxs("div",{className:"space-y-1.5 font-sans",children:[e.jsx("div",{className:"text-xs text-gray-400 font-bold uppercase tracking-wider font-sans",children:r==="zh"?"我提交的内容":"My Submission Content"}),e.jsx("div",{className:"bg-gray-900 text-gray-100 p-4 rounded-xl border border-gray-800 overflow-x-auto max-h-40 overflow-y-auto text-xs font-mono leading-relaxed whitespace-pre-wrap",children:s.assignment.submission_content})]})]})]}),e.jsxs("div",{className:"p-4 border-t border-gray-100 bg-gray-50/85 flex justify-end gap-2.5 shrink-0 font-sans",children:[e.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-xs font-semibold border border-gray-200 text-gray-700 bg-white rounded-lg hover:bg-gray-100 transition-colors cursor-pointer",children:r==="zh"?"关闭":"Close"}),s.assignment&&e.jsxs("button",{type:"button",onClick:()=>a(s.assignment),className:"px-4 py-2 text-xs font-bold bg-indigo-600 text-white border border-indigo-700 rounded-lg hover:bg-indigo-700 hover:shadow shadow-sm transition-all cursor-pointer flex items-center gap-1.5 font-sans",children:[e.jsx(i,{size:14,className:"font-sans"}),r==="zh"?"打开画布 / 查看详情":"Open Workspace Canvas"]})]})]})}):null}export{y as NotificationDetailModal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as J,j as e,c as Re,g as ot,R as _e}from"./vendor-react-DHoBZpn2.js";import{c as ye,ar as lt,bh as dt,af as Oe,T as ze,an as ct,bW as ht,bx as Le,X as Ie,ah as ut,S as We,V as He,aT as ft,aC as mt,k as Ke,a8 as pt,ba as xt,U as gt,bX as Ge,aD as bt,R as Ce,bY as yt,D as vt,ac as Ve,bZ as Me,a$ as wt,aX as jt,b_ as _t,J as Ue,t as kt,E as nt,h as Pe,b as Be,au as Nt,P as at,as as qe,bq as zt,b$ as St,av as Ct}from"./vendor-icons-DLOPlM4i.js";import{c as De}from"./vendor-pptx-BqU7v5zS.js";import{d as Ye,s as Ne,c as It}from"./index-XduPa2-x.js";import{p as Et}from"./pluginParsers-BO6U1E-h.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-DVWGghIL.js";import"./vendor-charts-skggaP9D.js";import"./vendor-motion-BFAPOs-b.js";function At({pluginId:R,lang:C}){const a=C==="zh",N=(k,w)=>a?k:w,[d,l]=J.useState(null),[u,n]=J.useState(!0),[f,x]=J.useState(!1),[_,y]=J.useState(null),[j,i]=J.useState(null),g=`/api/plugins/${encodeURIComponent(R)}/network-grants`,o=J.useCallback(async()=>{n(!0);try{const k=await fetch(g);if(k.status===403||k.status===404){x(!0);return}const w=await k.json().catch(()=>({}));if(!k.ok||w?.success===!1){x(!0);return}l({proposed:Array.isArray(w.proposed)?w.proposed:[],approved:Array.isArray(w.approved)?w.approved:[],rejected:Array.isArray(w.rejected)?w.rejected:[]}),x(!1)}catch{x(!0)}finally{n(!1)}},[g]);J.useEffect(()=>{o()},[o]);const p=J.useCallback(async k=>{y(k),i(null);try{const w=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hosts:[k]})}),E=await w.json().catch(()=>({}));(!w.ok||E?.success!==!0)&&i(E?.error||N("批准失败","Approval failed"))}catch(w){i(w?.message||N("批准失败","Approval failed"))}finally{y(null),await o()}},[g,o,N]),s=J.useCallback(async k=>{y(k),i(null);try{const w=await fetch(`${g}?host=${encodeURIComponent(k)}`,{method:"DELETE"}),E=await w.json().catch(()=>({}));(!w.ok||E?.success!==!0)&&i(E?.error||N("撤销失败","Revoke failed"))}catch(w){i(w?.message||N("撤销失败","Revoke failed"))}finally{y(null),await o()}},[g,o,N]),c=d&&(d.approved.length>0||d.proposed.length>0||d.rejected.length>0);if(f||!u&&!c)return null;if(u)return e.jsxs("div",{className:"py-4 flex items-center gap-2 text-xs text-gray-400","data-testid":"network-grants-loading",children:[e.jsx(ye,{size:14,className:"animate-spin"}),N("正在读取出站域名授权…","Loading outbound grants…")]});const v=(d?.proposed??[]).filter(k=>!(d?.approved??[]).includes(k));return e.jsxs("div",{className:"pt-4 mt-2 border-t border-gray-100","data-testid":"network-grants-panel",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(lt,{size:15,className:"text-gray-500"}),e.jsx("h4",{className:"text-sm font-medium text-gray-700",children:N("出站网络域名","Outbound network hosts")}),e.jsxs("span",{className:"text-[10px] font-mono text-gray-400 bg-gray-50 border border-gray-200 rounded px-1.5 py-0.5",children:[d?.approved.length??0," ",N("已批准","approved")]})]}),e.jsx("p",{className:"text-xs text-gray-400 mb-3 leading-relaxed",children:N("清单声明的域名只是申请,只有「已批准」的才会被运行时放行。回环、私有与保留地址永远不会被批准。","Hosts declared in the manifest are requests only; the runtime allows just the approved ones. Loopback, private and reserved addresses are never granted.")}),j&&e.jsx("div",{className:"mb-2 text-xs text-rose-600 bg-rose-50 border border-rose-100 rounded-lg px-2.5 py-1.5",role:"alert",children:j}),e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"text-[11px] font-bold text-emerald-700 mb-1.5 flex items-center gap-1",children:[e.jsx(dt,{size:12}),N("已批准(运行时放行)","Approved (allowed at runtime)")]}),d&&d.approved.length>0?e.jsx("ul",{className:"space-y-1",children:d.approved.map(k=>e.jsxs("li",{className:"flex items-center justify-between gap-2 bg-emerald-50/60 border border-emerald-100 rounded-lg px-2.5 py-1.5",children:[e.jsx("code",{className:"text-xs text-emerald-900 font-mono truncate",children:k}),e.jsxs("button",{type:"button",onClick:()=>void s(k),disabled:_===k,"data-testid":`revoke-${k}`,className:"text-[11px] font-bold text-rose-600 hover:text-rose-700 flex items-center gap-1 disabled:opacity-40 cursor-pointer",children:[_===k?e.jsx(ye,{size:11,className:"animate-spin"}):e.jsx(Oe,{size:11}),N("撤销","Revoke")]})]},k))}):e.jsx("p",{className:"text-xs text-gray-400 italic","data-testid":"no-approved",children:N("尚未批准任何域名 —— 该插件无法发起出站请求。","No host approved yet — this plugin cannot make outbound requests.")})]}),v.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"text-[11px] font-bold text-amber-700 mb-1.5 flex items-center gap-1",children:[e.jsx(ze,{size:12}),N("清单申请中(未生效)","Requested by manifest (not active)")]}),e.jsx("ul",{className:"space-y-1",children:v.map(k=>e.jsxs("li",{className:"flex items-center justify-between gap-2 bg-amber-50/60 border border-amber-100 rounded-lg px-2.5 py-1.5",children:[e.jsx("code",{className:"text-xs text-amber-900 font-mono truncate",children:k}),e.jsxs("button",{type:"button",onClick:()=>void p(k),disabled:_===k,"data-testid":`approve-${k}`,className:"text-[11px] font-bold text-indigo-600 hover:text-indigo-700 flex items-center gap-1 disabled:opacity-40 cursor-pointer",children:[_===k?e.jsx(ye,{size:11,className:"animate-spin"}):e.jsx(ct,{size:11}),N("批准","Approve")]})]},k))})]}),d&&d.rejected.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-[11px] font-bold text-rose-700 mb-1.5 flex items-center gap-1",children:[e.jsx(ht,{size:12}),N("不可批准","Not approvable")]}),e.jsx("ul",{className:"space-y-1","data-testid":"rejected-hosts",children:d.rejected.map(k=>e.jsxs("li",{className:"text-xs text-gray-500 leading-relaxed",children:[e.jsx("code",{className:"font-mono text-rose-700 line-through",children:k.host}),k.reason?e.jsxs("span",{className:"ml-1.5 text-gray-400",children:["— ",k.reason]}):null]},`${k.host}-${k.reason??""}`))})]})]})}function Pt({pluginId:R,pluginName:C,manifestStr:a,lang:N,onClose:d}){const[l,u]=J.useState(null),[n,f]=J.useState({}),[x,_]=J.useState(!0),[y,j]=J.useState(!1),[i,g]=J.useState(null),o=J.useCallback(async()=>{_(!0);try{const w=await fetch(`/api/plugins/${encodeURIComponent(R)}/config`);if(w.ok){const E=await w.json();if(E.success){u(E.result.schema),f(E.result.values);return}}}catch{}try{const E=JSON.parse(a).configuration?.properties??{};u(E);const A={};for(const[L,T]of Object.entries(E))A[L]=T.default;f(A)}catch{u({})}_(!1)},[R,a]);J.useEffect(()=>{o().finally(()=>_(!1))},[o]);const p=async()=>{j(!0),g(null);try{const E=await(await fetch(`/api/plugins/${encodeURIComponent(R)}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).json();E.success?g(N==="zh"?"✓ 已保存":"✓ Saved"):g(`✗ ${E.error}`)}catch(w){g(`✗ ${w.message}`)}j(!1)},s=(w,E)=>{f(A=>({...A,[w]:E})),g(null)},c=(w,E)=>N==="zh"?w:E,v=(w,E)=>{const A=n[w],L=E.description??"";switch(E.type){case"boolean":return e.jsxs("div",{className:"flex items-center justify-between py-2.5 border-b border-gray-100",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700",children:w}),L&&e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:L})]}),e.jsx("button",{type:"button",onClick:()=>s(w,!A),className:`relative w-10 h-5 rounded-full transition-colors ${A?"bg-indigo-600":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${A?"translate-x-5":"translate-x-0.5"}`})})]},w);case"number":case"integer":return e.jsxs("div",{className:"py-2.5 border-b border-gray-100",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1",children:w}),L&&e.jsx("p",{className:"text-xs text-gray-400 mb-1.5",children:L}),e.jsx("input",{type:"number",step:E.type==="integer"?1:"any",min:E.minimum,max:E.maximum,value:A!=null?String(A):"",onChange:T=>{const H=T.target.value===""?void 0:Number(T.target.value);s(w,H)},className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-indigo-200 focus:border-indigo-400 outline-none",placeholder:E.default!==void 0?String(E.default):""})]},w);default:return E.enum&&E.enum.length>0?e.jsxs("div",{className:"py-2.5 border-b border-gray-100",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1",children:w}),L&&e.jsx("p",{className:"text-xs text-gray-400 mb-1.5",children:L}),e.jsx("select",{value:String(A??E.default??""),onChange:T=>s(w,T.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-indigo-200 focus:border-indigo-400 outline-none bg-white",children:E.enum.map(T=>e.jsx("option",{value:String(T),children:String(T)},String(T)))})]},w):e.jsxs("div",{className:"py-2.5 border-b border-gray-100",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1",children:w}),L&&e.jsx("p",{className:"text-xs text-gray-400 mb-1.5",children:L}),e.jsx("input",{type:"text",value:A!=null?String(A):"",onChange:T=>s(w,T.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-indigo-200 focus:border-indigo-400 outline-none",placeholder:E.default!==void 0?String(E.default):""})]},w)}},k=l&&Object.keys(l).length>0;return e.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center z-50 p-4",onClick:d,children:e.jsxs("div",{className:"bg-white rounded-xl shadow-xl w-full max-w-md flex flex-col max-h-[85vh]",onClick:w=>w.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{size:18,className:"text-gray-500"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 text-sm",children:c("插件设置","Plugin Settings")}),e.jsx("p",{className:"text-xs text-gray-400",children:C})]})]}),e.jsx("button",{onClick:d,className:"text-gray-400 hover:text-gray-600 p-1",children:e.jsx(Ie,{size:18})})]}),e.jsxs("div",{className:"p-4 flex-1 overflow-auto",children:[x?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ye,{size:24,className:"text-gray-400 animate-spin"})}):k?e.jsx("div",{className:"space-y-0.5",children:Object.entries(l).map(([w,E])=>v(w,E))}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Le,{size:32,className:"text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-gray-400",children:c("此插件没有可配置项。","This plugin has no configurable settings.")}),e.jsx("p",{className:"text-xs text-gray-300 mt-1",children:c("在 manifest.configuration 中声明配置项即可在此处显示。","Declare settings in manifest.configuration to see them here.")})]}),e.jsx(At,{pluginId:R,lang:N})]}),k&&e.jsxs("div",{className:"p-4 border-t border-gray-100 flex items-center justify-between",children:[i&&e.jsx("span",{className:`text-xs ${i.startsWith("✓")?"text-green-600":"text-red-500"}`,children:i}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsx("button",{onClick:d,className:"px-4 py-2 text-xs font-medium text-gray-600 hover:bg-gray-50 rounded-lg transition-colors",children:c("取消","Cancel")}),e.jsxs("button",{onClick:p,disabled:y,className:"px-4 py-2 text-xs font-medium bg-indigo-600 text-white hover:bg-indigo-700 rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-50",children:[y?e.jsx(ye,{size:14,className:"animate-spin"}):e.jsx(ut,{size:14}),c("保存","Save")]})]})]})]})})}var Fe={exports:{}};/*!
|
|
1
|
+
import{r as J,j as e,c as Re,g as ot,R as _e}from"./vendor-react-DHoBZpn2.js";import{c as ye,ar as lt,au as dt,af as Oe,T as ze,an as ct,bW as ht,bx as Le,X as Ie,ah as ut,S as We,V as He,aW as ft,aF as mt,k as Ke,a8 as pt,at as xt,U as gt,bX as Ge,aG as bt,R as Ce,bY as yt,D as vt,ac as Ve,bZ as Me,b2 as wt,a$ as jt,b_ as _t,J as Ue,t as kt,E as nt,h as Pe,b as Be,ax as Nt,P as at,as as qe,bq as zt,b$ as St,ay as Ct}from"./vendor-icons-CqLdl4B_.js";import{c as De}from"./vendor-pptx-C0qaOH5T.js";import{d as Ye,s as Ne,c as It}from"./index-7CK1B0tE.js";import{p as Et}from"./pluginParsers-BN3lQ7PJ.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-BMEc_Clb.js";import"./vendor-charts-skggaP9D.js";import"./vendor-motion-BFAPOs-b.js";function At({pluginId:R,lang:C}){const a=C==="zh",N=(k,w)=>a?k:w,[d,l]=J.useState(null),[u,n]=J.useState(!0),[f,x]=J.useState(!1),[_,y]=J.useState(null),[j,i]=J.useState(null),g=`/api/plugins/${encodeURIComponent(R)}/network-grants`,o=J.useCallback(async()=>{n(!0);try{const k=await fetch(g);if(k.status===403||k.status===404){x(!0);return}const w=await k.json().catch(()=>({}));if(!k.ok||w?.success===!1){x(!0);return}l({proposed:Array.isArray(w.proposed)?w.proposed:[],approved:Array.isArray(w.approved)?w.approved:[],rejected:Array.isArray(w.rejected)?w.rejected:[]}),x(!1)}catch{x(!0)}finally{n(!1)}},[g]);J.useEffect(()=>{o()},[o]);const p=J.useCallback(async k=>{y(k),i(null);try{const w=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hosts:[k]})}),E=await w.json().catch(()=>({}));(!w.ok||E?.success!==!0)&&i(E?.error||N("批准失败","Approval failed"))}catch(w){i(w?.message||N("批准失败","Approval failed"))}finally{y(null),await o()}},[g,o,N]),s=J.useCallback(async k=>{y(k),i(null);try{const w=await fetch(`${g}?host=${encodeURIComponent(k)}`,{method:"DELETE"}),E=await w.json().catch(()=>({}));(!w.ok||E?.success!==!0)&&i(E?.error||N("撤销失败","Revoke failed"))}catch(w){i(w?.message||N("撤销失败","Revoke failed"))}finally{y(null),await o()}},[g,o,N]),c=d&&(d.approved.length>0||d.proposed.length>0||d.rejected.length>0);if(f||!u&&!c)return null;if(u)return e.jsxs("div",{className:"py-4 flex items-center gap-2 text-xs text-gray-400","data-testid":"network-grants-loading",children:[e.jsx(ye,{size:14,className:"animate-spin"}),N("正在读取出站域名授权…","Loading outbound grants…")]});const v=(d?.proposed??[]).filter(k=>!(d?.approved??[]).includes(k));return e.jsxs("div",{className:"pt-4 mt-2 border-t border-gray-100","data-testid":"network-grants-panel",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(lt,{size:15,className:"text-gray-500"}),e.jsx("h4",{className:"text-sm font-medium text-gray-700",children:N("出站网络域名","Outbound network hosts")}),e.jsxs("span",{className:"text-[10px] font-mono text-gray-400 bg-gray-50 border border-gray-200 rounded px-1.5 py-0.5",children:[d?.approved.length??0," ",N("已批准","approved")]})]}),e.jsx("p",{className:"text-xs text-gray-400 mb-3 leading-relaxed",children:N("清单声明的域名只是申请,只有「已批准」的才会被运行时放行。回环、私有与保留地址永远不会被批准。","Hosts declared in the manifest are requests only; the runtime allows just the approved ones. Loopback, private and reserved addresses are never granted.")}),j&&e.jsx("div",{className:"mb-2 text-xs text-rose-600 bg-rose-50 border border-rose-100 rounded-lg px-2.5 py-1.5",role:"alert",children:j}),e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"text-[11px] font-bold text-emerald-700 mb-1.5 flex items-center gap-1",children:[e.jsx(dt,{size:12}),N("已批准(运行时放行)","Approved (allowed at runtime)")]}),d&&d.approved.length>0?e.jsx("ul",{className:"space-y-1",children:d.approved.map(k=>e.jsxs("li",{className:"flex items-center justify-between gap-2 bg-emerald-50/60 border border-emerald-100 rounded-lg px-2.5 py-1.5",children:[e.jsx("code",{className:"text-xs text-emerald-900 font-mono truncate",children:k}),e.jsxs("button",{type:"button",onClick:()=>void s(k),disabled:_===k,"data-testid":`revoke-${k}`,className:"text-[11px] font-bold text-rose-600 hover:text-rose-700 flex items-center gap-1 disabled:opacity-40 cursor-pointer",children:[_===k?e.jsx(ye,{size:11,className:"animate-spin"}):e.jsx(Oe,{size:11}),N("撤销","Revoke")]})]},k))}):e.jsx("p",{className:"text-xs text-gray-400 italic","data-testid":"no-approved",children:N("尚未批准任何域名 —— 该插件无法发起出站请求。","No host approved yet — this plugin cannot make outbound requests.")})]}),v.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"text-[11px] font-bold text-amber-700 mb-1.5 flex items-center gap-1",children:[e.jsx(ze,{size:12}),N("清单申请中(未生效)","Requested by manifest (not active)")]}),e.jsx("ul",{className:"space-y-1",children:v.map(k=>e.jsxs("li",{className:"flex items-center justify-between gap-2 bg-amber-50/60 border border-amber-100 rounded-lg px-2.5 py-1.5",children:[e.jsx("code",{className:"text-xs text-amber-900 font-mono truncate",children:k}),e.jsxs("button",{type:"button",onClick:()=>void p(k),disabled:_===k,"data-testid":`approve-${k}`,className:"text-[11px] font-bold text-indigo-600 hover:text-indigo-700 flex items-center gap-1 disabled:opacity-40 cursor-pointer",children:[_===k?e.jsx(ye,{size:11,className:"animate-spin"}):e.jsx(ct,{size:11}),N("批准","Approve")]})]},k))})]}),d&&d.rejected.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-[11px] font-bold text-rose-700 mb-1.5 flex items-center gap-1",children:[e.jsx(ht,{size:12}),N("不可批准","Not approvable")]}),e.jsx("ul",{className:"space-y-1","data-testid":"rejected-hosts",children:d.rejected.map(k=>e.jsxs("li",{className:"text-xs text-gray-500 leading-relaxed",children:[e.jsx("code",{className:"font-mono text-rose-700 line-through",children:k.host}),k.reason?e.jsxs("span",{className:"ml-1.5 text-gray-400",children:["— ",k.reason]}):null]},`${k.host}-${k.reason??""}`))})]})]})}function Pt({pluginId:R,pluginName:C,manifestStr:a,lang:N,onClose:d}){const[l,u]=J.useState(null),[n,f]=J.useState({}),[x,_]=J.useState(!0),[y,j]=J.useState(!1),[i,g]=J.useState(null),o=J.useCallback(async()=>{_(!0);try{const w=await fetch(`/api/plugins/${encodeURIComponent(R)}/config`);if(w.ok){const E=await w.json();if(E.success){u(E.result.schema),f(E.result.values);return}}}catch{}try{const E=JSON.parse(a).configuration?.properties??{};u(E);const A={};for(const[L,T]of Object.entries(E))A[L]=T.default;f(A)}catch{u({})}_(!1)},[R,a]);J.useEffect(()=>{o().finally(()=>_(!1))},[o]);const p=async()=>{j(!0),g(null);try{const E=await(await fetch(`/api/plugins/${encodeURIComponent(R)}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).json();E.success?g(N==="zh"?"✓ 已保存":"✓ Saved"):g(`✗ ${E.error}`)}catch(w){g(`✗ ${w.message}`)}j(!1)},s=(w,E)=>{f(A=>({...A,[w]:E})),g(null)},c=(w,E)=>N==="zh"?w:E,v=(w,E)=>{const A=n[w],L=E.description??"";switch(E.type){case"boolean":return e.jsxs("div",{className:"flex items-center justify-between py-2.5 border-b border-gray-100",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700",children:w}),L&&e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:L})]}),e.jsx("button",{type:"button",onClick:()=>s(w,!A),className:`relative w-10 h-5 rounded-full transition-colors ${A?"bg-indigo-600":"bg-gray-300"}`,children:e.jsx("span",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${A?"translate-x-5":"translate-x-0.5"}`})})]},w);case"number":case"integer":return e.jsxs("div",{className:"py-2.5 border-b border-gray-100",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1",children:w}),L&&e.jsx("p",{className:"text-xs text-gray-400 mb-1.5",children:L}),e.jsx("input",{type:"number",step:E.type==="integer"?1:"any",min:E.minimum,max:E.maximum,value:A!=null?String(A):"",onChange:T=>{const H=T.target.value===""?void 0:Number(T.target.value);s(w,H)},className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-indigo-200 focus:border-indigo-400 outline-none",placeholder:E.default!==void 0?String(E.default):""})]},w);default:return E.enum&&E.enum.length>0?e.jsxs("div",{className:"py-2.5 border-b border-gray-100",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1",children:w}),L&&e.jsx("p",{className:"text-xs text-gray-400 mb-1.5",children:L}),e.jsx("select",{value:String(A??E.default??""),onChange:T=>s(w,T.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-indigo-200 focus:border-indigo-400 outline-none bg-white",children:E.enum.map(T=>e.jsx("option",{value:String(T),children:String(T)},String(T)))})]},w):e.jsxs("div",{className:"py-2.5 border-b border-gray-100",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1",children:w}),L&&e.jsx("p",{className:"text-xs text-gray-400 mb-1.5",children:L}),e.jsx("input",{type:"text",value:A!=null?String(A):"",onChange:T=>s(w,T.target.value),className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:ring-2 focus:ring-indigo-200 focus:border-indigo-400 outline-none",placeholder:E.default!==void 0?String(E.default):""})]},w)}},k=l&&Object.keys(l).length>0;return e.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center z-50 p-4",onClick:d,children:e.jsxs("div",{className:"bg-white rounded-xl shadow-xl w-full max-w-md flex flex-col max-h-[85vh]",onClick:w=>w.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{size:18,className:"text-gray-500"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 text-sm",children:c("插件设置","Plugin Settings")}),e.jsx("p",{className:"text-xs text-gray-400",children:C})]})]}),e.jsx("button",{onClick:d,className:"text-gray-400 hover:text-gray-600 p-1",children:e.jsx(Ie,{size:18})})]}),e.jsxs("div",{className:"p-4 flex-1 overflow-auto",children:[x?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ye,{size:24,className:"text-gray-400 animate-spin"})}):k?e.jsx("div",{className:"space-y-0.5",children:Object.entries(l).map(([w,E])=>v(w,E))}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Le,{size:32,className:"text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-gray-400",children:c("此插件没有可配置项。","This plugin has no configurable settings.")}),e.jsx("p",{className:"text-xs text-gray-300 mt-1",children:c("在 manifest.configuration 中声明配置项即可在此处显示。","Declare settings in manifest.configuration to see them here.")})]}),e.jsx(At,{pluginId:R,lang:N})]}),k&&e.jsxs("div",{className:"p-4 border-t border-gray-100 flex items-center justify-between",children:[i&&e.jsx("span",{className:`text-xs ${i.startsWith("✓")?"text-green-600":"text-red-500"}`,children:i}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsx("button",{onClick:d,className:"px-4 py-2 text-xs font-medium text-gray-600 hover:bg-gray-50 rounded-lg transition-colors",children:c("取消","Cancel")}),e.jsxs("button",{onClick:p,disabled:y,className:"px-4 py-2 text-xs font-medium bg-indigo-600 text-white hover:bg-indigo-700 rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-50",children:[y?e.jsx(ye,{size:14,className:"animate-spin"}):e.jsx(ut,{size:14}),c("保存","Save")]})]})]})]})})}var Fe={exports:{}};/*!
|
|
2
2
|
|
|
3
3
|
JSZip v3.10.1 - A JavaScript class for generating and reading zip files
|
|
4
4
|
<http://stuartk.com/jszip>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-react-DHoBZpn2.js";import{
|
|
1
|
+
import{j as e}from"./vendor-react-DHoBZpn2.js";import{ay as o}from"./vendor-icons-CqLdl4B_.js";import"./vendor-utils-BxOuk3id.js";function n({showProcessLogs:s,setShowProcessLogs:r,processLogsContent:l,t}){return s?e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-xl w-full max-w-2xl flex flex-col max-h-[90vh]",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between",children:[e.jsxs("h2",{className:"font-semibold text-gray-800 flex items-center gap-2",children:[e.jsx(o,{size:18,className:"text-gray-600"}),t.processLogsTitle||"Process Logs"]}),e.jsx("button",{onClick:()=>r(null),className:"text-gray-400 hover:text-gray-600 font-bold px-2",children:"×"})]}),e.jsx("div",{className:"p-4 flex-1 overflow-auto bg-gray-900 m-4 rounded flex flex-col",children:e.jsx("pre",{className:"font-mono text-xs text-green-400 whitespace-pre-wrap",children:l||"No logs generated."})})]})}):null}export{n as ProcessLogsModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-react-DHoBZpn2.js";import{m as O}from"./index-XduPa2-x.js";import{au as w,c as C,h as k}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";function E(z){const{isQuizGeneratorOpen:S,setIsQuizGeneratorOpen:x,lessons:g,quizGenMode:n,setQuizGenMode:u,quizGenSelectedLessonId:l,setQuizGenSelectedLessonId:Q,quizGenTopic:c,setQuizGenTopic:M,isGeneratingSuggestions:p,setIsGeneratingSuggestions:h,suggestedObjectives:b,setSuggestedObjectives:f,suggestedQuestions:r,setSuggestedQuestions:m,quizGenTimeLimit:j,setQuizGenTimeLimit:G,savingQuiz:y,setSavingQuiz:v,quizGeneratorClassId:o,fetchClassDashboard:N}=z;return e.jsx(e.Fragment,{children:S&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50 overflow-y-auto text-gray-850",children:e.jsxs(O.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-3xl flex flex-col overflow-hidden max-h-[90vh]",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(w,{className:"text-indigo-600 animate-pulse",size:20}),e.jsx("h2",{className:"font-bold text-gray-800 text-lg",children:"AI-Objective Quiz Generator"})]}),e.jsx("button",{onClick:()=>x(!1),className:"text-gray-400 hover:text-gray-600 font-bold p-1 hover:bg-gray-200 rounded transition-colors",children:"×"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[r.length===0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-indigo-50/80 p-4 rounded-xl border border-indigo-100 text-xs text-indigo-800 leading-relaxed font-sans",children:"Choose a lesson to scan. Our advanced AI model will run a deep semantic scan across the entire lesson curriculum content, discover your core learning objectives, and construct interactive multiple-choice questions aligning precisely with each of them."}),e.jsxs("div",{className:"font-sans",children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Scan Core Selection Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>u("scan_lesson"),className:`p-3 rounded-lg border text-left flex flex-col transition-all ${n==="scan_lesson"?"border-indigo-600 bg-indigo-50/40 ring-2 ring-indigo-100":"border-gray-200 hover:border-gray-300"}`,children:[e.jsx("span",{className:"font-semibold text-sm text-indigo-900",children:"Curriculum Lesson Scanning"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:"Examines real Markdown content inside virtual lesson modules."})]}),e.jsxs("button",{onClick:()=>u("topic"),className:`p-3 rounded-lg border text-left flex flex-col transition-all ${n==="topic"?"border-indigo-600 bg-indigo-50/40 ring-2 ring-indigo-100":"border-gray-200 hover:border-gray-300"}`,children:[e.jsx("span",{className:"font-semibold text-sm text-indigo-900",children:"Custom Keyword / Topic"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:"Provide a custom prompt keyword or objective manually."})]})]})]}),n==="scan_lesson"?e.jsxs("div",{className:"font-sans",children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Select Lesson to Scan"}),g.length===0?e.jsx("div",{className:"text-gray-500 text-xs py-3 border rounded border-dashed text-center",children:"No lessons available. Please create a lesson first."}):e.jsxs("select",{value:l,onChange:s=>Q(s.target.value),className:"w-full p-2.5 bg-white border border-gray-200 rounded-lg text-sm text-gray-800 focus:border-indigo-500 focus:outline-none shadow-sm",children:[e.jsx("option",{value:"",children:"-- Choose a lesson --"}),g.map(s=>e.jsx("option",{value:s.id,children:s.title},s.id))]})]}):e.jsxs("div",{className:"font-sans",children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-505 uppercase tracking-wider mb-2",children:"Custom Topic Prompt"}),e.jsx("input",{type:"text",placeholder:"e.g. Introduction to React state, Cloud SQL setup...",value:c,onChange:s=>M(s.target.value),className:"w-full p-2.5 bg-white border border-gray-200 rounded-lg text-sm focus:border-indigo-500 focus:outline-none shadow-sm text-gray-800"})]}),e.jsx("div",{className:"pt-4 flex justify-end font-sans",children:e.jsx("button",{disabled:p||n==="scan_lesson"&&!l||n==="topic"&&!c.trim(),onClick:async()=>{h(!0);try{if(n==="scan_lesson"){const s=await fetch(`/api/classes/${o}/assignments/suggest`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:l})});if(s.ok){const t=await s.json();f(t.learningObjectives||[]),m((t.questions||[]).map(i=>({...i,selected:!0})))}else alert("Error generating suggestions. Please make sure the selected lesson has content.")}else(await fetch(`/api/classes/${o}/assignments/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:c})})).ok?(await N(o),x(!1)):alert("Error generating topic quiz.")}catch(s){console.error(s),alert(s.message)}finally{h(!1)}},className:"px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 text-white rounded-lg font-medium text-xs shadow transition flex items-center gap-2",children:p?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:16,className:"animate-spin"}),e.jsx("span",{children:"AI Scanning Content..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{size:16}),e.jsx("span",{children:"Generate Key MCQ Quiz"})]})})})]}),r.length>0&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"font-sans",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-2",children:"Identified Core Objectives"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((s,t)=>e.jsxs("span",{className:"px-2.5 py-1 bg-teal-50 text-teal-800 border border-teal-200 rounded-full text-xs font-semibold",children:["🎯 ",s]},t))})]}),e.jsxs("div",{className:"space-y-4 font-sans",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider font-semibold",children:"Suggested MCQ Questions"}),e.jsx("div",{className:"space-y-3",children:r.map((s,t)=>e.jsxs("div",{className:"p-4 rounded-xl border border-gray-150 bg-gray-50/50 hover:bg-gray-50 transition space-y-3 text-gray-800 text-gray-850",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-5 h-5 rounded-full bg-indigo-150 text-indigo-700 flex items-center justify-center text-xs font-bold shrink-0",children:t+1}),e.jsxs("span",{className:"text-xs font-semibold text-teal-700 bg-teal-50 px-2.5 py-0.5 rounded border border-teal-100",children:["objective: ",s.objective]})]}),e.jsx("input",{type:"checkbox",checked:!!s.selected,onChange:i=>{const a=[...r];a[t].selected=i.target.checked,m(a)},className:"w-4 h-4 text-indigo-600 border-gray-300 rounded focus:ring-indigo-500"})]}),e.jsx("p",{className:"font-semibold text-gray-800 text-sm leading-relaxed",children:s.question}),e.jsx("div",{className:"grid grid-cols-2 gap-2 text-xs",children:s.options.map((i,a)=>{const d=i===s.correctAnswer;return e.jsxs("div",{className:`p-2 rounded border flex items-center justify-between ${d?"bg-green-50 border-green-200 text-green-955 font-semibold":"bg-white border-gray-100 text-gray-700"}`,children:[e.jsx("span",{children:i}),d&&e.jsx(k,{size:12,className:"text-green-600 shrink-0"})]},a)})})]},t))})]}),e.jsxs("div",{className:"pt-4 border-t border-gray-100 flex justify-between items-center font-sans",children:[e.jsx("button",{onClick:()=>{f([]),m([])},className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg text-xs font-semibold transition",children:"Back / Scan New"}),e.jsxs("div",{className:"flex items-center gap-2 border border-indigo-150 bg-indigo-50/50 px-3 py-1.5 rounded-lg text-xs font-semibold text-indigo-900",children:[e.jsx("span",{children:"⏱️ Quiz Time Limit:"}),e.jsxs("select",{value:j,onChange:s=>G(Number(s.target.value)),className:"bg-transparent text-xs text-indigo-950 font-bold focus:outline-none cursor-pointer",children:[e.jsx("option",{className:"text-gray-800",value:0,children:"No Limit"}),e.jsx("option",{className:"text-gray-800",value:1,children:"1 Min"}),e.jsx("option",{className:"text-gray-800",value:2,children:"2 Mins"}),e.jsx("option",{className:"text-gray-800",value:5,children:"5 Mins"}),e.jsx("option",{className:"text-gray-800",value:10,children:"10 Mins"}),e.jsx("option",{className:"text-gray-800",value:15,children:"15 Mins"}),e.jsx("option",{className:"text-gray-800",value:20,children:"20 Mins"}),e.jsx("option",{className:"text-gray-800",value:30,children:"30 Mins"}),e.jsx("option",{className:"text-gray-800",value:45,children:"45 Mins"}),e.jsx("option",{className:"text-gray-800",value:60,children:"60 Mins"})]})]}),e.jsxs("button",{disabled:y||r.filter(s=>s.selected).length===0,onClick:async()=>{v(!0);try{const s=g.find(a=>a.id===l),t=s?s.title:c||"Custom Objective";(await fetch(`/api/classes/${o}/assignments/create-suggested-quiz`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:`MCQ Evaluation: ${t}`,description:"Automatic evaluation based on core learning objectives.",questions:r.filter(a=>a.selected).map(({selected:a,...d})=>d),learningObjectives:b,timeLimit:j})})).ok?(await N(o),x(!1)):alert("Failed to save suggested quiz.")}catch(s){console.error(s),alert(s.message)}finally{v(!1)}},className:"px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg font-medium text-xs shadow hover:shadow-md transition flex items-center gap-2",children:[y?e.jsx(C,{size:16,className:"animate-spin"}):e.jsx(k,{size:16}),e.jsx("span",{children:"Create Assessment Quiz"})]})]})]})]})]})})})}export{E as QuizGeneratorModal};
|
|
1
|
+
import{j as e}from"./vendor-react-DHoBZpn2.js";import{m as O}from"./index-7CK1B0tE.js";import{ax as w,c as C,h as k}from"./vendor-icons-CqLdl4B_.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-BMEc_Clb.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-skggaP9D.js";function E(z){const{isQuizGeneratorOpen:S,setIsQuizGeneratorOpen:x,lessons:g,quizGenMode:n,setQuizGenMode:u,quizGenSelectedLessonId:l,setQuizGenSelectedLessonId:Q,quizGenTopic:c,setQuizGenTopic:M,isGeneratingSuggestions:p,setIsGeneratingSuggestions:h,suggestedObjectives:b,setSuggestedObjectives:f,suggestedQuestions:r,setSuggestedQuestions:m,quizGenTimeLimit:j,setQuizGenTimeLimit:G,savingQuiz:y,setSavingQuiz:v,quizGeneratorClassId:o,fetchClassDashboard:N}=z;return e.jsx(e.Fragment,{children:S&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50 overflow-y-auto text-gray-850",children:e.jsxs(O.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-3xl flex flex-col overflow-hidden max-h-[90vh]",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(w,{className:"text-indigo-600 animate-pulse",size:20}),e.jsx("h2",{className:"font-bold text-gray-800 text-lg",children:"AI-Objective Quiz Generator"})]}),e.jsx("button",{onClick:()=>x(!1),className:"text-gray-400 hover:text-gray-600 font-bold p-1 hover:bg-gray-200 rounded transition-colors",children:"×"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[r.length===0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-indigo-50/80 p-4 rounded-xl border border-indigo-100 text-xs text-indigo-800 leading-relaxed font-sans",children:"Choose a lesson to scan. Our advanced AI model will run a deep semantic scan across the entire lesson curriculum content, discover your core learning objectives, and construct interactive multiple-choice questions aligning precisely with each of them."}),e.jsxs("div",{className:"font-sans",children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Scan Core Selection Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>u("scan_lesson"),className:`p-3 rounded-lg border text-left flex flex-col transition-all ${n==="scan_lesson"?"border-indigo-600 bg-indigo-50/40 ring-2 ring-indigo-100":"border-gray-200 hover:border-gray-300"}`,children:[e.jsx("span",{className:"font-semibold text-sm text-indigo-900",children:"Curriculum Lesson Scanning"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:"Examines real Markdown content inside virtual lesson modules."})]}),e.jsxs("button",{onClick:()=>u("topic"),className:`p-3 rounded-lg border text-left flex flex-col transition-all ${n==="topic"?"border-indigo-600 bg-indigo-50/40 ring-2 ring-indigo-100":"border-gray-200 hover:border-gray-300"}`,children:[e.jsx("span",{className:"font-semibold text-sm text-indigo-900",children:"Custom Keyword / Topic"}),e.jsx("span",{className:"text-xs text-gray-500 mt-1",children:"Provide a custom prompt keyword or objective manually."})]})]})]}),n==="scan_lesson"?e.jsxs("div",{className:"font-sans",children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Select Lesson to Scan"}),g.length===0?e.jsx("div",{className:"text-gray-500 text-xs py-3 border rounded border-dashed text-center",children:"No lessons available. Please create a lesson first."}):e.jsxs("select",{value:l,onChange:s=>Q(s.target.value),className:"w-full p-2.5 bg-white border border-gray-200 rounded-lg text-sm text-gray-800 focus:border-indigo-500 focus:outline-none shadow-sm",children:[e.jsx("option",{value:"",children:"-- Choose a lesson --"}),g.map(s=>e.jsx("option",{value:s.id,children:s.title},s.id))]})]}):e.jsxs("div",{className:"font-sans",children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-505 uppercase tracking-wider mb-2",children:"Custom Topic Prompt"}),e.jsx("input",{type:"text",placeholder:"e.g. Introduction to React state, Cloud SQL setup...",value:c,onChange:s=>M(s.target.value),className:"w-full p-2.5 bg-white border border-gray-200 rounded-lg text-sm focus:border-indigo-500 focus:outline-none shadow-sm text-gray-800"})]}),e.jsx("div",{className:"pt-4 flex justify-end font-sans",children:e.jsx("button",{disabled:p||n==="scan_lesson"&&!l||n==="topic"&&!c.trim(),onClick:async()=>{h(!0);try{if(n==="scan_lesson"){const s=await fetch(`/api/classes/${o}/assignments/suggest`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:l})});if(s.ok){const t=await s.json();f(t.learningObjectives||[]),m((t.questions||[]).map(i=>({...i,selected:!0})))}else alert("Error generating suggestions. Please make sure the selected lesson has content.")}else(await fetch(`/api/classes/${o}/assignments/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:c})})).ok?(await N(o),x(!1)):alert("Error generating topic quiz.")}catch(s){console.error(s),alert(s.message)}finally{h(!1)}},className:"px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 text-white rounded-lg font-medium text-xs shadow transition flex items-center gap-2",children:p?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:16,className:"animate-spin"}),e.jsx("span",{children:"AI Scanning Content..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(w,{size:16}),e.jsx("span",{children:"Generate Key MCQ Quiz"})]})})})]}),r.length>0&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"font-sans",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-2",children:"Identified Core Objectives"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((s,t)=>e.jsxs("span",{className:"px-2.5 py-1 bg-teal-50 text-teal-800 border border-teal-200 rounded-full text-xs font-semibold",children:["🎯 ",s]},t))})]}),e.jsxs("div",{className:"space-y-4 font-sans",children:[e.jsx("div",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider font-semibold",children:"Suggested MCQ Questions"}),e.jsx("div",{className:"space-y-3",children:r.map((s,t)=>e.jsxs("div",{className:"p-4 rounded-xl border border-gray-150 bg-gray-50/50 hover:bg-gray-50 transition space-y-3 text-gray-800 text-gray-850",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-5 h-5 rounded-full bg-indigo-150 text-indigo-700 flex items-center justify-center text-xs font-bold shrink-0",children:t+1}),e.jsxs("span",{className:"text-xs font-semibold text-teal-700 bg-teal-50 px-2.5 py-0.5 rounded border border-teal-100",children:["objective: ",s.objective]})]}),e.jsx("input",{type:"checkbox",checked:!!s.selected,onChange:i=>{const a=[...r];a[t].selected=i.target.checked,m(a)},className:"w-4 h-4 text-indigo-600 border-gray-300 rounded focus:ring-indigo-500"})]}),e.jsx("p",{className:"font-semibold text-gray-800 text-sm leading-relaxed",children:s.question}),e.jsx("div",{className:"grid grid-cols-2 gap-2 text-xs",children:s.options.map((i,a)=>{const d=i===s.correctAnswer;return e.jsxs("div",{className:`p-2 rounded border flex items-center justify-between ${d?"bg-green-50 border-green-200 text-green-955 font-semibold":"bg-white border-gray-100 text-gray-700"}`,children:[e.jsx("span",{children:i}),d&&e.jsx(k,{size:12,className:"text-green-600 shrink-0"})]},a)})})]},t))})]}),e.jsxs("div",{className:"pt-4 border-t border-gray-100 flex justify-between items-center font-sans",children:[e.jsx("button",{onClick:()=>{f([]),m([])},className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg text-xs font-semibold transition",children:"Back / Scan New"}),e.jsxs("div",{className:"flex items-center gap-2 border border-indigo-150 bg-indigo-50/50 px-3 py-1.5 rounded-lg text-xs font-semibold text-indigo-900",children:[e.jsx("span",{children:"⏱️ Quiz Time Limit:"}),e.jsxs("select",{value:j,onChange:s=>G(Number(s.target.value)),className:"bg-transparent text-xs text-indigo-950 font-bold focus:outline-none cursor-pointer",children:[e.jsx("option",{className:"text-gray-800",value:0,children:"No Limit"}),e.jsx("option",{className:"text-gray-800",value:1,children:"1 Min"}),e.jsx("option",{className:"text-gray-800",value:2,children:"2 Mins"}),e.jsx("option",{className:"text-gray-800",value:5,children:"5 Mins"}),e.jsx("option",{className:"text-gray-800",value:10,children:"10 Mins"}),e.jsx("option",{className:"text-gray-800",value:15,children:"15 Mins"}),e.jsx("option",{className:"text-gray-800",value:20,children:"20 Mins"}),e.jsx("option",{className:"text-gray-800",value:30,children:"30 Mins"}),e.jsx("option",{className:"text-gray-800",value:45,children:"45 Mins"}),e.jsx("option",{className:"text-gray-800",value:60,children:"60 Mins"})]})]}),e.jsxs("button",{disabled:y||r.filter(s=>s.selected).length===0,onClick:async()=>{v(!0);try{const s=g.find(a=>a.id===l),t=s?s.title:c||"Custom Objective";(await fetch(`/api/classes/${o}/assignments/create-suggested-quiz`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:`MCQ Evaluation: ${t}`,description:"Automatic evaluation based on core learning objectives.",questions:r.filter(a=>a.selected).map(({selected:a,...d})=>d),learningObjectives:b,timeLimit:j})})).ok?(await N(o),x(!1)):alert("Failed to save suggested quiz.")}catch(s){console.error(s),alert(s.message)}finally{v(!1)}},className:"px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg font-medium text-xs shadow hover:shadow-md transition flex items-center gap-2",children:[y?e.jsx(C,{size:16,className:"animate-spin"}):e.jsx(k,{size:16}),e.jsx("span",{children:"Create Assessment Quiz"})]})]})]})]})]})})})}export{E as QuizGeneratorModal};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import{r as a,j as e,b as ke}from"./vendor-react-DHoBZpn2.js";import{P as Ce,i as se,a as Pe,t as re,k as Se}from"./vendor-pptx-C0qaOH5T.js";import{bf as le,g as ne,aW as ae,k as ie,n as Te,B as Fe,x as Le,c as oe,af as $e,ac as Me,r as ze,D as Ae,ax as Re,C as De}from"./vendor-icons-CqLdl4B_.js";import{M as ce}from"./index-7CK1B0tE.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-BMEc_Clb.js";import"./vendor-charts-skggaP9D.js";import"./vendor-motion-BFAPOs-b.js";let A=null;const Ee=10;async function Xe(){if(A!=null)return A;try{const d=await fetch("/api/site-settings");if(d.ok){const l=await d.json();typeof l.uploadMaxFileMb=="number"&&l.uploadMaxFileMb>0&&(A=l.uploadMaxFileMb)}}catch{}return A??Ee}const Be={hiddenPanels:["inspector"]},Ie=[{code:"en",label:"English",nativeLabel:"English"},{code:"fr",label:"French",nativeLabel:"Français"},{code:"es",label:"Spanish",nativeLabel:"Español"},{code:"de",label:"German",nativeLabel:"Deutsch"},{code:"zh-CN",label:"Chinese (Simplified)",nativeLabel:"简体中文"}];se.isInitialized||se.use(Pe).init({resources:{en:{translation:re},"zh-CN":{translation:re}},lng:"zh-CN",fallbackLng:"en",keySeparator:!1,nsSeparator:!1,interpolation:{escapeValue:!1},parseMissingKeyHandler:d=>Se(d)});function Ze({elementId:d,data:l,userRole:V="teacher",onElementUpdate:o}){const[p,$]=a.useState("ppt"),[F,W]=a.useState(l.markdown||`# Title Slide
|
|
2
|
+
---
|
|
3
|
+
## Slide 2`),[r,N]=a.useState(l.slideX||0),v=a.useRef(r),w=a.useRef(null),R=a.useRef(l);R.current=l;const[j,D]=a.useState(!1),[E,de]=a.useState(4),[X,xe]=a.useState(!1),H=a.useRef(null),g=V==="teacher",c=V==="student",f=l.fileUrl||"",n=l.fileType||"md",y=l.fileName||"",K=!!f,[ue,q]=a.useState(!1),G=a.useRef(null),[J,B]=a.useState(null),[fe,k]=a.useState(!1),[Z,L]=a.useState(null),Q=a.useRef(null),Y=a.useRef(null),x=!!l.isFullscreenSynced,m=!!l.isFullscreenForced,i=X||c&&x&&m,C=F.split(/(?:\r?\n|^)---(?:\r?\n|$)/).map(t=>t.trim()).filter(t=>t.length>0),h=n==="md"?Math.max(1,C.length):l.slideCount||1;a.useEffect(()=>{n!=="md"&&p!=="ppt"&&$("ppt")},[n,p]),a.useEffect(()=>{l.slideX!==void 0&&l.slideX!==v.current&&(v.current=l.slideX,w.current=null,N(l.slideX))},[l.slideX]),a.useEffect(()=>{w.current=null},[f,n,i]),a.useEffect(()=>{l.markdown!==void 0&&l.markdown!==F&&W(l.markdown)},[l.markdown]);const pe=t=>(k(!0),L(null),fetch(t).then(s=>{if(!s.ok)throw new Error(`无法获取课件文件 (HTTP ${s.status})`);return s.arrayBuffer()}).then(s=>{B(new Uint8Array(s)),k(!1)}).catch(s=>{console.error("[RevealPresentationWrapper] Fetch PPTX failed:",s),L(s.message||"课件文件加载失败"),k(!1)}));a.useEffect(()=>{if(n!=="pptx"||!f){B(null),k(!1),L(null);return}let t=!0;return k(!0),L(null),fetch(f).then(s=>{if(!s.ok)throw new Error(`无法获取课件文件 (HTTP ${s.status})`);return s.arrayBuffer()}).then(s=>{t&&(B(new Uint8Array(s)),k(!1))}).catch(s=>{t&&(console.error("[RevealPresentationWrapper] Fetch PPTX failed:",s),L(s.message||"课件文件加载失败"),k(!1))}),()=>{t=!1}},[f,n]),a.useEffect(()=>{if(n==="pptx"){const t=i?Y.current:Q.current;if(t)try{const s=t.getActiveSlideIndex?.();s!==void 0&&(s===r?w.current===r&&(w.current=null):t.setActiveSlideIndex?.(r))}catch(s){console.warn("[RevealPresentationWrapper] Failed to sync PPTX slide index:",s)}}},[r,n,i]);const me=a.useCallback(t=>{const s=w.current;if(s!==null){if(t!==s)return;w.current=null}t!==v.current&&(v.current=t,N(t),g&&o&&o(d,{...R.current,slideX:t}))},[g,o,d]),he=a.useCallback(t=>{t>0&&g&&o&&l.slideCount!==t&&o(d,{...l,slideCount:t})},[g,o,l,d]),U=t=>fe?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center text-slate-500 gap-3 bg-slate-50 rounded-xl",children:[e.jsx(oe,{className:"w-8 h-8 animate-spin text-indigo-600"}),e.jsx("span",{className:"text-sm font-medium",children:"正在解析 PPTX 课件..."})]}):Z?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center text-rose-500 gap-2 p-6 text-center bg-slate-50 rounded-xl",children:[e.jsx(De,{className:"w-8 h-8"}),e.jsx("p",{className:"text-sm font-medium",children:Z}),e.jsx("button",{onClick:()=>{f&&pe(f)},className:"mt-2 px-3 py-1 text-xs bg-white border border-slate-200 hover:bg-slate-100 text-slate-700 rounded-md shadow-sm transition-colors",children:"重试加载"})]}):J?e.jsx("div",{className:"w-full h-full overflow-hidden rounded-xl bg-white border border-slate-100 shadow-md",children:e.jsx(Ce,{ref:t?Y:Q,content:J,fileName:y||"课件演示.pptx",canEdit:!1,showToolbar:!1,showThumbnails:t,showCompatibilityToasts:!1,customization:Be,initialSlide:r,defaultLocale:"zh-CN",availableLocales:Ie,onActiveSlideChange:me,onSlideCountChange:he,className:"w-full h-full"},`${f}-${t?"fs":"card"}`)}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-slate-400 text-sm bg-slate-50 rounded-xl",children:"课件内容未就绪"});a.useEffect(()=>{if(!j||p!=="ppt"||n!=="md")return;const t=setInterval(()=>{N(s=>{const u=(s+1)%Math.max(1,C.length);return v.current=u,o&&o(d,{...R.current,slideX:u}),u})},E*1e3);return()=>clearInterval(t)},[j,E,C.length,p,n]),a.useEffect(()=>{const t=s=>{c&&x&&m||(s.key==="ArrowRight"||s.key===" "?(s.preventDefault(),P(r+1)):s.key==="ArrowLeft"?(s.preventDefault(),P(r-1)):s.key==="Escape"&&i&&(s.preventDefault(),M(!1)))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[r,i,c,x,m,h]);const P=t=>{if(c&&x&&m)return;const s=Math.min(Math.max(0,t),h-1);v.current=s,n==="pptx"&&(w.current=s),N(s),g&&o&&o(d,{...l,slideX:s})},ee=t=>{W(t),o&&o(d,{...l,markdown:t})},be=async t=>{const s=t.target.files?.[0];if(!s)return;const u=s.name.split(".").pop()?.toLowerCase();if(u!=="pdf"&&u!=="pptx"){alert("仅支持上传 PDF 或 PPTX 格式的课件文件!");return}q(!0);try{const b=await Xe();if(s.size>b*1024*1024){alert(`课件文件超过 ${b}MB 上限,请压缩后再上传(上限可在管理后台 → 站点设置调整)。`);return}const O=(await new Promise((ve,Ne)=>{const _=new FileReader;_.onload=ye=>ve(ye.target?.result??""),_.onerror=()=>Ne(new Error("本地文件读取失败")),_.readAsDataURL(s)})).split(",")[1],T=await fetch("/api/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:s.name,base64Data:O})}),z=await T.json().catch(()=>({}));if(!T.ok)throw T.status===413?new Error("课件文件过大,超过服务器上传上限(10MB)。"):new Error(z.error||`上传失败(HTTP ${T.status})`);o&&(await o(d,{...l,fileUrl:z.fileUrl,fileName:s.name,fileType:z.fileType,slideX:0,slideCount:z.slideCount||1,isFullscreenSynced:l.isFullscreenSynced!==void 0?l.isFullscreenSynced:!0,isFullscreenForced:!1}),v.current=0,w.current=null,N(0))}catch(b){console.error("[RevealPresentation] upload failed:",b),alert(b?.message||"课件文件上传失败,请重试")}finally{q(!1)}},ge=()=>{window.confirm("确定要清除已上传的课件并恢复为 Markdown 编辑模式吗?")&&o&&(o(d,{...l,fileUrl:"",fileName:"",fileType:"md",slideX:0,slideCount:0,isFullscreenForced:!1}),v.current=0,w.current=null,N(0))},M=t=>{xe(t),g&&o&&o(d,{...l,isFullscreenForced:t})},I=t=>{o&&o(d,{...l,isFullscreenSynced:t,isFullscreenForced:t?X:!1})},we=[{name:"基础通用课件",desc:"标准的课件 structure",content:`# 物理学原理与探究
|
|
4
|
+
---
|
|
5
|
+
## 课程介绍
|
|
6
|
+
1. 经典力学基础
|
|
7
|
+
2. 能量守恒定律
|
|
8
|
+
3. 万有引力应用
|
|
9
|
+
---
|
|
10
|
+
## 科学探究要素
|
|
11
|
+
- 观察与提问
|
|
12
|
+
- 制定计划与设计实验
|
|
13
|
+
- 进行实验与收集证据
|
|
14
|
+
- 交流、评估及得出结论
|
|
15
|
+
---
|
|
16
|
+
## 物理课后思考一
|
|
17
|
+
> 牛顿第一定律是否可以在地球上直接通过实验完全验证?请结合摩擦力阐述。`},{name:"英语词汇互动",desc:"交互式英文闪卡",content:`# Topic: Smart Education
|
|
18
|
+
---
|
|
19
|
+
## Key Vocabulary
|
|
20
|
+
- **Orchestration**: Arrangement or cooperation of system systems.
|
|
21
|
+
- **Heuristic**: Practical method not guaranteed to be perfect.
|
|
22
|
+
- **Applet**: Lightweight interactive program.
|
|
23
|
+
---
|
|
24
|
+
## Reading Passage
|
|
25
|
+
Modern class orchestration allows instructors to dispatch customized applets directly onto the virtual desk interfaces of student endpoints instantly!
|
|
26
|
+
---
|
|
27
|
+
## Fill in the Blank
|
|
28
|
+
The teacher used the virtual whiteboard to ___ classroom active learning slides.
|
|
29
|
+
*(Answer: orchestrate)*`},{name:"微课探究文档",desc:"一页式大纲微课",content:`# 探究牛顿第三定律
|
|
30
|
+
在本节微课中,我们将探讨作用力与反作用力的核心性质。
|
|
31
|
+
|
|
32
|
+
## 概念要点
|
|
33
|
+
- 作用力与反作用力**大小相等**
|
|
34
|
+
- 作用力与反作用力**方向相反**
|
|
35
|
+
- 作用力与反作用力作用在**不同的物体上**
|
|
36
|
+
- 它们伴随发生,同时消失。
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 经典实验设计
|
|
41
|
+
1. 准备两个完全相同的弹簧测力计 A 与 B。
|
|
42
|
+
2. 将它们对拉,观察两者的示数变化。
|
|
43
|
+
3. 会发现:不管拉力如何变化,A 的读数总是等于 B 的读数。
|
|
44
|
+
|
|
45
|
+
## 问题思考
|
|
46
|
+
当马拉着车在水平路面上加速前进时,马拉车的力与车拉马的力,哪一个更大?`}],te=(()=>{const t=F.split(`
|
|
47
|
+
`),s=[];return t.forEach((u,b)=>{const S=u.match(/^(#{1,3})\s+(.*)$/);S&&s.push({text:S[2].trim(),level:S[1].length,lineIndex:b})}),s})();if(n==="file"&&K){const t=(y.split(".").pop()||"file").toLowerCase();return e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-3 p-5 bg-gradient-to-br from-slate-50 to-white border border-slate-200 rounded-xl","data-testid":"course-package-file-card",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-indigo-50 border border-indigo-100 flex items-center justify-center",children:e.jsx(le,{size:22,className:"text-indigo-600"})}),e.jsxs("div",{className:"text-center max-w-full",children:[e.jsx("p",{className:"text-sm font-bold text-slate-800 truncate",title:y||f,children:y||"课程附件"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5 font-mono uppercase",children:t})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("a",{href:f,download:y||void 0,"data-testid":"course-package-file-download",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 rounded-lg transition-colors",onClick:s=>s.stopPropagation(),children:[e.jsx(le,{size:13}),"下载附件"]}),g&&o&&e.jsx("button",{onClick:s=>{s.stopPropagation(),window.confirm("确定要移除此附件引用吗?(不会删除已上传的文件)")&&o(d,{...l,fileUrl:"",fileName:"",fileType:"md",slideCount:0})},"data-testid":"course-package-file-clear",className:"px-3 py-1.5 text-xs font-bold text-slate-600 bg-white border border-slate-200 hover:bg-slate-50 rounded-lg transition-colors",children:"移除引用"})]}),e.jsx("p",{className:"text-[10px] text-slate-400 text-center leading-relaxed max-w-[240px]",children:"该类型没有白板内联渲染器,以附件形式提供下载。"})]})}if(i&&typeof document<"u")return e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center bg-slate-900/10 text-slate-400 font-sans p-4",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(ne,{size:24,className:"text-indigo-500 animate-pulse"}),e.jsx("span",{className:"text-xs",children:"演示文稿正在全屏放映中"})]}),ke.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[99999] bg-neutral-950 flex flex-col items-center justify-center font-sans p-6",children:[e.jsxs("div",{className:"absolute top-4 left-4 right-4 flex items-center justify-between text-white/80 select-none z-[100001] px-4 py-2 bg-neutral-900/60 backdrop-blur-md rounded-xl border border-neutral-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsxs("span",{className:"font-bold text-xs tracking-wider uppercase",children:[n==="md"?"Markdown Slides":`${n.toUpperCase()} Presentation`," ",c&&"(Synced)"]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-xs font-mono text-white/50",children:["Slide ",r+1," / ",h]}),g&&e.jsxs(e.Fragment,{children:[n==="md"&&e.jsx("button",{onClick:()=>D(t=>!t),className:`px-2.5 py-1 rounded-md text-xs uppercase font-bold tracking-wider transition-colors border cursor-pointer ${j?"bg-emerald-50 border-emerald-400 text-white animate-pulse":"bg-transparent border-neutral-700 text-neutral-400 hover:bg-neutral-850"}`,children:j?"Autoplay Live":"Autoplay"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-white/70 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:x,onChange:t=>I(t.target.checked),className:"rounded border-neutral-700 bg-neutral-800 text-indigo-500 focus:ring-0 focus:ring-offset-0 cursor-pointer"}),e.jsx("span",{children:"同步学生全屏"})]})]}),(!c||!m||!x||X)&&e.jsx("button",{onClick:()=>M(!1),className:"p-1 px-2.5 bg-red-600 text-white text-xs font-bold rounded-lg transition-colors cursor-pointer border-0 hover:bg-red-700",title:"退出放映",children:"退出放映 (Esc)"})]})]}),e.jsx("div",{className:"w-full flex-1 min-h-0 flex items-center justify-center relative",children:n==="pdf"?e.jsx("div",{className:"w-full h-full flex items-center justify-center p-2 bg-slate-100 max-w-[90vw] max-h-[82vh] aspect-video rounded-2xl overflow-hidden shadow-2xl border border-neutral-850",children:e.jsx("iframe",{src:`${f}#page=${r+1}&toolbar=0&navpanes=0`,className:"w-full h-full border-0 rounded-xl"},`${f}-fs-${r}`)}):n==="pptx"?e.jsx("div",{className:"w-full h-full flex items-center justify-center p-2 bg-slate-900/5 max-w-[90vw] max-h-[82vh] aspect-video rounded-2xl overflow-hidden shadow-2xl border border-neutral-850",children:U(!0)}):e.jsx("div",{className:"flex-1 w-full flex items-center justify-center max-w-[90vw] min-h-0",children:e.jsxs("div",{className:"w-full bg-white rounded-xl shadow-md border border-slate-100 flex flex-col overflow-y-auto p-6 md:p-8 aspect-video relative transition-all duration-300 hover:shadow-lg max-h-[82vh] max-w-none p-12 md:p-16 border-neutral-850 rounded-3xl shadow-2xl",children:[e.jsxs("div",{className:"flex justify-between items-center text-xs font-semibold text-slate-400 border-b border-slate-100 pb-2 mb-4 shrink-0",children:[e.jsx("span",{className:"tracking-wide uppercase text-indigo-650",children:"SMART CLASS SLIDE DECK"}),e.jsxs("span",{className:"font-mono",children:["SLIDE ",r+1," / ",h]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1",children:e.jsx("div",{className:"markdown-body text-slate-800 leading-relaxed font-sans prose prose-neutral max-w-none text-xs",children:C[r]?e.jsx(ce,{children:C[r]}):e.jsx("div",{className:"text-center text-slate-400 italic py-8",children:"幻灯片没有内容,请在“编辑文档”中添加。"})})}),e.jsxs("div",{className:"mt-4 pt-2 border-t border-slate-50 flex items-center justify-between text-xs text-slate-400 shrink-0 font-sans",children:[e.jsx("span",{children:"智慧互动教室白板演示系统"}),e.jsxs("span",{children:["Page ",r+1]})]})]})})}),!(c&&x&&m)&&e.jsxs("div",{className:"absolute bottom-6 bg-neutral-900/80 backdrop-blur-md px-6 py-2.5 rounded-full border border-neutral-800 shadow-2xl z-[100001]",children:[e.jsx("button",{disabled:r===0||c,onClick:()=>P(r-1),className:`p-1.5 rounded-full border transition-colors cursor-pointer ${r===0||c?"border-neutral-800 text-neutral-600 bg-neutral-950/20 cursor-not-allowed":"border-neutral-700 text-neutral-300 hover:bg-neutral-800"}`,title:"上一张 (ArrowLeft)",children:e.jsx(ae,{size:18})}),e.jsxs("div",{className:"flex items-center gap-1.5 px-1 font-mono text-xs text-neutral-200",children:[e.jsx("span",{className:"font-bold text-white text-base",children:r+1}),e.jsx("span",{className:"text-neutral-600",children:"/"}),e.jsx("span",{children:h})]}),e.jsx("button",{disabled:r>=h-1||c,onClick:()=>P(r+1),className:`p-1.5 rounded-full border transition-colors cursor-pointer ${r>=h-1||c?"border-neutral-800 text-neutral-600 bg-neutral-950/20 cursor-not-allowed":"border-neutral-700 text-neutral-300 hover:bg-neutral-800"}`,title:"下一张 (ArrowRight)",children:e.jsx(ie,{size:18})})]})]}),document.body)]});const je=i?"fixed inset-0 z-[99999] bg-neutral-950 flex flex-col items-center justify-center font-sans p-6":"flex-1 flex flex-col items-center justify-between p-4 bg-slate-900/5 relative min-w-0";return e.jsxs("div",{className:"w-full h-full flex flex-col bg-slate-50 text-slate-800 overflow-hidden text-xs relative font-sans",children:[!i&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-slate-100 border-b border-slate-200 shrink-0 select-none relative z-10",children:[e.jsx("div",{className:"flex items-center gap-1",children:n==="md"?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>$("ppt"),className:`px-2 py-1 rounded flex items-center gap-1 font-medium transition-colors cursor-pointer ${p==="ppt"?"bg-indigo-600 text-white shadow-sm":"text-slate-600 hover:bg-slate-200"}`,title:"播放课件幻灯片 (PPT Mode)",children:[e.jsx(Te,{size:11}),e.jsx("span",{children:"PPT 播放"})]}),e.jsxs("button",{onClick:()=>$("doc"),className:`px-2 py-1 rounded flex items-center gap-1 font-medium transition-colors cursor-pointer ${p==="doc"?"bg-indigo-600 text-white shadow-sm":"text-slate-600 hover:bg-slate-200"}`,title:"以精美文档形式阅读 (Markdown Document mode)",children:[e.jsx(Fe,{size:11}),e.jsx("span",{children:"文档阅读"})]}),e.jsxs("button",{onClick:()=>$("edit"),className:`px-2 py-1 rounded flex items-center gap-1 font-medium transition-colors cursor-pointer ${p==="edit"?"bg-indigo-600 text-white shadow-sm":"text-slate-600 hover:bg-slate-200"}`,title:"在线编辑 Markdown 内容",children:[e.jsx(Le,{size:11}),e.jsx("span",{children:"编辑文档"})]})]}):e.jsxs("div",{className:"flex items-center gap-1 bg-indigo-50 border border-indigo-200/50 text-indigo-700 px-2 py-0.5 rounded text-xs font-semibold",children:[e.jsx(ne,{size:10}),e.jsxs("span",{children:[n.toUpperCase()," 课件演示中"]})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[g&&e.jsx("div",{className:"flex items-center gap-1.5 border-r border-slate-200 pr-3",children:ue?e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-500 font-medium",children:[e.jsx(oe,{size:10,className:"animate-spin"}),e.jsx("span",{children:"上传解析中..."})]}):K?e.jsxs("div",{className:"flex items-center gap-1.5 bg-slate-200/50 pl-2 pr-1.5 py-0.5 rounded border border-slate-300/30",children:[e.jsx("span",{className:"text-xs font-medium text-slate-600 max-w-[120px] truncate font-mono",title:y,children:y}),e.jsx("button",{onClick:ge,className:"p-0.5 hover:bg-slate-300 rounded text-red-500 cursor-pointer border-0 bg-transparent",title:"清除并切换回 Markdown",children:e.jsx($e,{size:10})})]}):e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>G.current?.click(),className:"px-2 py-1 rounded bg-indigo-50 border border-indigo-200 text-indigo-700 hover:bg-indigo-100 flex items-center gap-1 font-semibold text-xs cursor-pointer",title:"上传 PPTX 或 PDF 课件",children:[e.jsx(Me,{size:10}),e.jsx("span",{children:"上传课件"})]}),e.jsx("input",{type:"file",ref:G,onChange:be,accept:".pdf,.pptx",className:"hidden"})]})}),p==="ppt"&&n==="md"&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>D(t=>!t),className:`p-1 rounded flex items-center gap-1 font-semibold text-xs transition-colors border cursor-pointer ${j?"bg-emerald-50 border-emerald-300 text-emerald-700":"bg-white border-slate-200 text-slate-500 hover:bg-slate-50"}`,title:"开启/关闭幻灯片自动播放",children:[j?e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-ping"}):null,e.jsx("span",{children:j?"自动播放中":"自动播放"})]}),j&&e.jsxs("select",{value:E,onChange:t=>de(Number(t.target.value)),className:"bg-white border border-slate-200 rounded px-1 text-xs py-0.5 text-slate-700 font-medium",children:[e.jsx("option",{value:2,children:"2秒"}),e.jsx("option",{value:4,children:"4秒"}),e.jsx("option",{value:6,children:"6秒"}),e.jsx("option",{value:10,children:"10秒"})]})]}),g&&p==="ppt"&&e.jsxs("label",{className:"flex items-center gap-1 text-xs text-slate-500 font-medium cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:x,onChange:t=>I(t.target.checked),className:"rounded border-slate-300 text-indigo-650 focus:ring-0 focus:ring-offset-0 cursor-pointer"}),e.jsx("span",{children:"同步学生全屏"})]}),p==="ppt"&&(!c||!(x&&m))&&e.jsx("button",{onClick:()=>M(!0),className:"p-1 rounded-lg text-slate-655 hover:bg-slate-200 border border-slate-200 bg-white transition-colors cursor-pointer",title:"全屏放映",children:e.jsx(ze,{size:11})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 relative flex flex-row overflow-hidden",children:[p==="ppt"&&e.jsxs("div",{className:je,children:[i&&e.jsxs("div",{className:"absolute top-4 left-4 right-4 flex items-center justify-between text-white/80 select-none z-[100001] px-4 py-2 bg-neutral-900/60 backdrop-blur-md rounded-xl border border-neutral-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsxs("span",{className:"font-bold text-xs tracking-wider uppercase",children:[n==="md"?"Markdown Slides":`${n.toUpperCase()} Presentation`," ",c&&"(Synced)"]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-xs font-mono text-white/50",children:["Slide ",r+1," / ",h]}),g&&e.jsxs(e.Fragment,{children:[n==="md"&&e.jsx("button",{onClick:()=>D(t=>!t),className:`px-2.5 py-1 rounded-md text-xs uppercase font-bold tracking-wider transition-colors border cursor-pointer ${j?"bg-emerald-50 border-emerald-400 text-white animate-pulse":"bg-transparent border-neutral-700 text-neutral-400 hover:bg-neutral-850"}`,children:j?"Autoplay Live":"Autoplay"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-white/70 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:x,onChange:t=>I(t.target.checked),className:"rounded border-neutral-700 bg-neutral-800 text-indigo-500 focus:ring-0 focus:ring-offset-0 cursor-pointer"}),e.jsx("span",{children:"同步学生全屏"})]}),e.jsx("button",{onClick:()=>M(!1),className:"p-1 px-2.5 bg-red-655 text-white text-xs font-bold rounded-md transition-colors cursor-pointer border-0",title:"退出放映",children:"退出放映 (Esc)"})]})]})]}),e.jsx("div",{className:"w-full flex-1 min-h-0 flex items-center justify-center relative",children:n==="pdf"?e.jsx("div",{className:`w-full h-full flex items-center justify-center p-2 bg-slate-100 ${i?"max-w-5xl aspect-video rounded-2xl overflow-hidden shadow-2xl border border-neutral-850":""}`,children:e.jsx("iframe",{src:`${f}#page=${r+1}&toolbar=0&navpanes=0`,className:"w-full h-full border-0 rounded-xl"},`${f}-${i?"fs":"card"}-${r}`)}):n==="pptx"?e.jsx("div",{className:`w-full h-full flex items-center justify-center p-2 bg-slate-900/5 ${i?"max-w-5xl aspect-video rounded-2xl overflow-hidden shadow-2xl border border-neutral-850":""}`,children:U(!1)}):e.jsx("div",{className:"flex-1 w-full flex items-center justify-center max-w-2xl min-h-0",children:e.jsxs("div",{className:`w-full bg-white rounded-xl shadow-md border border-slate-100 flex flex-col overflow-y-auto p-6 md:p-8 aspect-video relative transition-all duration-300 hover:shadow-lg max-h-full ${i?"max-w-4xl p-12 md:p-16 border-neutral-850 rounded-3xl shadow-2xl":""}`,children:[e.jsxs("div",{className:"flex justify-between items-center text-xs font-semibold text-slate-400 border-b border-slate-100 pb-2 mb-4 shrink-0",children:[e.jsx("span",{className:"tracking-wide uppercase text-indigo-650",children:"SMART CLASS SLIDE DECK"}),e.jsxs("span",{className:"font-mono",children:["SLIDE ",r+1," / ",h]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1",children:e.jsx("div",{className:"markdown-body text-slate-800 leading-relaxed font-sans prose prose-neutral max-w-none text-xs",children:C[r]?e.jsx(ce,{children:C[r]}):e.jsx("div",{className:"text-center text-slate-400 italic py-8",children:"幻灯片没有内容,请在“编辑文档”中添加。"})})}),e.jsxs("div",{className:"mt-4 pt-2 border-t border-slate-50 flex items-center justify-between text-xs text-slate-400 shrink-0 font-sans",children:[e.jsx("span",{children:"智慧互动教室白板演示系统"}),e.jsxs("span",{children:["Page ",r+1]})]})]})})}),!(c&&x&&m)&&e.jsxs("div",{className:`mt-4 flex items-center justify-center gap-3 select-none shrink-0 ${i?"absolute bottom-6 bg-neutral-900/80 backdrop-blur-md px-6 py-2.5 rounded-full border border-neutral-800 shadow-2xl z-[100001]":"bg-white px-4 py-2 rounded-full border border-slate-200/80 shadow-md relative z-10"}`,children:[e.jsx("button",{disabled:r===0||c&&x&&m,onClick:()=>P(r-1),className:`p-1.5 rounded-full border transition-colors cursor-pointer ${r===0||c&&x&&m?i?"border-neutral-800 text-neutral-600 bg-neutral-950/20 cursor-not-allowed":"border-slate-100 bg-slate-50 text-slate-300 cursor-not-allowed":i?"border-neutral-700 text-neutral-300 hover:bg-neutral-800":"border-slate-205 text-slate-655 hover:bg-slate-50"}`,title:"上一张 (ArrowLeft)",children:e.jsx(ae,{size:i?18:14})}),e.jsxs("div",{className:`flex items-center gap-1.5 px-1 font-mono text-xs ${i?"text-neutral-200":"text-slate-700"}`,children:[e.jsx("span",{className:`font-bold ${i?"text-white text-base":"text-slate-900"}`,children:r+1}),e.jsx("span",{className:i?"text-neutral-600":"text-slate-350",children:"/"}),e.jsx("span",{children:h})]}),e.jsx("button",{disabled:r>=h-1||c&&x&&m,onClick:()=>P(r+1),className:`p-1.5 rounded-full border transition-colors cursor-pointer ${r>=h-1||c&&x&&m?i?"border-neutral-800 text-neutral-600 bg-neutral-950/20 cursor-not-allowed":"border-slate-100 bg-slate-50 text-slate-300 cursor-not-allowed":i?"border-neutral-700 text-neutral-300 hover:bg-neutral-800":"border-slate-205 text-slate-655 hover:bg-slate-50"}`,title:"下一张 (ArrowRight)",children:e.jsx(ie,{size:i?18:14})})]})]}),p==="doc"&&n==="md"&&e.jsxs("div",{className:"flex-1 flex flex-row min-h-0 bg-white",children:[te.length>0&&e.jsxs("div",{className:"w-1/4 min-w-[120px] max-w-[200px] border-r border-slate-200 bg-slate-50/50 flex flex-col py-3 px-2 overflow-y-auto shrink-0 select-none",children:[e.jsxs("span",{className:"text-xs font-bold text-slate-400 uppercase tracking-widest px-2 mb-2 flex items-center gap-1",children:[e.jsx(Ae,{size:10}),"文档大纲"]}),e.jsx("div",{className:"flex flex-col gap-0.5",children:te.map((t,s)=>e.jsx("button",{onClick:()=>{const u=H.current?.querySelector(`[data-line-index="${t.lineIndex}"]`);u&&u.scrollIntoView({behavior:"smooth",block:"start"})},className:"text-left text-xs py-1 px-2 rounded hover:bg-slate-100 text-slate-600 hover:text-slate-900 truncate cursor-pointer font-medium whitespace-nowrap border-0 bg-transparent",style:{paddingLeft:`${Math.max(8,t.level*6)}px`},title:t.text,children:t.text},s))})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-6 md:p-8",ref:H,children:e.jsx("div",{className:"markdown-body prose prose-neutral max-w-none text-xs leading-relaxed text-slate-700",children:F.split(`
|
|
48
|
+
`).map((t,s)=>{const u=t.match(/^(#{1,3})\s+(.*)$/);if(u){const b=u[1].length,S=u[2].trim(),O=b===1?"h1":b===2?"h2":"h3",T=b===1?"text-lg font-bold text-indigo-900 border-b pb-1 mt-4 mb-2":b===2?"text-base font-bold text-slate-800 mt-3 mb-1.5":"text-sm font-semibold text-slate-700 mt-2 mb-1";return e.jsx(O,{"data-line-index":s,className:T,children:S},s)}return t.trim()==="---"?e.jsx("hr",{className:"my-4 border-slate-200"},s):e.jsx("p",{className:"my-1.5 text-slate-600 antialiased leading-relaxed",children:t},s)})})})]}),p==="edit"&&n==="md"&&e.jsxs("div",{className:"flex-1 flex flex-col md:flex-row min-h-0 bg-white",children:[e.jsxs("div",{className:"w-full md:w-1/3 border-b md:border-b-0 md:border-r border-slate-100 bg-slate-50/40 p-3 flex flex-col overflow-y-auto shrink-0 select-none",children:[e.jsxs("span",{className:"text-xs font-bold text-slate-400 tracking-wider uppercase mb-2 flex items-center gap-1",children:[e.jsx(Re,{size:10,className:"text-indigo-650"}),"推荐课件及文档模板"]}),e.jsx("div",{className:"flex flex-col gap-2",children:we.map((t,s)=>e.jsxs("button",{type:"button",onClick:()=>{window.confirm(`确定要加载模板 “${t.name}” 吗?这将会覆盖当前白板课件中的所有编辑内容。`)&&(ee(t.content),v.current=0,w.current=null,N(0))},className:"w-full text-left p-2.5 rounded-lg border border-slate-200 bg-white hover:border-indigo-300 hover:shadow-sm transition-all focus:outline-none cursor-pointer group",children:[e.jsx("div",{className:"font-bold text-xs text-slate-800 group-hover:text-indigo-700 whitespace-nowrap overflow-hidden text-ellipsis",children:t.name}),e.jsx("div",{className:"text-xs text-slate-400 mt-0.5",children:t.desc})]},s))}),e.jsxs("div",{className:"mt-4 p-2 bg-amber-50 rounded border border-amber-100 text-xs text-amber-700 font-sans leading-relaxed",children:[e.jsx("strong",{children:"💡 使用提示"}),e.jsx("br",{}),"在任意位置插入一行 ",e.jsx("code",{children:"---"})," 即可分割出一个新的幻灯片(PPT)页面。"]})]}),e.jsxs("div",{className:"flex-1 flex flex-col p-3 min-h-[200px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[e.jsx("span",{className:"font-bold text-slate-500 text-xs uppercase",children:"Markdown Source Code"}),e.jsx("span",{className:"text-xs text-slate-400",children:"实时自动同步到所有协同终端"})]}),e.jsx("textarea",{value:F,onChange:t=>ee(t.target.value),placeholder:"在此输入 Markdown 文档。使用 '---' 来作为 PPT 页面分页符...",className:"flex-1 w-full p-3 font-mono text-xs bg-slate-50 border border-slate-200 rounded-lg focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:bg-white transition-all resize-none leading-relaxed text-slate-800"})]})]})]})]})}export{Ze as RevealPresentationWrapper};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e}from"./vendor-react-DHoBZpn2.js";import{s as v,E as M}from"./index-XduPa2-x.js";import{A as Z}from"./AssignmentFilePreview-D_POvLmv.js";import{R as w,ac as O,b4 as I,a4 as ee,y as se,C as te,q as ae,_ as ie,a as ne,D as re,a8 as le,t as oe}from"./vendor-icons-DLOPlM4i.js";function de(i){if(!i)return"";const l=i.split("/");return l[l.length-1]||i}function H(i){const l=de(i?.file_path);if(l)return l;const x=Array.isArray(i?.files)?i.files:[];return x.length===1?x[0]?.name||"附件":x.length>1?`${x.length} 个附件`:i?.textContent?"文字作答":i?.linkUrl?"链接作答":"已提交(无附件)"}function q(i,l){return!l?.fileId||!i?.assignment_id?null:`/api/assignments/${i.assignment_id}/files/${l.fileId}`}function he({lessonId:i,studentId:l,lang:x,addToast:f}){const[B,S]=c.useState(!1),[T,R]=c.useState(!1),[N,V]=c.useState(null),[W,G]=c.useState([]),[y,J]=c.useState(""),[z,$]=c.useState(null),[F,P]=c.useState(!1),[k,A]=c.useState({}),[_,D]=c.useState({}),[Y,L]=c.useState({}),t=x==="zh",b=async(s=!1)=>{s?R(!0):S(!0);try{const r=await(await fetch(`/api/lessons/${i}/students/${l}/eval-status`)).json();V(r);const d=await(await fetch(`/api/lessons/${i}/eval-submissions`)).json();G(d)}catch(n){console.error("Error fetching eval data:",n),f(t?"数据加载失败":"Failed to Load Data",t?"请检查网络连接或刷新页面。":"Please check your connection and try again.","warning")}finally{S(!1),R(!1)}};c.useEffect(()=>{i&&l&&b()},[i,l]);const K=async s=>{s.preventDefault(),y.trim(),P(!0);try{const r=await(await fetch(`/api/lessons/${i}/eval-submissions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentId:l,filePath:y.trim()||void 0})})).json();if(r.success)f(t?"作业提交成功":"Assignment Submitted",t?`成功提交版本 ${r.version}!`:`Successfully submitted version ${r.version}!`,"success"),b(!0);else throw new Error(r.error||"Failed to submit assignment")}catch(n){f(t?"提交失败":"Submission Failed",n.message,"warning")}finally{P(!1)}},Q=async(s,n)=>{const r=k[s],h=_[s]||"";if(r===void 0||isNaN(r)||r<0||r>100){f(t?"评分无效":"Invalid Score",t?"分数必须在 0 到 100 之间!":"Score must be between 0 and 100!","warning");return}L(d=>({...d,[s]:!0}));try{const p=await(await fetch(`/api/lessons/${i}/eval-submissions/${s}/reviews`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:Number(r),comment:h})})).json();if(p.success)f(t?"互评提交成功":"Review Submitted",t?"成功对同学的作品完成了评价!":"Successfully completed review for classmate!","success"),D(j=>{const u={...j};return delete u[s],u}),b(!0);else throw new Error(p.error||"Failed to submit review")}catch(d){f(t?"评价提交失败":"Review Failed",d.message,"warning")}finally{L(d=>({...d,[s]:!1}))}};if(B)return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-gray-500",children:[e.jsx(w,{className:"animate-spin text-indigo-500 mb-2",size:32}),e.jsx("p",{children:t?"正在读取作业互评状态...":"Loading assignment status..."})]});const a=N?.submission,E=v(a?.linkUrl),o=N?.grade,X=N?.reviewsWritten||[],U=W.filter(s=>s.student_id!==l);return e.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-6 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"w-full lg:w-5/12 flex flex-col gap-6",children:[e.jsxs("div",{className:"bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs text-left",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 select-none",children:[e.jsx(O,{size:16,className:"text-indigo-600"}),t?"我的作业提交":"My Assignment Submission"]}),e.jsx("button",{onClick:()=>b(!0),className:"p-1 hover:bg-slate-200/50 rounded transition-colors text-slate-550",title:t?"刷新数据":"Refresh Data",children:e.jsx(w,{size:14,className:T?"animate-spin":""})})]}),a?e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-xl space-y-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"bg-emerald-50 text-emerald-600 p-2.5 rounded-lg border border-emerald-100",children:e.jsx(I,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-slate-400 font-medium",children:t?"当前已提交版本":"Currently Submitted Version"}),e.jsx("p",{className:"text-sm font-semibold text-slate-700 truncate",children:H(a)})]}),e.jsxs("span",{className:"bg-indigo-100 text-indigo-700 text-xs font-bold px-2 py-0.5 rounded-full border border-indigo-200",children:["V",a.version]})]}),e.jsxs("div",{className:"border-t border-slate-100 pt-2.5 flex justify-between items-center text-xs text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ee,{size:11}),t?"更新时间:":"Updated At:"," ",new Date(a.updated_at).toLocaleString()]}),e.jsx("span",{className:"font-mono text-slate-350 select-all truncate max-w-[120px]",title:a.file_path||void 0,children:a.file_path||"—"})]}),(a.textContent||a.linkUrl||Array.isArray(a.files)&&a.files.length>0)&&e.jsxs("div",{className:"border-t border-slate-100 pt-2.5 space-y-1 text-xs text-slate-600",children:[a.textContent&&e.jsx("p",{className:"whitespace-pre-wrap break-all max-h-20 overflow-hidden",children:a.textContent}),E&&e.jsx("a",{href:E,target:"_blank",rel:"noopener noreferrer",className:"block truncate text-indigo-600 hover:underline",children:a.linkUrl}),Array.isArray(a.files)&&a.files.map((s,n)=>{const r=v(q(a,s)),h=!!(r&&a?.assignment_id&&s?.fileId);return e.jsxs("span",{className:"flex items-center gap-1.5",children:[h&&e.jsx("button",{onClick:()=>$({id:String(s.fileId),original_name:String(s.name??s.fileId),size:Number(s.size??0),mime:s.mime??null}),className:"p-0.5 rounded text-indigo-600 hover:bg-indigo-50 shrink-0",title:t?"预览":"Preview","aria-label":t?`预览 ${s.name}`:`Preview ${s.name}`,"data-testid":"student-assignment-file-preview",children:e.jsx(se,{size:11})}),r?e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"block truncate text-indigo-600 hover:underline",children:s.name}):e.jsx("span",{className:"block truncate",children:s.name})]},s.fileId??n)})]}),e.jsx(M,{slot:"assignment.submission.preview",slotProps:{submission:a,studentId:l,lessonId:i,isSelf:!0,lang:x}})]}):e.jsxs("div",{className:"bg-amber-50/50 border border-amber-100 p-4 rounded-xl flex items-start gap-3 mb-4 text-left",children:[e.jsx(te,{className:"text-amber-500 shrink-0 mt-0.5",size:16}),e.jsxs("div",{className:"text-xs text-amber-700",children:[e.jsx("p",{className:"font-bold",children:t?"未提交作业":"No Submission Yet"}),e.jsx("p",{className:"mt-1",children:t?"在此上传提交后,其他同学将可以对您的作业进行评分互评。":"Once submitted, other students can view and peer-review your work."})]})]}),e.jsx("form",{onSubmit:K,className:"space-y-3",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:t?"输入作品文件路径 / 虚拟路径":"Simulated File Path"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:y,onChange:s=>J(s.target.value),placeholder:"/files/homework.pdf",required:!0,className:"flex-1 bg-white border border-slate-200 px-3 py-2 text-xs rounded-lg text-slate-700 focus:outline-none focus:border-indigo-400 font-mono transition-colors"}),e.jsxs("button",{type:"submit",disabled:F,className:"bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs px-4 py-2 rounded-lg transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1.5 shadow-3xs",children:[F?e.jsx(w,{className:"animate-spin",size:13}):e.jsx(O,{size:13}),a?t?"重新提交":"Re-submit":t?"上传作品":"Submit"]})]})]})})]}),a&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs text-left",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 mb-4 select-none",children:[e.jsx(ae,{size:16,className:"text-pink-650"}),t?"我的平时学习得分":"My Score & Feedback"]}),o?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-xl flex items-center justify-between shadow-3xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-slate-400 font-bold uppercase tracking-wider",children:t?"学期对接总分":"Weighted Final Grade"}),e.jsxs("h2",{className:"text-3xl font-extrabold text-indigo-700 font-mono mt-1",children:[o.calculated_final_score," ",e.jsx("span",{className:"text-xs text-slate-455 font-normal",children:"/ 100"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("span",{className:`inline-block px-2.5 py-1 text-xs font-bold rounded-lg border ${o.status==="confirmed"?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-amber-50 text-amber-700 border-amber-100"}`,children:o.status==="confirmed"?t?"已确认同步":"Synced":t?"教师评分草稿":"Draft"}),e.jsx("p",{className:"text-xs text-slate-400 mt-1.5 font-medium",children:t?`教师分 ${o.teacher_score} (占 ${(o.teacher_weight*100).toFixed(0)}%)`:`Teacher ${o.teacher_score} (${(o.teacher_weight*100).toFixed(0)}%)`}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5 font-medium",children:t?`学生互评 (占 ${(o.peer_weight*100).toFixed(0)}%)`:`Peer Review (${(o.peer_weight*100).toFixed(0)}%)`})]})]}),o.teacher_comment&&e.jsxs("div",{className:"bg-slate-100/60 p-3 rounded-lg border border-slate-200 flex gap-2",children:[e.jsx(ie,{size:14,className:"text-slate-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500",children:t?"教师寄语":"Teacher Comments"}),e.jsx("p",{className:"text-xs text-slate-650 mt-0.5",children:o.teacher_comment})]})]})]}):e.jsx("div",{className:"bg-white border border-slate-150 p-4 rounded-xl flex items-center justify-center text-slate-400 italic text-xs py-8",children:t?"教师尚未确认最终成绩与权重折算。":"Teacher grading is in progress."})]})]}),e.jsxs("div",{className:"flex-grow bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs flex flex-col min-h-[400px] text-left",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 mb-4 shrink-0 select-none",children:[e.jsx(ne,{size:16,className:"text-teal-700"}),t?"同学作业互评公开板":"Classmate Submissions for Peer Review"]}),U.length===0?e.jsx("div",{className:"flex-grow flex items-center justify-center text-subtle italic text-xs py-12 border border-dashed border-slate-200 rounded-xl bg-white",children:t?"当前暂无同学提交作业作品。":"No classmate submissions available yet."}):e.jsx("div",{className:"flex-grow overflow-y-auto space-y-4 pr-1",children:U.map(s=>{const n=X.find(m=>m.submission_id===s.id),r=k[s.id]!==void 0?k[s.id]:n?n.score:85,h=_[s.id]!==void 0?_[s.id]:n?n.comment:"",d=Y[s.id]||!1,p=Array.isArray(s.files)?s.files:[],j=v(s.file_path||q(s,p[0])||null),u=j||v(s.linkUrl)||null;return e.jsxs("div",{className:"bg-white border border-slate-200 rounded-xl p-4 shadow-3xs flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-start border-b border-slate-100 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-indigo-50 text-indigo-700 flex items-center justify-center font-bold text-xs select-none",children:s.student_name?s.student_name[0]:"?"}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-slate-700",children:s.student_name||s.student_id}),e.jsxs("p",{className:"text-xs text-slate-400 font-mono flex items-center gap-1 mt-0.5 truncate max-w-[200px]",title:s.file_path||void 0,children:[e.jsx(re,{size:11,className:"text-slate-350"}),H(s)," (V",s.version,")"]})]})]}),u?e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-bold text-indigo-600 hover:text-indigo-800 transition-colors border border-indigo-100 px-2 py-1 rounded bg-indigo-50/50 hover:bg-indigo-50 shrink-0",children:j?t?"下载查阅":"Download File":t?"打开链接":"Open Link"}):e.jsx("span",{className:"text-xs text-slate-400 px-2 py-1 border border-slate-200 rounded bg-white shrink-0",children:t?"无附件":"No File"})]}),s.textContent&&e.jsx("p",{className:"text-xs text-slate-600 whitespace-pre-wrap break-all max-h-24 overflow-auto bg-slate-50 border border-slate-100 rounded-lg p-2",children:s.textContent}),e.jsx(M,{slot:"assignment.submission.preview",slotProps:{submission:s,studentId:s.student_id,lessonId:i,isSelf:!1,lang:x}}),n&&e.jsxs("div",{className:"bg-emerald-50/50 border border-emerald-100 p-2.5 rounded-lg flex items-start gap-2 text-xs text-emerald-800",children:[e.jsx(le,{className:"text-emerald-500 shrink-0 mt-0.5",size:14}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-bold flex items-center gap-1",children:t?`我已评分:${n.score} 分`:`My Score: ${n.score} pts`}),n.comment&&e.jsxs("p",{className:"text-xs text-emerald-700/80 mt-0.5 italic",children:['"',n.comment,'"']})]})]}),e.jsxs("div",{className:"bg-slate-50/60 border border-slate-100 rounded-lg p-3 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:t?"滑动或输入互评分数":"Peer Rating"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"number",min:"0",max:"100",value:r,onChange:m=>{const g=Math.min(100,Math.max(0,parseInt(m.target.value)||0));A(C=>({...C,[s.id]:g}))},className:"w-12 text-center text-xs font-bold font-mono border border-slate-200 rounded px-1 py-0.5 bg-white text-indigo-750"}),e.jsx("span",{className:"text-xs text-slate-400 font-bold",children:t?"分":"pts"})]})]}),e.jsx("input",{type:"range",min:"0",max:"100",value:r,onChange:m=>{const g=parseInt(m.target.value);A(C=>({...C,[s.id]:g}))},className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("textarea",{rows:1,value:h,onChange:m=>{D(g=>({...g,[s.id]:m.target.value}))},placeholder:t?"简要评语反馈...":"Brief feedback comment...",className:"flex-1 bg-white border border-slate-200 px-2 py-1 text-xs rounded-lg text-slate-700 focus:outline-none focus:border-indigo-400 resize-none transition-colors"}),e.jsxs("button",{onClick:()=>Q(s.id,s.student_id),disabled:d,className:"bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs px-3 rounded-lg transition-colors cursor-pointer disabled:opacity-50 flex items-center justify-center",children:[d?e.jsx(w,{className:"animate-spin",size:13}):e.jsx(oe,{size:13}),e.jsx("span",{className:"ml-1 shrink-0",children:n?t?"修改评分":"Update":t?"确认提交":"Submit"})]})]})]})]},s.id)})})]}),z&&a?.assignment_id&&e.jsx(Z,{assignmentId:String(a.assignment_id),file:z,lang:x,onClose:()=>$(null)})]})}export{he as S};
|
|
1
|
+
import{r as c,j as e}from"./vendor-react-DHoBZpn2.js";import{s as v,E as M}from"./index-7CK1B0tE.js";import{A as Z}from"./AssignmentFilePreview-7fHtUuUL.js";import{R as w,ac as O,b7 as I,a4 as ee,y as se,C as te,q as ae,_ as ie,a as ne,D as re,a8 as le,t as oe}from"./vendor-icons-CqLdl4B_.js";function de(i){if(!i)return"";const l=i.split("/");return l[l.length-1]||i}function H(i){const l=de(i?.file_path);if(l)return l;const x=Array.isArray(i?.files)?i.files:[];return x.length===1?x[0]?.name||"附件":x.length>1?`${x.length} 个附件`:i?.textContent?"文字作答":i?.linkUrl?"链接作答":"已提交(无附件)"}function q(i,l){return!l?.fileId||!i?.assignment_id?null:`/api/assignments/${i.assignment_id}/files/${l.fileId}`}function he({lessonId:i,studentId:l,lang:x,addToast:f}){const[B,S]=c.useState(!1),[T,R]=c.useState(!1),[N,V]=c.useState(null),[W,G]=c.useState([]),[y,J]=c.useState(""),[z,$]=c.useState(null),[F,P]=c.useState(!1),[k,A]=c.useState({}),[_,D]=c.useState({}),[Y,L]=c.useState({}),t=x==="zh",b=async(s=!1)=>{s?R(!0):S(!0);try{const r=await(await fetch(`/api/lessons/${i}/students/${l}/eval-status`)).json();V(r);const d=await(await fetch(`/api/lessons/${i}/eval-submissions`)).json();G(d)}catch(n){console.error("Error fetching eval data:",n),f(t?"数据加载失败":"Failed to Load Data",t?"请检查网络连接或刷新页面。":"Please check your connection and try again.","warning")}finally{S(!1),R(!1)}};c.useEffect(()=>{i&&l&&b()},[i,l]);const K=async s=>{s.preventDefault(),y.trim(),P(!0);try{const r=await(await fetch(`/api/lessons/${i}/eval-submissions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentId:l,filePath:y.trim()||void 0})})).json();if(r.success)f(t?"作业提交成功":"Assignment Submitted",t?`成功提交版本 ${r.version}!`:`Successfully submitted version ${r.version}!`,"success"),b(!0);else throw new Error(r.error||"Failed to submit assignment")}catch(n){f(t?"提交失败":"Submission Failed",n.message,"warning")}finally{P(!1)}},Q=async(s,n)=>{const r=k[s],h=_[s]||"";if(r===void 0||isNaN(r)||r<0||r>100){f(t?"评分无效":"Invalid Score",t?"分数必须在 0 到 100 之间!":"Score must be between 0 and 100!","warning");return}L(d=>({...d,[s]:!0}));try{const p=await(await fetch(`/api/lessons/${i}/eval-submissions/${s}/reviews`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:Number(r),comment:h})})).json();if(p.success)f(t?"互评提交成功":"Review Submitted",t?"成功对同学的作品完成了评价!":"Successfully completed review for classmate!","success"),D(j=>{const u={...j};return delete u[s],u}),b(!0);else throw new Error(p.error||"Failed to submit review")}catch(d){f(t?"评价提交失败":"Review Failed",d.message,"warning")}finally{L(d=>({...d,[s]:!1}))}};if(B)return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-gray-500",children:[e.jsx(w,{className:"animate-spin text-indigo-500 mb-2",size:32}),e.jsx("p",{children:t?"正在读取作业互评状态...":"Loading assignment status..."})]});const a=N?.submission,E=v(a?.linkUrl),o=N?.grade,X=N?.reviewsWritten||[],U=W.filter(s=>s.student_id!==l);return e.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-6 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"w-full lg:w-5/12 flex flex-col gap-6",children:[e.jsxs("div",{className:"bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs text-left",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 select-none",children:[e.jsx(O,{size:16,className:"text-indigo-600"}),t?"我的作业提交":"My Assignment Submission"]}),e.jsx("button",{onClick:()=>b(!0),className:"p-1 hover:bg-slate-200/50 rounded transition-colors text-slate-550",title:t?"刷新数据":"Refresh Data",children:e.jsx(w,{size:14,className:T?"animate-spin":""})})]}),a?e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-xl space-y-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"bg-emerald-50 text-emerald-600 p-2.5 rounded-lg border border-emerald-100",children:e.jsx(I,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-slate-400 font-medium",children:t?"当前已提交版本":"Currently Submitted Version"}),e.jsx("p",{className:"text-sm font-semibold text-slate-700 truncate",children:H(a)})]}),e.jsxs("span",{className:"bg-indigo-100 text-indigo-700 text-xs font-bold px-2 py-0.5 rounded-full border border-indigo-200",children:["V",a.version]})]}),e.jsxs("div",{className:"border-t border-slate-100 pt-2.5 flex justify-between items-center text-xs text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ee,{size:11}),t?"更新时间:":"Updated At:"," ",new Date(a.updated_at).toLocaleString()]}),e.jsx("span",{className:"font-mono text-slate-350 select-all truncate max-w-[120px]",title:a.file_path||void 0,children:a.file_path||"—"})]}),(a.textContent||a.linkUrl||Array.isArray(a.files)&&a.files.length>0)&&e.jsxs("div",{className:"border-t border-slate-100 pt-2.5 space-y-1 text-xs text-slate-600",children:[a.textContent&&e.jsx("p",{className:"whitespace-pre-wrap break-all max-h-20 overflow-hidden",children:a.textContent}),E&&e.jsx("a",{href:E,target:"_blank",rel:"noopener noreferrer",className:"block truncate text-indigo-600 hover:underline",children:a.linkUrl}),Array.isArray(a.files)&&a.files.map((s,n)=>{const r=v(q(a,s)),h=!!(r&&a?.assignment_id&&s?.fileId);return e.jsxs("span",{className:"flex items-center gap-1.5",children:[h&&e.jsx("button",{onClick:()=>$({id:String(s.fileId),original_name:String(s.name??s.fileId),size:Number(s.size??0),mime:s.mime??null}),className:"p-0.5 rounded text-indigo-600 hover:bg-indigo-50 shrink-0",title:t?"预览":"Preview","aria-label":t?`预览 ${s.name}`:`Preview ${s.name}`,"data-testid":"student-assignment-file-preview",children:e.jsx(se,{size:11})}),r?e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"block truncate text-indigo-600 hover:underline",children:s.name}):e.jsx("span",{className:"block truncate",children:s.name})]},s.fileId??n)})]}),e.jsx(M,{slot:"assignment.submission.preview",slotProps:{submission:a,studentId:l,lessonId:i,isSelf:!0,lang:x}})]}):e.jsxs("div",{className:"bg-amber-50/50 border border-amber-100 p-4 rounded-xl flex items-start gap-3 mb-4 text-left",children:[e.jsx(te,{className:"text-amber-500 shrink-0 mt-0.5",size:16}),e.jsxs("div",{className:"text-xs text-amber-700",children:[e.jsx("p",{className:"font-bold",children:t?"未提交作业":"No Submission Yet"}),e.jsx("p",{className:"mt-1",children:t?"在此上传提交后,其他同学将可以对您的作业进行评分互评。":"Once submitted, other students can view and peer-review your work."})]})]}),e.jsx("form",{onSubmit:K,className:"space-y-3",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:t?"输入作品文件路径 / 虚拟路径":"Simulated File Path"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:y,onChange:s=>J(s.target.value),placeholder:"/files/homework.pdf",required:!0,className:"flex-1 bg-white border border-slate-200 px-3 py-2 text-xs rounded-lg text-slate-700 focus:outline-none focus:border-indigo-400 font-mono transition-colors"}),e.jsxs("button",{type:"submit",disabled:F,className:"bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs px-4 py-2 rounded-lg transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1.5 shadow-3xs",children:[F?e.jsx(w,{className:"animate-spin",size:13}):e.jsx(O,{size:13}),a?t?"重新提交":"Re-submit":t?"上传作品":"Submit"]})]})]})})]}),a&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs text-left",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 mb-4 select-none",children:[e.jsx(ae,{size:16,className:"text-pink-650"}),t?"我的平时学习得分":"My Score & Feedback"]}),o?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-xl flex items-center justify-between shadow-3xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-slate-400 font-bold uppercase tracking-wider",children:t?"学期对接总分":"Weighted Final Grade"}),e.jsxs("h2",{className:"text-3xl font-extrabold text-indigo-700 font-mono mt-1",children:[o.calculated_final_score," ",e.jsx("span",{className:"text-xs text-slate-455 font-normal",children:"/ 100"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("span",{className:`inline-block px-2.5 py-1 text-xs font-bold rounded-lg border ${o.status==="confirmed"?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-amber-50 text-amber-700 border-amber-100"}`,children:o.status==="confirmed"?t?"已确认同步":"Synced":t?"教师评分草稿":"Draft"}),e.jsx("p",{className:"text-xs text-slate-400 mt-1.5 font-medium",children:t?`教师分 ${o.teacher_score} (占 ${(o.teacher_weight*100).toFixed(0)}%)`:`Teacher ${o.teacher_score} (${(o.teacher_weight*100).toFixed(0)}%)`}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5 font-medium",children:t?`学生互评 (占 ${(o.peer_weight*100).toFixed(0)}%)`:`Peer Review (${(o.peer_weight*100).toFixed(0)}%)`})]})]}),o.teacher_comment&&e.jsxs("div",{className:"bg-slate-100/60 p-3 rounded-lg border border-slate-200 flex gap-2",children:[e.jsx(ie,{size:14,className:"text-slate-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500",children:t?"教师寄语":"Teacher Comments"}),e.jsx("p",{className:"text-xs text-slate-650 mt-0.5",children:o.teacher_comment})]})]})]}):e.jsx("div",{className:"bg-white border border-slate-150 p-4 rounded-xl flex items-center justify-center text-slate-400 italic text-xs py-8",children:t?"教师尚未确认最终成绩与权重折算。":"Teacher grading is in progress."})]})]}),e.jsxs("div",{className:"flex-grow bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs flex flex-col min-h-[400px] text-left",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 mb-4 shrink-0 select-none",children:[e.jsx(ne,{size:16,className:"text-teal-700"}),t?"同学作业互评公开板":"Classmate Submissions for Peer Review"]}),U.length===0?e.jsx("div",{className:"flex-grow flex items-center justify-center text-subtle italic text-xs py-12 border border-dashed border-slate-200 rounded-xl bg-white",children:t?"当前暂无同学提交作业作品。":"No classmate submissions available yet."}):e.jsx("div",{className:"flex-grow overflow-y-auto space-y-4 pr-1",children:U.map(s=>{const n=X.find(m=>m.submission_id===s.id),r=k[s.id]!==void 0?k[s.id]:n?n.score:85,h=_[s.id]!==void 0?_[s.id]:n?n.comment:"",d=Y[s.id]||!1,p=Array.isArray(s.files)?s.files:[],j=v(s.file_path||q(s,p[0])||null),u=j||v(s.linkUrl)||null;return e.jsxs("div",{className:"bg-white border border-slate-200 rounded-xl p-4 shadow-3xs flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-start border-b border-slate-100 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-indigo-50 text-indigo-700 flex items-center justify-center font-bold text-xs select-none",children:s.student_name?s.student_name[0]:"?"}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-slate-700",children:s.student_name||s.student_id}),e.jsxs("p",{className:"text-xs text-slate-400 font-mono flex items-center gap-1 mt-0.5 truncate max-w-[200px]",title:s.file_path||void 0,children:[e.jsx(re,{size:11,className:"text-slate-350"}),H(s)," (V",s.version,")"]})]})]}),u?e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-bold text-indigo-600 hover:text-indigo-800 transition-colors border border-indigo-100 px-2 py-1 rounded bg-indigo-50/50 hover:bg-indigo-50 shrink-0",children:j?t?"下载查阅":"Download File":t?"打开链接":"Open Link"}):e.jsx("span",{className:"text-xs text-slate-400 px-2 py-1 border border-slate-200 rounded bg-white shrink-0",children:t?"无附件":"No File"})]}),s.textContent&&e.jsx("p",{className:"text-xs text-slate-600 whitespace-pre-wrap break-all max-h-24 overflow-auto bg-slate-50 border border-slate-100 rounded-lg p-2",children:s.textContent}),e.jsx(M,{slot:"assignment.submission.preview",slotProps:{submission:s,studentId:s.student_id,lessonId:i,isSelf:!1,lang:x}}),n&&e.jsxs("div",{className:"bg-emerald-50/50 border border-emerald-100 p-2.5 rounded-lg flex items-start gap-2 text-xs text-emerald-800",children:[e.jsx(le,{className:"text-emerald-500 shrink-0 mt-0.5",size:14}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-bold flex items-center gap-1",children:t?`我已评分:${n.score} 分`:`My Score: ${n.score} pts`}),n.comment&&e.jsxs("p",{className:"text-xs text-emerald-700/80 mt-0.5 italic",children:['"',n.comment,'"']})]})]}),e.jsxs("div",{className:"bg-slate-50/60 border border-slate-100 rounded-lg p-3 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:t?"滑动或输入互评分数":"Peer Rating"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"number",min:"0",max:"100",value:r,onChange:m=>{const g=Math.min(100,Math.max(0,parseInt(m.target.value)||0));A(C=>({...C,[s.id]:g}))},className:"w-12 text-center text-xs font-bold font-mono border border-slate-200 rounded px-1 py-0.5 bg-white text-indigo-750"}),e.jsx("span",{className:"text-xs text-slate-400 font-bold",children:t?"分":"pts"})]})]}),e.jsx("input",{type:"range",min:"0",max:"100",value:r,onChange:m=>{const g=parseInt(m.target.value);A(C=>({...C,[s.id]:g}))},className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("textarea",{rows:1,value:h,onChange:m=>{D(g=>({...g,[s.id]:m.target.value}))},placeholder:t?"简要评语反馈...":"Brief feedback comment...",className:"flex-1 bg-white border border-slate-200 px-2 py-1 text-xs rounded-lg text-slate-700 focus:outline-none focus:border-indigo-400 resize-none transition-colors"}),e.jsxs("button",{onClick:()=>Q(s.id,s.student_id),disabled:d,className:"bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs px-3 rounded-lg transition-colors cursor-pointer disabled:opacity-50 flex items-center justify-center",children:[d?e.jsx(w,{className:"animate-spin",size:13}):e.jsx(oe,{size:13}),e.jsx("span",{className:"ml-1 shrink-0",children:n?t?"修改评分":"Update":t?"确认提交":"Submit"})]})]})]})]},s.id)})})]}),z&&a?.assignment_id&&e.jsx(Z,{assignmentId:String(a.assignment_id),file:z,lang:x,onClose:()=>$(null)})]})}export{he as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as N}from"./vendor-react-DHoBZpn2.js";import{E as z,k as T,M as q}from"./index-XduPa2-x.js";import{k as _,au as C,h as A,m as S,T as E,X as R}from"./vendor-icons-DLOPlM4i.js";import{L as O}from"./LazyWhiteboard-CsF9GB6J.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-DVWGghIL.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-skggaP9D.js";function I(x){const{setStudentViewStatus:s,setSelectedAssignment:i,selectedAssignment:o}=x;return e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>{s("dashboard"),i(null)},className:"flex items-center gap-2 text-indigo-600 hover:text-indigo-800 transition-colors font-medium text-sm",children:[e.jsx(_,{className:"rotate-180",size:16})," Back to Dashboard"]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("h2",{className:"text-xl font-bold text-gray-800",children:["Assignment: ",o.title]}),e.jsx(z,{slot:"student.assignment.toolbar.action",slotProps:{assignment:o}})]})]})}function Q(x){const{selectedAssignment:s,quizStudentAnswers:i,setQuizStudentAnswers:o,submitQuizAssignment:d}=x,m=T.match(s?.content);if(m){const n=m.config,r={assignment:s,answers:i,setAnswers:t=>o?.(t),lang:"zh"};return e.jsxs("div",{className:"w-1/3 border-r border-gray-100 pr-4 overflow-y-auto hidden md:block",children:[e.jsx("div",{className:"flex justify-between items-center mb-4",children:e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-indigo-500 bg-indigo-50 border border-indigo-100 p-2.5 rounded-lg flex items-center gap-1.5 w-full",children:n.label})}),n.render(r),!s.submission_status&&e.jsx("div",{className:"mt-6 border-t border-gray-100 pt-4",children:e.jsx("button",{onClick:async()=>{if(n.validate){const t=n.validate(r);if(t){window.alert(t);return}}n.buildSubmission&&o?.(n.buildSubmission(r)),await d(!1)},className:"w-full py-2 bg-indigo-600 text-white rounded-lg shadow font-medium hover:bg-indigo-700 transition",children:"Submit"})})]})}return e.jsxs("div",{className:"w-1/3 border-r border-gray-100 pr-4 overflow-y-auto hidden md:block",children:[e.jsx("div",{className:"flex justify-between items-center mb-4",children:e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400",children:s?.content&&s.content.startsWith('{"quizType":"mcq_learning_objectives"')?"Assessment":"Question"})}),s?.content&&s.content.startsWith('{"quizType":"mcq_learning_objectives"')?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wider text-teal-700 bg-teal-50 border border-teal-100 p-2.5 rounded-lg flex items-center gap-1.5 font-sans",children:[e.jsx(C,{size:12,className:"text-teal-600 animate-pulse"})," AI Interactive Evaluation"]}),e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed font-sans",children:"This assessment was automatically mapped to the core learning objectives of your lesson by our tutoring assistant compiler."}),(()=>{try{const n=JSON.parse(s.content);return e.jsxs("div",{className:"space-y-2 font-sans",children:[e.jsx("div",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider",children:"Lesson Learning Objectives:"}),e.jsx("ul",{className:"space-y-1.5",children:(n.learningObjectives||[]).map((r,t)=>e.jsxs("li",{className:"text-xs text-gray-755 flex items-start gap-1.5 font-medium leading-normal",children:[e.jsx("span",{className:"text-indigo-500 shrink-0 select-none",children:"🎯"}),e.jsx("span",{children:r})]},t))})]})}catch{return null}})()]}):e.jsx("div",{className:"prose prose-sm prose-indigo max-w-none mb-6",children:e.jsx(q,{children:s.content||""})}),!s.submission_status&&e.jsxs("div",{className:"mt-8 border-t border-gray-100 pt-6",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 mb-2",children:"Ready to submit?"}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:s?.content&&s.content.startsWith('{"quizType":"mcq_learning_objectives"')?"Please answer all the interactive questions on the evaluation sheet, then click Submit.":"You can use the whiteboard to draw or answer, then click submit when finished."}),e.jsx("button",{onClick:async()=>{const n=s?.content&&s.content.startsWith('{"quizType":"mcq_learning_objectives"');if(n&&JSON.stringify(i),n)try{const r=JSON.parse(s.content),t=Object.keys(i).length;if(t<r.questions.length&&!window.confirm(`You have only answered ${t}/${r.questions.length} questions. Are you sure you want to submit your answers?`))return}catch{}await d(!1)},className:"w-full py-2 bg-indigo-600 text-white rounded-lg shadow font-medium hover:bg-indigo-700 transition",children:"Submit"})]}),s.submission_status==="graded"&&s.feedback&&e.jsxs("div",{className:"mt-6 bg-green-50 p-4 rounded-xl border border-green-100",children:[e.jsxs("div",{className:"font-semibold text-green-800 text-sm mb-1 flex items-center gap-1",children:[e.jsx(A,{size:16})," Grade: ",s.score,"%"]}),e.jsx("div",{className:"text-xs text-green-700 whitespace-pre-wrap leading-relaxed font-sans",children:s.feedback})]})]})}function W({assignmentId:x,timeLimitMinutes:s,onTimeUp:i,isSubmitted:o}){const[d,m]=N.useState(null);if(N.useEffect(()=>{if(o||!s||s<=0){m(null);return}const a=`quiz_timer_start_${x}`;let u=sessionStorage.getItem(a),g=u?parseInt(u,10):null;g||(g=Date.now(),sessionStorage.setItem(a,g.toString()));const l=s*60,c=()=>{const j=Math.floor((Date.now()-g)/1e3),h=l-j;h<=0?(m(0),i()):m(h)};c();const b=setInterval(c,1e3);return()=>clearInterval(b)},[x,s,o,i]),!s||s<=0)return null;if(o)return e.jsxs("div",{className:"flex items-center gap-2 font-sans text-xs bg-gray-100 text-gray-600 px-3 py-1.5 rounded-lg border border-gray-200",children:[e.jsx(S,{size:14}),e.jsxs("span",{children:["Time Limit: ",s," mins (Completed)"]})]});if(d===null)return null;const n=Math.floor(d/60),r=d%60,t=d<60;return e.jsxs("div",{className:`flex items-center gap-3 font-sans px-4 py-2.5 rounded-xl border transition-all ${t?"bg-red-50 text-red-700 border-red-200 animate-pulse font-bold":d<180?"bg-amber-50 text-amber-700 border-amber-200 font-semibold":"bg-indigo-50 text-indigo-700 border-indigo-100"}`,children:[e.jsx(S,{size:16,className:t?"text-red-600 animate-pulse":"text-indigo-600"}),e.jsxs("div",{className:"flex-1 flex justify-between items-center text-xs gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Time Remaining:"}),e.jsxs("span",{className:"font-mono ml-1 text-sm bg-black/5 text-slate-800 px-1.5 py-0.5 rounded font-bold",children:[n.toString().padStart(2,"0"),":",r.toString().padStart(2,"0")]})]}),t&&e.jsxs("span",{className:"flex items-center gap-1 text-xs uppercase tracking-wider text-red-600 font-bold animate-pulse",children:[e.jsx(E,{size:12})," Time is almost up!"]})]})]})}function P(x){const{selectedAssignment:s,subAssignmentTab:i,setSubAssignmentTab:o,quizStudentAnswers:d,setQuizStudentAnswers:m,submitQuizAssignment:n,elements:r,activeRole:t,activeStudentId:a,fetchElements:u}=x;return e.jsx("div",{className:"flex-1 relative flex flex-col min-h-0",children:(()=>{const g=s?.content&&s.content.startsWith('{"quizType":"mcq_learning_objectives"');return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 pointer-events-none",children:g&&i==="quiz"?"Evaluation Sheet":"Live Canvas"}),g&&e.jsxs("div",{className:"flex bg-gray-100 p-0.5 rounded-lg border border-gray-200 text-xs",children:[e.jsx("button",{onClick:()=>o("quiz"),className:`px-2.5 py-0.5 rounded text-xs font-bold transition-all ${i==="quiz"?"bg-white text-indigo-700 shadow-sm":"text-gray-500 hover:text-gray-900"}`,children:"Interactive Test"}),e.jsx("button",{onClick:()=>o("whiteboard"),className:`px-2.5 py-0.5 rounded text-xs font-bold transition-all ${i==="whiteboard"?"bg-white text-indigo-700 shadow-sm":"text-gray-500 hover:text-gray-900"}`,children:"Sketch Whiteboard"})]})]}),s.submission_status&&e.jsx("div",{className:"text-xs uppercase font-bold text-gray-400 bg-gray-100 px-2 py-0.5 rounded",children:"Read Only"})]}),g&&i==="quiz"?e.jsx("div",{className:"flex-1 bg-gray-50/50 rounded-xl border border-gray-200 p-6 overflow-y-auto space-y-6",children:(()=>{try{const l=JSON.parse(s.content);return e.jsxs(e.Fragment,{children:[l.timeLimit>0&&e.jsx(W,{assignmentId:s.id,timeLimitMinutes:l.timeLimit,onTimeUp:()=>n(!0),isSubmitted:!!s.submission_status}),l.questions.map((c,b)=>{const j=d[b],h=!!s.submission_status,v=d[b]===c.correctAnswer;return e.jsxs("div",{className:"bg-white p-5 rounded-xl border border-gray-100 shadow-sm space-y-3 font-sans",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-6 h-6 rounded-full bg-indigo-50 text-indigo-700 flex items-center justify-center text-xs font-bold ring-1 ring-indigo-100",children:b+1}),e.jsxs("span",{className:"text-xs font-semibold text-teal-700 bg-teal-50 px-2.5 py-0.5 rounded-full border border-teal-100",children:["evaluates: ",c.objective]})]}),h&&e.jsx("span",{className:`text-xs font-bold px-2.5 py-0.5 rounded-full ${v?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:v?"Correct ✓":`Incorrect (Correct Option: ${c.correctAnswer})`})]}),e.jsx("div",{className:"font-semibold text-gray-800 text-sm",children:c.question}),e.jsx("div",{className:"grid grid-cols-2 gap-3 text-xs pt-1",children:c.options.map((f,k)=>{const y=j===f,w=f===c.correctAnswer;let p="border-gray-200 hover:border-gray-300 bg-white text-gray-700 hover:bg-gray-50/50 cursor-pointer";return h?y?p=w?"border-green-600 bg-green-50 text-green-900 ring-2 ring-green-100":"border-red-600 bg-red-50 text-red-900 ring-2 ring-red-100":w?p="border-green-400 bg-green-50/20 text-green-900":p="border-gray-200 opacity-60 text-gray-400":y&&(p="border-indigo-600 bg-indigo-50/30 text-indigo-900 ring-2 ring-indigo-100 font-medium cursor-pointer"),e.jsxs("div",{onClick:()=>{h||m($=>({...$,[b]:f}))},className:`p-3 rounded-xl border transition-all duration-150 flex items-center justify-between ${p}`,children:[e.jsx("span",{children:f}),y&&(h?w?e.jsx(A,{size:14,className:"text-green-600 shrink-0"}):e.jsx(R,{size:14,className:"text-red-600 shrink-0"}):e.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-600 shadow-sm shrink-0"}))]},k)})})]},b)})]})}catch{return e.jsx("div",{className:"text-xs text-red-500 font-sans",children:"Error parsing quiz structure."})}})()}):e.jsx("div",{className:`flex-1 min-h-0 flex flex-col ${s.submission_status?"opacity-90 pointer-events-none filter grayscale-[0.2]":""}`,children:e.jsx(O,{lessonId:`assignment-${s.id}-student-${a}`,elements:r,userRole:t,enableAutoAI:t==="student"&&!s.submission_status,onElementAdd:async(l,c)=>{await fetch(`/api/lessons/assignment-${s.id}-student-${a}/whiteboard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:l,data:c})}),u(`assignment-${s.id}-student-${a}`)},onElementUpdate:async(l,c)=>{await fetch(`/api/lessons/assignment-${s.id}-student-${a}/whiteboard/${l}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:c})}),u(`assignment-${s.id}-student-${a}`)},onElementDelete:async l=>{await fetch(`/api/lessons/assignment-${s.id}-student-${a}/whiteboard/${l}`,{method:"DELETE"}),u(`assignment-${s.id}-student-${a}`)},onClearBoard:async()=>{await fetch(`/api/lessons/assignment-${s.id}-student-${a}/whiteboard`,{method:"DELETE"}),u(`assignment-${s.id}-student-${a}`)},onRefresh:()=>u(`assignment-${s.id}-student-${a}`)})})]})})()})}function H(x){const{selectedAssignment:s,setStudentViewStatus:i,setSelectedAssignment:o,quizStudentAnswers:d,submitQuizAssignment:m,subAssignmentTab:n,setSubAssignmentTab:r,setQuizStudentAnswers:t,elements:a,activeRole:u,activeStudentId:g,fetchElements:l}=x;return e.jsxs("div",{className:"flex flex-col h-full space-y-4",children:[e.jsx(I,{setStudentViewStatus:i,setSelectedAssignment:o,selectedAssignment:s}),e.jsxs("div",{className:"flex-1 flex gap-6 min-h-0 bg-white border border-gray-200 rounded-xl p-4 shadow-sm",children:[e.jsx(Q,{selectedAssignment:s,quizStudentAnswers:d,setQuizStudentAnswers:t,submitQuizAssignment:m}),e.jsx(P,{selectedAssignment:s,subAssignmentTab:n,setSubAssignmentTab:r,quizStudentAnswers:d,setQuizStudentAnswers:t,submitQuizAssignment:m,elements:a,activeRole:u,activeStudentId:g,fetchElements:l})]})]})}export{H as StudentAssignmentView};
|
|
1
|
+
import{j as e,r as N}from"./vendor-react-DHoBZpn2.js";import{E as z,l as T,M as q}from"./index-7CK1B0tE.js";import{k as _,ax as C,h as A,m as S,T as E,X as R}from"./vendor-icons-CqLdl4B_.js";import{L as O}from"./LazyWhiteboard-NPD1EoyO.js";import"./vendor-utils-BxOuk3id.js";import"./vendor-pdf-BMEc_Clb.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-skggaP9D.js";function I(x){const{setStudentViewStatus:s,setSelectedAssignment:i,selectedAssignment:o}=x;return e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>{s("dashboard"),i(null)},className:"flex items-center gap-2 text-indigo-600 hover:text-indigo-800 transition-colors font-medium text-sm",children:[e.jsx(_,{className:"rotate-180",size:16})," Back to Dashboard"]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("h2",{className:"text-xl font-bold text-gray-800",children:["Assignment: ",o.title]}),e.jsx(z,{slot:"student.assignment.toolbar.action",slotProps:{assignment:o}})]})]})}function Q(x){const{selectedAssignment:s,quizStudentAnswers:i,setQuizStudentAnswers:o,submitQuizAssignment:d}=x,m=T.match(s?.content);if(m){const n=m.config,r={assignment:s,answers:i,setAnswers:t=>o?.(t),lang:"zh"};return e.jsxs("div",{className:"w-1/3 border-r border-gray-100 pr-4 overflow-y-auto hidden md:block",children:[e.jsx("div",{className:"flex justify-between items-center mb-4",children:e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-indigo-500 bg-indigo-50 border border-indigo-100 p-2.5 rounded-lg flex items-center gap-1.5 w-full",children:n.label})}),n.render(r),!s.submission_status&&e.jsx("div",{className:"mt-6 border-t border-gray-100 pt-4",children:e.jsx("button",{onClick:async()=>{if(n.validate){const t=n.validate(r);if(t){window.alert(t);return}}n.buildSubmission&&o?.(n.buildSubmission(r)),await d(!1)},className:"w-full py-2 bg-indigo-600 text-white rounded-lg shadow font-medium hover:bg-indigo-700 transition",children:"Submit"})})]})}return e.jsxs("div",{className:"w-1/3 border-r border-gray-100 pr-4 overflow-y-auto hidden md:block",children:[e.jsx("div",{className:"flex justify-between items-center mb-4",children:e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400",children:s?.content&&s.content.startsWith('{"quizType":"mcq_learning_objectives"')?"Assessment":"Question"})}),s?.content&&s.content.startsWith('{"quizType":"mcq_learning_objectives"')?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wider text-teal-700 bg-teal-50 border border-teal-100 p-2.5 rounded-lg flex items-center gap-1.5 font-sans",children:[e.jsx(C,{size:12,className:"text-teal-600 animate-pulse"})," AI Interactive Evaluation"]}),e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed font-sans",children:"This assessment was automatically mapped to the core learning objectives of your lesson by our tutoring assistant compiler."}),(()=>{try{const n=JSON.parse(s.content);return e.jsxs("div",{className:"space-y-2 font-sans",children:[e.jsx("div",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider",children:"Lesson Learning Objectives:"}),e.jsx("ul",{className:"space-y-1.5",children:(n.learningObjectives||[]).map((r,t)=>e.jsxs("li",{className:"text-xs text-gray-755 flex items-start gap-1.5 font-medium leading-normal",children:[e.jsx("span",{className:"text-indigo-500 shrink-0 select-none",children:"🎯"}),e.jsx("span",{children:r})]},t))})]})}catch{return null}})()]}):e.jsx("div",{className:"prose prose-sm prose-indigo max-w-none mb-6",children:e.jsx(q,{children:s.content||""})}),!s.submission_status&&e.jsxs("div",{className:"mt-8 border-t border-gray-100 pt-6",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 mb-2",children:"Ready to submit?"}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:s?.content&&s.content.startsWith('{"quizType":"mcq_learning_objectives"')?"Please answer all the interactive questions on the evaluation sheet, then click Submit.":"You can use the whiteboard to draw or answer, then click submit when finished."}),e.jsx("button",{onClick:async()=>{const n=s?.content&&s.content.startsWith('{"quizType":"mcq_learning_objectives"');if(n&&JSON.stringify(i),n)try{const r=JSON.parse(s.content),t=Object.keys(i).length;if(t<r.questions.length&&!window.confirm(`You have only answered ${t}/${r.questions.length} questions. Are you sure you want to submit your answers?`))return}catch{}await d(!1)},className:"w-full py-2 bg-indigo-600 text-white rounded-lg shadow font-medium hover:bg-indigo-700 transition",children:"Submit"})]}),s.submission_status==="graded"&&s.feedback&&e.jsxs("div",{className:"mt-6 bg-green-50 p-4 rounded-xl border border-green-100",children:[e.jsxs("div",{className:"font-semibold text-green-800 text-sm mb-1 flex items-center gap-1",children:[e.jsx(A,{size:16})," Grade: ",s.score,"%"]}),e.jsx("div",{className:"text-xs text-green-700 whitespace-pre-wrap leading-relaxed font-sans",children:s.feedback})]})]})}function W({assignmentId:x,timeLimitMinutes:s,onTimeUp:i,isSubmitted:o}){const[d,m]=N.useState(null);if(N.useEffect(()=>{if(o||!s||s<=0){m(null);return}const a=`quiz_timer_start_${x}`;let u=sessionStorage.getItem(a),g=u?parseInt(u,10):null;g||(g=Date.now(),sessionStorage.setItem(a,g.toString()));const l=s*60,c=()=>{const j=Math.floor((Date.now()-g)/1e3),h=l-j;h<=0?(m(0),i()):m(h)};c();const b=setInterval(c,1e3);return()=>clearInterval(b)},[x,s,o,i]),!s||s<=0)return null;if(o)return e.jsxs("div",{className:"flex items-center gap-2 font-sans text-xs bg-gray-100 text-gray-600 px-3 py-1.5 rounded-lg border border-gray-200",children:[e.jsx(S,{size:14}),e.jsxs("span",{children:["Time Limit: ",s," mins (Completed)"]})]});if(d===null)return null;const n=Math.floor(d/60),r=d%60,t=d<60;return e.jsxs("div",{className:`flex items-center gap-3 font-sans px-4 py-2.5 rounded-xl border transition-all ${t?"bg-red-50 text-red-700 border-red-200 animate-pulse font-bold":d<180?"bg-amber-50 text-amber-700 border-amber-200 font-semibold":"bg-indigo-50 text-indigo-700 border-indigo-100"}`,children:[e.jsx(S,{size:16,className:t?"text-red-600 animate-pulse":"text-indigo-600"}),e.jsxs("div",{className:"flex-1 flex justify-between items-center text-xs gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Time Remaining:"}),e.jsxs("span",{className:"font-mono ml-1 text-sm bg-black/5 text-slate-800 px-1.5 py-0.5 rounded font-bold",children:[n.toString().padStart(2,"0"),":",r.toString().padStart(2,"0")]})]}),t&&e.jsxs("span",{className:"flex items-center gap-1 text-xs uppercase tracking-wider text-red-600 font-bold animate-pulse",children:[e.jsx(E,{size:12})," Time is almost up!"]})]})]})}function P(x){const{selectedAssignment:s,subAssignmentTab:i,setSubAssignmentTab:o,quizStudentAnswers:d,setQuizStudentAnswers:m,submitQuizAssignment:n,elements:r,activeRole:t,activeStudentId:a,fetchElements:u}=x;return e.jsx("div",{className:"flex-1 relative flex flex-col min-h-0",children:(()=>{const g=s?.content&&s.content.startsWith('{"quizType":"mcq_learning_objectives"');return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 pointer-events-none",children:g&&i==="quiz"?"Evaluation Sheet":"Live Canvas"}),g&&e.jsxs("div",{className:"flex bg-gray-100 p-0.5 rounded-lg border border-gray-200 text-xs",children:[e.jsx("button",{onClick:()=>o("quiz"),className:`px-2.5 py-0.5 rounded text-xs font-bold transition-all ${i==="quiz"?"bg-white text-indigo-700 shadow-sm":"text-gray-500 hover:text-gray-900"}`,children:"Interactive Test"}),e.jsx("button",{onClick:()=>o("whiteboard"),className:`px-2.5 py-0.5 rounded text-xs font-bold transition-all ${i==="whiteboard"?"bg-white text-indigo-700 shadow-sm":"text-gray-500 hover:text-gray-900"}`,children:"Sketch Whiteboard"})]})]}),s.submission_status&&e.jsx("div",{className:"text-xs uppercase font-bold text-gray-400 bg-gray-100 px-2 py-0.5 rounded",children:"Read Only"})]}),g&&i==="quiz"?e.jsx("div",{className:"flex-1 bg-gray-50/50 rounded-xl border border-gray-200 p-6 overflow-y-auto space-y-6",children:(()=>{try{const l=JSON.parse(s.content);return e.jsxs(e.Fragment,{children:[l.timeLimit>0&&e.jsx(W,{assignmentId:s.id,timeLimitMinutes:l.timeLimit,onTimeUp:()=>n(!0),isSubmitted:!!s.submission_status}),l.questions.map((c,b)=>{const j=d[b],h=!!s.submission_status,v=d[b]===c.correctAnswer;return e.jsxs("div",{className:"bg-white p-5 rounded-xl border border-gray-100 shadow-sm space-y-3 font-sans",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-6 h-6 rounded-full bg-indigo-50 text-indigo-700 flex items-center justify-center text-xs font-bold ring-1 ring-indigo-100",children:b+1}),e.jsxs("span",{className:"text-xs font-semibold text-teal-700 bg-teal-50 px-2.5 py-0.5 rounded-full border border-teal-100",children:["evaluates: ",c.objective]})]}),h&&e.jsx("span",{className:`text-xs font-bold px-2.5 py-0.5 rounded-full ${v?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:v?"Correct ✓":`Incorrect (Correct Option: ${c.correctAnswer})`})]}),e.jsx("div",{className:"font-semibold text-gray-800 text-sm",children:c.question}),e.jsx("div",{className:"grid grid-cols-2 gap-3 text-xs pt-1",children:c.options.map((f,k)=>{const y=j===f,w=f===c.correctAnswer;let p="border-gray-200 hover:border-gray-300 bg-white text-gray-700 hover:bg-gray-50/50 cursor-pointer";return h?y?p=w?"border-green-600 bg-green-50 text-green-900 ring-2 ring-green-100":"border-red-600 bg-red-50 text-red-900 ring-2 ring-red-100":w?p="border-green-400 bg-green-50/20 text-green-900":p="border-gray-200 opacity-60 text-gray-400":y&&(p="border-indigo-600 bg-indigo-50/30 text-indigo-900 ring-2 ring-indigo-100 font-medium cursor-pointer"),e.jsxs("div",{onClick:()=>{h||m($=>({...$,[b]:f}))},className:`p-3 rounded-xl border transition-all duration-150 flex items-center justify-between ${p}`,children:[e.jsx("span",{children:f}),y&&(h?w?e.jsx(A,{size:14,className:"text-green-600 shrink-0"}):e.jsx(R,{size:14,className:"text-red-600 shrink-0"}):e.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-600 shadow-sm shrink-0"}))]},k)})})]},b)})]})}catch{return e.jsx("div",{className:"text-xs text-red-500 font-sans",children:"Error parsing quiz structure."})}})()}):e.jsx("div",{className:`flex-1 min-h-0 flex flex-col ${s.submission_status?"opacity-90 pointer-events-none filter grayscale-[0.2]":""}`,children:e.jsx(O,{lessonId:`assignment-${s.id}-student-${a}`,elements:r,userRole:t,enableAutoAI:t==="student"&&!s.submission_status,onElementAdd:async(l,c)=>{await fetch(`/api/lessons/assignment-${s.id}-student-${a}/whiteboard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:l,data:c})}),u(`assignment-${s.id}-student-${a}`)},onElementUpdate:async(l,c)=>{await fetch(`/api/lessons/assignment-${s.id}-student-${a}/whiteboard/${l}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:c})}),u(`assignment-${s.id}-student-${a}`)},onElementDelete:async l=>{await fetch(`/api/lessons/assignment-${s.id}-student-${a}/whiteboard/${l}`,{method:"DELETE"}),u(`assignment-${s.id}-student-${a}`)},onClearBoard:async()=>{await fetch(`/api/lessons/assignment-${s.id}-student-${a}/whiteboard`,{method:"DELETE"}),u(`assignment-${s.id}-student-${a}`)},onRefresh:()=>u(`assignment-${s.id}-student-${a}`)})})]})})()})}function H(x){const{selectedAssignment:s,setStudentViewStatus:i,setSelectedAssignment:o,quizStudentAnswers:d,submitQuizAssignment:m,subAssignmentTab:n,setSubAssignmentTab:r,setQuizStudentAnswers:t,elements:a,activeRole:u,activeStudentId:g,fetchElements:l}=x;return e.jsxs("div",{className:"flex flex-col h-full space-y-4",children:[e.jsx(I,{setStudentViewStatus:i,setSelectedAssignment:o,selectedAssignment:s}),e.jsxs("div",{className:"flex-1 flex gap-6 min-h-0 bg-white border border-gray-200 rounded-xl p-4 shadow-sm",children:[e.jsx(Q,{selectedAssignment:s,quizStudentAnswers:d,setQuizStudentAnswers:t,submitQuizAssignment:m}),e.jsx(P,{selectedAssignment:s,subAssignmentTab:n,setSubAssignmentTab:r,quizStudentAnswers:d,setQuizStudentAnswers:t,submitQuizAssignment:m,elements:a,activeRole:u,activeStudentId:g,fetchElements:l})]})]})}export{H as StudentAssignmentView};
|