PageSourceSearch

https://zerde.ai/assets/QuizDetail-CEP4RHOf.js

js zerde.ai collected 2026-10-05 13:32:15 UTC 16,505 bytes, 2 lines download raw bytes

1import{x as Te,q as Qe,t as Re,f as d,j as e,J as u,T as j,B as l,L as Le,am as Ae,K as C,C as S,R as ae,U as D,al as Oe,a1 as Pe,Q as _e}from"./app-DQCW1V05.js";import{L as $e}from"./label-DCzaBmCO.js";import{S as Ie,a as Fe,b as Ue,c as Me,d as Ee}from"./select-D39Q3ou4.js";import{B as k}from"./badge-iSTyHvSS.js";import{S as g}from"./skeleton-DvchcgY_.js";import{T as He,a as Be,b as ie,c as le}from"./tabs-CXykx38R.js";import{P as Ve}from"./progress-DOCOkUH0.js";import{D as N,f as Je,a as v,b as T,c as Q,d as R,e as L}from"./dialog-CfSxp4On.js";import{A as Ke,a as Xe,b as Ge,c as We,d as Ye,e as Ze,f as es,g as ss,h as as}from"./alert-dialog-CfEdOcsl.js";import{d as is,e as ls,f as ts,g as ns,a as rs,h as cs}from"./useQuizzes-DwidaY9w.js";import{a as os}from"./useFormatDate-B4g9KZLa.js";import{T as ds,a as ms,b as te,c as A,d as xs,e as O}from"./table-D-xK0aLY.js";import{A as hs}from"./arrow-left-BS6oloWa.js";import{E as us}from"./eye-Cfecrep0.js";import{S as js}from"./square-pen-D-GwcxWZ.js";import{P as ne}from"./play-sC4Adzc4.js";import{T as ps}from"./timer-BcqUSbdN.js";import{Q as re}from"./qr-code-D_r2Y6I6.js";import{C as ce}from"./copy-Bawi9M9m.js";import{C as gs}from"./clock-QCYaNK_Y.js";import{C as fs}from"./circle-x-BodK2nZH.js";import{T as oe}from"./trophy-p6qkg67t.js";import{M as de}from"./medal-DpVbV9D_.js";import{R as Ns}from"./refresh-cw-BULDHTUh.js";import{D as vs}from"./download-BdA6S4Tz.js";import"./index-DSI6OSeg.js";import"./chevron-up-CoF5NpGj.js";function Ks(){var X,G,W,Y,Z,ee,se;const{id:me}=Te(),p=me||"",{t:a}=Qe(),xe=os(),P=Re(),{data:t,isLoading:he}=is(p),{data:o,isLoading:ue}=ls(p),z=ts(),_=ns(),je=rs(),[pe,$]=d.useState(null),[ge,f]=d.useState(!1),[fe,I]=d.useState(!1),[r,w]=d.useState(0),[F,Ne]=d.useState("45"),[U,b]=d.useState(!1),[M,ve]=d.useState(null),{data:n,isLoading:q,refetch:ze}=cs(M||"",{enabled:!!M&&U}),E=s=>{ve(s),b(!0)},[we,y]=d.useState(!1),[m,be]=d.useState(null),qe=s=>{be(s),y(!0)},H=s=>`${window.location.origin}/sessions/${s}`,B=s=>{const i=H(s);return`https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=${encodeURIComponent(i)}`},ye=async()=>{if(!m)return;const s=B(m),h=await(await fetch(s)).blob(),c=URL.createObjectURL(h),x=document.createElement("a");x.href=c,x.download=`quiz-session-${m}.png`,document.body.appendChild(x),x.click(),document.body.removeChild(x),URL.revokeObjectURL(c)},Ce=[{value:"15",label:a("quizzes.duration15min","15 minutes")},{value:"30",label:a("quizzes.duration30min","30 minutes")},{value:"45",label:a("quizzes.duration45min","45 minutes")},{value:"60",label:a("quizzes.duration1hour","1 hour")},{value:"120",label:a("quizzes.duration2hours","2 hours")},{value:"1440",label:a("quizzes.duration1day","1 day")}],Se=async()=>{try{const s=new Date;s.setMinutes(s.getMinutes()+parseInt(F,10)),await z.mutateAsync({quizId:p,data:{expires_at:s.toISOString()}}),f(!1)}catch{}},De=async s=>{try{await _.mutateAsync({sessionId:s,quizId:p})}catch{}},ke=async()=>{try{await je.mutateAsync(p),P("/quizzes")}catch{}},V=s=>{const i=`${window.location.origin}/sessions/${s}`;navigator.clipboard.writeText(i),$(s),setTimeout(()=>$(null),2e3)},J=(o==null?void 0:o.filter(s=>s.is_active))||[],K=(o==null?void 0:o.filter(s=>!s.is_active))||[];return he?e.jsxs("div",{className:"space-y-6",children:[e.jsx(g,{className:"h-10 w-64"}),e.jsx(g,{className:"h-48"}),e.jsx(g,{className:"h-64"})]}):t?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(l,{variant:"ghost",size:"icon",onClick:()=>P("/quizzes"),children:e.jsx(hs,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:t.title}),t.description&&e.jsx("p",{className:"text-muted-foreground",children:t.description})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(l,{variant:"outline",onClick:()=>{w(0),I(!0)},disabled:!((X=t.questions)!=null&&X.length),children:[e.jsx(us,{className:"h-4 w-4 mr-2"}),a("quizzes.preview")]}),e.jsx(l,{variant:"outline",asChild:!0,children:e.jsxs(Le,{to:`/quizzes/${p}/edit`,children:[e.jsx(js,{className:"h-4 w-4 mr-2"}),a("common.edit")]})}),e.jsxs(Ke,{children:[e.jsx(Xe,{asChild:!0,children:e.jsxs(l,{variant:"destructive",children:[e.jsx(Ae,{className:"h-4 w-4 mr-2"}),a("common.delete")]})}),e.jsxs(Ge,{children:[e.jsxs(We,{children:[e.jsx(Ye,{children:a("common.confirm")}),e.jsx(Ze,{children:a("quizzes.deleteConfirm")})]}),e.jsxs(es,{children:[e.jsx(ss,{children:a("common.cancel")}),e.jsx(as,{onClick:ke,className:"bg-destructive text-destructive-foreground",children:a("common.delete")})]})]})]})]})]}),e.jsxs(He,{defaultValue:"sessions",className:"space-y-4",children:[e.jsxs(Be,{children:[e.jsx(ie,{value:"sessions",children:a("quizzes.sessions")}),e.jsx(ie,{value:"questions",children:a("quizzes.questions")})]}),e.jsxs(le,{value:"sessions",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-xl font-semibold",children:a("quizzes.sessions")}),e.jsxs(N,{open:ge,onOpenChange:f,children:[e.jsx(Je,{asChild:!0,children:e.jsxs(l,{className:"gap-2",children:[e.jsx(ne,{className:"h-4 w-4"}),a("quizzes.startSession")]})}),e.jsxs(v,{children:[e.jsxs(T,{children:[e.jsx(Q,{children:a("quizzes.startNewSession")}),e.jsx(R,{children:a("quizzes.startSessionDescription")})]}),e.jsx("div",{className:"py-4 space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs($e,{htmlFor:"duration",className:"flex items-center gap-2",children:[e.jsx(ps,{className:"h-4 w-4"}),a("quizzes.sessionDuration","Session Duration")]}),e.jsxs(Ie,{value:F,onValueChange:Ne,children:[e.jsx(Fe,{id:"duration",children:e.jsx(Ue,{placeholder:a("quizzes.selectDuration","Select duration")})}),e.jsx(Me,{children:Ce.map(s=>e.jsx(Ee,{value:s.value,children:s.label},s.value))})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("quizzes.durationHint","Students can join and complete the quiz within this time")})]})}),e.jsxs(L,{children:[e.jsx(l,{variant:"outline",onClick:()=>f(!1),children:a("common.cancel")}),e.jsx(l,{onClick:Se,disabled:z.isPending,children:z.isPending?a("common.loading"):a("quizzes.startSession")})]})]})]})]}),ue?e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:[1,2].map(s=>e.jsx(g,{className:"h-40"},s))}):e.jsxs(e.Fragment,{children:[J.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-medium text-green-600",children:a("quizzes.activeSessions")}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:J.map(s=>e.jsxs(u,{className:"border-green-200 bg-green-50/50",children:[e.jsxs(C,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{variant:"default",className:"bg-green-500",children:a("quizzes.active")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>qe(s.id),title:a("quizzes.showQR","Show QR Code"),children:e.jsx(re,{className:"h-4 w-4"})}),e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>V(s.id),className:"gap-2",children:pe===s.id?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"h-4 w-4"}),a("common.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"h-4 w-4"}
1),a("quizzes.copyLink")]})})]})]}),s.expires_at&&e.jsxs(ae,{className:"flex items-center gap-2 mt-2",children:[e.jsx(gs,{className:"h-3 w-3"}),a("quizzes.expiresAt"),": ",new Date(s.expires_at).toLocaleString()]})]}),e.jsxs(j,{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(l,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>E(s.id),children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),a("quizzes.viewResults")]}),e.jsxs(l,{variant:"destructive",size:"sm",onClick:()=>De(s.id),disabled:_.isPending,children:[e.jsx(fs,{className:"h-4 w-4 mr-2"}),a("quizzes.closeSession")]})]}),e.jsxs(l,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>window.open(`/sessions/${s.id}`,"_blank"),children:[e.jsx(Oe,{className:"h-4 w-4 mr-2"}),a("quizzes.openSessionPage")]})]})]},s.id))})]}),K.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-medium text-muted-foreground",children:a("quizzes.closedSessions")}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:K.map(s=>e.jsxs(u,{className:"opacity-70",children:[e.jsx(C,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{variant:"secondary",children:a("quizzes.closed")}),e.jsx(ae,{children:s.created_at&&xe(s.created_at)})]})}),e.jsx(j,{children:e.jsxs(l,{variant:"outline",size:"sm",className:"w-full",onClick:()=>E(s.id),children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),a("quizzes.viewResults")]})})]},s.id))})]}),(o==null?void 0:o.length)===0&&e.jsx(u,{children:e.jsxs(j,{className:"flex flex-col items-center justify-center py-10",children:[e.jsx(ne,{className:"mb-4 h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:a("quizzes.noSessions")}),e.jsxs(l,{onClick:()=>f(!0),className:"gap-2",children:[e.jsx(Pe,{className:"h-4 w-4"}),a("quizzes.startFirstSession")]})]})})]})]}),e.jsxs(le,{value:"questions",className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-xl font-semibold",children:[a("quizzes.questions")," (",((G=t.questions)==null?void 0:G.length)||0,")"]})}),t.questions&&t.questions.length>0?e.jsx("div",{className:"space-y-4",children:t.questions.map((s,i)=>{var h;return e.jsxs(u,{children:[e.jsxs(C,{className:"pb-2",children:[e.jsxs(_e,{className:"text-base",children:[i+1,". ",s.question]}),s.assets&&s.assets.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:s.assets.map((c,x)=>e.jsx("img",{src:c,alt:`Asset ${x+1}`,className:"max-h-32 rounded-md object-contain"},x))})]}),e.jsx(j,{children:e.jsx("div",{className:"grid gap-2",children:(h=s.options)==null?void 0:h.map(c=>e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-md ${c.is_correct?"bg-green-100 border border-green-300":"bg-muted"}`,children:[c.is_correct&&e.jsx(S,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{className:c.is_correct?"font-medium text-green-800":"",children:c.option})]},c.id))})})]},s.id)})}):e.jsx(u,{children:e.jsx(j,{className:"flex flex-col items-center justify-center py-10",children:e.jsx("p",{className:"text-muted-foreground",children:a("quizzes.noQuestions")})})})]})]}),e.jsx(N,{open:fe,onOpenChange:I,children:e.jsx(v,{className:"max-w-4xl h-[90vh] flex flex-col p-0 gap-0",children:e.jsxs("div",{className:"bg-gradient-to-br from-purple-900 to-blue-900 text-white flex-1 flex flex-col",children:[e.jsxs("div",{className:"p-4 flex items-center justify-between border-b border-white/10",children:[e.jsx("div",{className:"text-sm opacity-80",children:a("quizzes.previewMode")}),e.jsxs("div",{className:"text-sm font-medium",children:[r+1," / ",((W=t.questions)==null?void 0:W.length)||0]})]}),e.jsx("div",{className:"px-4 pt-2",children:e.jsx(Ve,{value:(r+1)/(((Y=t.questions)==null?void 0:Y.length)||1)*100,className:"h-2"})}),t.questions&&t.questions[r]&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-6",children:[e.jsx(u,{className:"w-full max-w-3xl mb-6",children:e.jsxs(j,{className:"py-8",children:[e.jsx("h2",{className:"text-xl md:text-2xl font-semibold text-center",children:t.questions[r].question}),t.questions[r].assets&&t.questions[r].assets.length>0&&e.jsx("div",{className:"mt-4 flex justify-center gap-2",children:t.questions[r].assets.map((s,i)=>e.jsx("img",{src:s,alt:"",className:"max-h-48 rounded-lg object-contain"},i))})]})}),e.jsx("div",{className:"w-full max-w-3xl grid grid-cols-1 md:grid-cols-2 gap-4",children:(Z=t.questions[r].options)==null?void 0:Z.map((s,i)=>{const h=["bg-red-500 border-red-600","bg-blue-500 border-blue-600","bg-yellow-500 border-yellow-600","bg-green-500 border-green-600"];return e.jsx("div",{className:`p-6 rounded-lg text-white font-semibold text-lg border-b-4 ${h[i%h.length]} ${s.is_correct?"ring-4 ring-white/50":""}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s.option}),s.is_correct&&e.jsx(S,{className:"h-6 w-6"})]})},s.id)})})]}),e.jsxs("div",{className:"p-4 flex justify-center gap-4 border-t border-white/10",children:[e.jsx(l,{variant:"secondary",onClick:()=>w(s=>Math.max(0,s-1)),disabled:r===0,children:a("common.previous")}),e.jsx(l,{variant:"secondary",onClick:()=>w(s=>{var i;return Math.min((((i=t.questions)==null?void 0:i.length)||1)-1,s+1)}),disabled:r>=(((ee=t.questions)==null?void 0:ee.length)||1)-1,children:a("common.next")})]})]})})}),e.jsx(N,{open:U,onOpenChange:b,children:e.jsxs(v,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(T,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5 text-yellow-500"}),a("sessions.quizResults","Quiz Results")]}),e.jsx(R,{children:n!=null&&n.is_active?a("quizzes.sessionActiveResults","Session is active - results update in real-time"):a("quizzes.sessionClosedResults","Session has ended")})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:q?e.jsx("div",{className:"space-y-3 p-4",children:[1,2,3].map(s=>e.jsx(g,{className:"h-12 w-full"},s))}):n!=null&&n.results&&n.results.length>0?e.jsxs(ds,{children:[e.jsx(ms,{children:e.jsxs(te,{children:[e.jsx(A,{className:"w-16",children:"#"}),e.jsx(A,{children:a("sessions.participant","Participant")}),e.jsx(A,{className:"text-right",children:a("sessions.score","Score")})]})}),e.jsx(xs,{children:n.results.sort((s,i)=>i.score-s.score).map((s,i)=>e.jsxs(te,{children:[e.jsx(O,{children:i===0?e.jsx(oe,{className:"h-5 w-5 text-yellow-500"}):i===1?e.jsx(de,{className:"h-5 w-5 text-gray-400"}):i===2?e.jsx(de,{className:"h-5 w-5 text-amber-600"}):e.jsx("span",{className:"text-muted-foreground",children:i+1})}),e.jsx(O,{className:"font-medium",children:s.username}),e.jsx(O,{className:"text-right",children:e.jsxs(k,{variant:i<3?"default":"secondary",children:[s.score," ",a("sessions.points","pts")]})})]},s.username))})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(D,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:a("sessions.noParticipants")}
1)]})}),e.jsx(L,{className:"flex-shrink-0 border-t pt-4",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((se=n==null?void 0:n.results)==null?void 0:se.length)||0," ",a("sessions.participants")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>ze(),disabled:q,className:"gap-2",children:[e.jsx(Ns,{className:`h-4 w-4 ${q?"animate-spin":""}`}),a("sessions.refreshResults")]}),e.jsx(l,{variant:"secondary",onClick:()=>b(!1),children:a("common.close")})]})]})})]})}),e.jsx(N,{open:we,onOpenChange:y,children:e.jsxs(v,{className:"max-w-md",children:[e.jsxs(T,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-5 w-5"}),a("quizzes.qrCode","QR Code")]}),e.jsx(R,{children:a("quizzes.qrCodeDescription","Students can scan this QR code to join the quiz")})]}),m&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx("div",{className:"bg-white p-4 rounded-lg shadow-inner",children:e.jsx("img",{src:B(m),alt:"QR Code",className:"w-64 h-64"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium mb-1",children:a("quizzes.sessionLink","Session Link")}),e.jsx("code",{className:"text-xs bg-muted px-2 py-1 rounded break-all",children:H(m)})]})]}),e.jsxs(L,{className:"flex-col sm:flex-row gap-2",children:[e.jsxs(l,{variant:"outline",onClick:ye,className:"gap-2 w-full sm:w-auto",children:[e.jsx(vs,{className:"h-4 w-4"}),a("quizzes.downloadQR","Download QR")]}),e.jsxs(l,{variant:"outline",onClick:()=>m&&V(m),className:"gap-2 w-full sm:w-auto",children:[e.jsx(ce,{className:"h-4 w-4"}),a("quizzes.copyLink")]}),e.jsx(l,{variant:"secondary",onClick:()=>y(!1),children:a("common.close")})]})]})})]}):e.jsx(u,{children:e.jsx(j,{className:"py-10 text-center text-muted-foreground",children:a("errors.notFound")})})}export{Ks as default};
2//# sourceMappingURL=QuizDetail-CEP4RHOf.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.