1import{j as e,L as u,s as l}from"./index-D7meMuQ8.js";import{u as m}from"./useQuery-NGa224AF.js";import{u as x}from"./use-user-id-C8wkJc-Z.js";import{L as p}from"./list-checks-N2JxYbzq.js";import{A as h}from"./arrow-right-B86V0g0A.js";import"./useBaseQuery-CBtXWqD9.js";import"./createLucideIcon-C5galkUl.js";function f(r){return{queryKey:["student","my-quizzes",r],queryFn:async()=>{const{data:o}=await l.from("enrollments").select("id, course_id, courses(id, title, cover_letter, cover_color)").eq("student_id",r),n=(o??[]).map(s=>s.course_id);if(n.length===0)return[];const{data:a}=await l.from("quizzes").select("id, course_id, title, pass_mark, is_required, quiz_questions(count)").in("course_id",n),{data:i}=await l.from("quiz_attempts").select("quiz_id, score, passed").eq("student_id",r),t=new Map;for(const s of i??[]){const d=t.get(s.quiz_id);(!d||s.score>d.score)&&t.set(s.quiz_id,{score:s.score,passed:s.passed})}return(a??[]).map(s=>{const d=o.find(c=>c.course_id===s.course_id);return{quiz:s,course:d.courses,best:t.get(s.id)??null,questionCount:s.quiz_questions?.[0]?.count??0}})},enabled:!!r}}function w(){const r=x(),{data:o=[],isLoading:n}=m(f(r??""));return e.jsxs("div",{className:"max-w-3xl mx-auto p-4 sm:p-8 space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"font-display text-2xl sm:text-3xl font-semibold text-ink",children:"Quizzes"}),e.jsx("p",{className:"text-sand-600 text-sm mt-1",children:"Prove what you've learned. Required quizzes unlock your certificate."})]}),n?e.jsx("div",{className:"rounded-2xl bg-sand-100 h-32 animate-pulse"}):o.length===0?e.jsxs("div",{className:"rounded-2xl bg-white border border-sand-200 p-8 text-center",children:[e.jsx("div",{className:"mx-auto h-12 w-12 rounded-full bg-[color:var(--clay-50)] grid place-items-center",children:e.jsx(p,{className:"h-6 w-6 text-[color:var(--clay-700)]"})}),e.jsx("h2",{className:"font-display text-xl font-semibold text-ink mt-4",children:"No quizzes yet"}),e.jsx("p",{className:"text-sand-600 mt-2 max-w-md mx-auto",children:"When a course you're enrolled in has a quiz, it'll show up here."})]}):e.jsx("ul",{className:"space-y-3",children:o.map(({quiz:a,course:i,best:t,questionCount:s})=>e.jsx("li",{children:e.jsxs(u,{to:"/learn/$courseId/quiz",params:{courseId:a.course_id}
1,className:"flex items-center gap-4 rounded-2xl bg-white border border-sand-200 p-4 hover:border-sand-300 transition",children:[e.jsx("div",{className:"h-14 w-14 rounded-xl grid place-items-center font-display text-2xl font-bold text-white shrink-0",style:{backgroundColor:i?.cover_color||"#E2562B"},children:i?.cover_letter??i?.title?.[0]??"â¢"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs text-sand-500 truncate",children:i?.title}),e.jsx("h3",{className:"font-semibold text-ink truncate",children:a.title}),e.jsxs("p",{className:"text-xs text-sand-600 mt-0.5",children:[s," questions · Pass ",a.pass_mark,"%",t!=null&&e.jsxs(e.Fragment,{children:[" · Best ",e.jsxs("span",{className:t.passed?"text-[color:var(--pine)] font-semibold":"text-sand-700 font-semibold",children:[t.score,"%"]})]})]})]}),e.jsx(h,{className:"h-4 w-4 text-sand-500 shrink-0"})]})},a.id))})]})}export{w as component};
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.