1import{r,j as e,o as E,x as I,M as S,i as Q,aH as T}from"./vendor-4067d247.js";import{aw as D,P,X as M,ax as R}from"./index-9a29aa96.js";import{H as U}from"./index-b3d3f0d3.js";import{u as _}from"./useFetchUser-78e878d8.js";import"./RadioSwitchButton-c005e0ce.js";import"./DeleteButton-38254d7b.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},l=new n.Error().stack;l&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[l]="6d363ccb-559a-4377-9955-c60d4e2d8812",n._sentryDebugIdIdentifier="sentry-dbid-6d363ccb-559a-4377-9955-c60d4e2d8812")}catch{}})();const A=({points:n,id:l,term:g,correct:c,yourAnswer:b,correctAnswer:k,collapse:h,assignedPoints:u,setGradedQuestions:N,gradedQuestions:w})=>{const[d,s]=r.useState(!1),[p,x]=r.useState(n);r.useEffect(()=>{h||s(!0),h&&s(!1)},[h]);const y=j=>{const v=w==null?void 0:w.map(a=>(a==null?void 0:a.questionId)===j?{...a,points:p,correct:u!=null?p>=u:!1}:a);v!=null&&N(v.filter(a=>a!==null))};return r.useEffect(()=>{y(l)},[p]),e.jsxs("div",{className:"mt-[20px] w-full rounded-[10px] bg-electric-violet-200 px-[25px] py-[12px] dark:bg-mariana-blue sm:rounded-[20px]",children:[e.jsxs("div",{className:"flex items-center gap-x-[15px]",children:[e.jsx(E,{onClick:()=>{s(!d)},className:`${d?"":"-rotate-90"} h-[28px] w-[28px] cursor-pointer text-tolopea dark:text-white`}),e.jsx("h1",{className:"font-medium text-tolopea dark:text-white",children:g}),e.jsx("div",{className:"ml-auto flex items-center gap-x-[10px]",children:e.jsxs("div",{className:"flex items-center overflow-hidden rounded-full border border-white",children:[e.jsx("input",{className:"w-[40px] bg-transparent pl-[20px] font-medium text-tolopea outline-none focus:outline-none dark:text-white",type:"number",onChange:j=>{x(parseInt(j.currentTarget.value))},min:0,max:u,value:p}),e.jsxs("span",{className:"font-medium mr-1",children:[" /",u]}),e.jsx("div",{className:`m-[1px] flex h-[30px] w-[30px] items-center justify-center rounded-full ${c===!0?"bg-blaze-orange":"bg-white"} `,children:c===!0?e.jsx(I,{className:"h-[18px] w-[18px] text-tolopea dark:text-white"}):e.jsx(S,{className:"h-[18px] w-[18px] text-tolopea"})})]})})]}),d&&e.jsxs("div",{className:"px-[40px] pt-4",children:[c===!0?e.jsx("div",{className:"flex h-[28px] w-[28px] items-center justify-center rounded-full bg-blaze-orange ",children:e.jsx(I,{className:"h-[18px] w-[18px] text-tolopea dark:text-white"})}):e.jsxs("div",{className:"flex w-fit items-center gap-x-[10px] rounded-full bg-aquamarine/30 p-2 text-tolopea dark:bg-tolopea dark:text-white",children:[e.jsx("div",{className:"flex h-[28px] w-[28px] items-center justify-center rounded-full bg-white ",children:e.jsx(S,{className:"h-[18px] w-[18px] text-tolopea"})}),e.jsx("p",{className:"pr-2 font-medium",children:"Student's answer :"})]}),e.jsx("p",{className:"pt-2 font-medium text-tolopea dark:text-white",children:b??"it was left blank!"}),c===!1&&e.jsxs("div",{className:"pt-6",children:[e.jsxs("div",{className:"flex w-fit items-center gap-x-[10px] rounded-full bg-aquamarine/30 p-2 text-tolopea dark:bg-tolopea dark:text-white",children:[e.jsx("div",{className:"flex h-[28px] w-[28px] items-center justify-center rounded-full bg-blaze-orange ",children:e.jsx(I,{className:"h-[18px] w-[18px] text-tolopea dark:text-white"})}),e.jsx("p",{className:"pr-2 font-medium",children:"Correct answer :"})]}),e.jsx("p",{className:"pt-2 font-medium text-tolopea dark:text-white",children:k})]})]})]})},F=()=>{var a,z;const{postToast:n}=D(),{resultId:l}=Q(),[g]=T(),c=g.get("guestId"),[b,k]=r.useState(!0),{user:h}=_(),[u,N]=r.useState(0),[w,d]=r.useState(0),[s,p]=r.useState(null),[x,y]=r.useState([]),j=async()=>{var i,o,f;const t=await R.getQuizResult(parseInt(l??""),c!=null?parseInt(c):null),m=(i=t.gradedResults)==null?void 0:i.map(C=>C.result);p(t),y(m??[]),N(((o=t.quizResult)==null?void 0:o.correct)??0),d(((f=t.quizResult)==null?void 0:f.points)??0)},v=async()=>{var i;const t=x.reduce((o,f)=>o+((f==null?void 0:f.points)??0),0),m=x.filter(o=>o.correct===!0).length;N(m),d(t),await R.gradeQuizManually(((i=s==null?void 0:s.quiz)==null?void 0:i.id)??0,parseInt(l??""),{quizResult:{...s==null?void 0:s.quizResult,points:t,correct:m},questionResults:x}),n({message:"Quiz results updated",title:"Success!"})};return r.useEffect(()=>{l!=null&&j()},[l]),e.jsx(P,{children:s!==null&&e.jsxs("div",{children:[e.jsx(U,{quizResults:s,correct:u,points:w,collapse:b,setCollapse:k}),(a=s.gradedResults)==null?void 0:a.map((t,m)=>{var i,o;return e.jsx(A,{id:t.question.id??0,setGradedQuestions:y,gradedQuestions:x,collapse:b,points:((i=t.result)==null?void 0:i.points)??0,term:t.question.term??"Term",correct:t.correct,correctAnswer:t.question.content??"Correct answer",yourAnswer:(o=t.result)==null?void 0:o.answer,assignedPoints:t.question.points},m)}),h.id===((z=s.quiz)==null?void 0:z.creator)&&e.jsx(M,{className:"my-[20px]",label:"Update",onClick:v})]})})};export{F as default};
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.