import{r as D,u as T,j as e,c3 as B,A as O,dS as E,m as o,l as f}from"./vendor-rThclpOQ.js";import{B as j}from"./badge-DJgeeB6N.js";import{B as H}from"./button-ZcsoqUQn.js";import{C as c,b as d}from"./card-HXna_7vU.js";import{D as M,a as Q,b as U,c as $,d as J}from"./dialog-CDEDwQhm.js";import{S as L}from"./scroll-area-BCwyUKIK.js";import"./index-DquVdLUg.js";import"./utils-8KAaAB9H.js";const G=({quiz:t,submission:l})=>{const[w,b]=D.useState(!1),{props:v}=T(),{translate:A}=v,{frontend:i}=A,g=l.is_passed,y=Math.round(l.total_marks/t.total_mark*100),h=s=>{if(typeof s=="string")try{return JSON.parse(s)}catch{return[]}return Array.isArray(s)?s:[]},C=s=>{const a=s.answers&&s.answers.length>0?s.answers[0]:null;return a?a.is_correct:!1},_=s=>{const a=s.answers&&s.answers.length>0?s.answers[0]:null;return a?h(a.answers):[]},k=s=>e.jsx("div",{dangerouslySetInnerHTML:{__html:s}});return e.jsxs(M,{open:w,onOpenChange:b,children:[e.jsx(Q,{asChild:!0,children:e.jsxs(H,{variant:"secondary",size:"sm",className:"text-sm",children:[e.jsx(B,{className:"h-4 w-4"}),e.jsx("span",{children:i.result})]})}),e.jsx(U,{className:"max-w-4xl p-0",children:e.jsxs(L,{className:"max-h-[90vh] p-6",children:[e.jsx($,{children:e.jsx(J,{className:"text-xl",children:t.title})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(c,{className:g?"border-green-500":"border-red-500",children:e.jsxs(d,{className:"flex items-center gap-2 p-4",children:[e.jsx(O,{className:`h-8 w-8 ${g?"text-green-500":"text-red-500"}`}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[y,"%"]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Total Score"})]})]})}),e.jsx(c,{children:e.jsxs(d,{className:"flex items-center gap-3 p-4",children:[e.jsx(E,{className:"h-8 w-8 text-blue-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[l.total_marks,"/",t.total_mark]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:i.total_marks})]})]})}),e.jsx(c,{children:e.jsxs(d,{className:"flex items-center gap-3 p-4",children:[e.jsx(o,{className:"h-8 w-8 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:l.correct_answers}),e.jsx("p",{className:"text-muted-foreground text-xs",children:i.correct_answers})]})]})}),e.jsx(c,{children:e.jsxs(d,{className:"flex items-center gap-3 p-4",children:[e.jsx(f,{className:"h-8 w-8 text-red-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:l.incorrect_answers}),e.jsx("p",{className:"text-muted-foreground text-xs",children:i.incorrect_answers})]})]})})]}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Quiz Questions"}),t.quiz_questions&&t.quiz_questions.map((s,a)=>{const x=C(s),p=_(s),N=h(s.answer),S=h(s.options);return e.jsx(c,{className:x?"border-l-green-500":"border-l-red-500",children:e.jsxs(d,{className:"p-4",children:[e.jsxs("div",{className:"mb-3 flex items-start justify-between",children:[e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("span",{className:"font-semibold",children:[a+1,"."]}),e.jsx("div",{className:"flex-1",children:k(s.title)})]})}),e.jsxs(j,{variant:x?"default":"destructive",className:"ml-2",children:[x?e.jsx(o,{className:"mr-1 h-3 w-3"}):e.jsx(f,{className:"mr-1 h-3 w-3"}),x?"Correct":"Wrong"]})]}),(s.type==="single"||s.type==="multiple")&&e.jsx("div",{className:"space-y-2",children:S.map((r,m)=>{const n=p.includes(r),u=N.includes(r);return e.jsx("div",{className:`rounded-md border p-3 ${u?"border-green-500 bg-green-50 dark:bg-green-950/20":n?"border-red-500 bg-red-50 dark:bg-red-950/20":"bg-muted/50"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:r}),e.jsxs("div",{className:"flex gap-2",children:[n&&e.jsx(j,{variant:"outline",className:"text-xs",children:"Your Answer"}),u&&e.jsx(o,{className:"h-4 w-4 text-green-600"})]})]})},m)})}),s.type==="boolean"&&e.jsx("div",{className:"space-y-2",children:["True","False"].map(r=>{const m=p.includes(r),n=N.includes(r);return e.jsx("div",{className:`rounded-md border p-3 ${n?"border-green-500 bg-green-50 dark:bg-green-950/20":m?"border-red-500 bg-red-50 dark:bg-red-950/20":"bg-muted/50"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:r}),e.jsxs("div",{className:"flex gap-2",children:[m&&e.jsx(j,{variant:"outline",className:"text-xs",children:"Your Answer"}),n&&e.jsx(o,{className:"h-4 w-4 text-green-600"})]})]})},r)})})]})},s.id)})]})]})})]})};export{G as default};
