lms/public/build/assets/exam-result-DcxbFkFo.js
2025-12-15 12:26:23 +01:00

2 lines
6.8 KiB
JavaScript

import{u as v,r as k,j as e,L as g,bO as w,K as _,aj as A,k as C,cv as B}from"./vendor-BKmmeuxg.js";import{Q as P,a as Q,b as T}from"./question-status-icon-ClKO4JNY.js";import{Q as N}from"./question-type-badge-C65yTFrV.js";import{B as M}from"./badge-AQfLLMpR.js";import{B as u}from"./button-BpNwv2aE.js";import{C as n,b as c,a as d,c as m}from"./card-D9_SJYq6.js";import{P as o}from"./progress-DinXkPLd.js";import{e as q}from"./richtor-CRcM6Du2.js";import"./utils-DxSsnXxD.js";import"./index-WW_1X1qx.js";const b=t=>t.exam_question??{},K=()=>{const{attempt:t}=v().props,r=(t==null?void 0:t.attempt_answers)??[],h=k.useMemo(()=>r.reduce((s,a)=>{const l=b(a),i=l.question_type;return i&&(s[i]||(s[i]={correct:0,total:0,marks:0,totalMarks:0}),s[i].total+=1,s[i].totalMarks+=l.marks??0,s[i].marks+=a.marks_obtained||0,a.is_correct&&(s[i].correct+=1)),s},{}),[r]);if(!t)return e.jsx("div",{className:"flex h-full items-center justify-center p-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-800",children:"Attempt data unavailable"}),e.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Please return to the exam list and try again."}),e.jsx("div",{className:"mt-4",children:e.jsx(g,{href:route("student.index","exams"),children:e.jsx(u,{variant:"outline",children:"Back to My Exams"})})})]})});const x=t.is_passed,y=t.percentage||0,j=r.filter(s=>s.is_correct).length,p=r.filter(s=>s.is_correct===!1).length,f=r.filter(s=>s.is_correct===null).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h6",{className:"text-xl font-semibold",children:["Attempt ",t.attempt_number," Result"]}),e.jsx(u,{asChild:!0,variant:"outline",children:e.jsxs(g,{href:route("student.exam.show",{id:t.exam_id,tab:"attempts"}),children:[e.jsx(w,{className:"h-4 w-4"}),"Back Attempts"]})})]}),e.jsx(n,{className:`border-2 ${x?"border-green-500 bg-green-50":"border-red-500 bg-red-50"}`,children:e.jsx(c,{className:"p-6",children:e.jsxs("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("h6",{className:`mb-2 text-4xl font-bold ${x?"text-green-600":"text-red-600"}`,children:[y.toFixed(1),"%"]}),e.jsx("p",{className:"text-sm font-semibold tracking-wide text-gray-600 uppercase",children:"Score"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("h6",{className:"mb-2 text-4xl font-bold",children:[t.obtained_marks,"/",t.total_marks]}),e.jsx("p",{className:"text-sm font-semibold tracking-wide text-gray-600 uppercase",children:"Marks"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx(M,{variant:x?"default":"destructive",className:"mb-2 px-6 py-1 text-lg",children:x?"PASSED":"FAILED"}),e.jsxs("p",{className:"text-sm text-gray-600",children:["Pass mark: ",e.jsx("span",{className:"font-semibold",children:t.exam.pass_mark})]})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"mb-2 text-3xl font-bold",children:[Math.floor((new Date(t.end_time).getTime()-new Date(t.start_time).getTime())/6e4)," min"]}),e.jsx("p",{className:"text-sm font-semibold tracking-wide text-gray-600 uppercase",children:"Time Taken"})]})]})})}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-3",children:[e.jsxs(n,{children:[e.jsxs(d,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(m,{className:"text-sm font-medium",children:"Correct Answers"}),e.jsx(_,{className:"h-4 w-4 text-green-600"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold text-green-600",children:j}),e.jsx(o,{value:r.length?j/r.length*100:0,className:"mt-2"})]})]}),e.jsxs(n,{children:[e.jsxs(d,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(m,{className:"text-sm font-medium",children:"Incorrect Answers"}),e.jsx(A,{className:"h-4 w-4 text-red-600"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold text-red-600",children:p}),e.jsx(o,{value:r.length?p/r.length*100:0,className:"mt-2"})]})]}),e.jsxs(n,{children:[e.jsxs(d,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(m,{className:"text-sm font-medium",children:"Pending Review"}),e.jsx(C,{className:"h-4 w-4 text-yellow-600"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold text-yellow-600",children:f}),f>0&&e.jsx("p",{className:"mt-1 text-xs text-gray-600",children:"Manual grading in progress"})]})]})]}),Object.keys(h).length>0&&e.jsxs(n,{children:[e.jsx(d,{className:"p-5 sm:p-6",children:e.jsxs(m,{className:"flex items-center gap-2",children:[e.jsx(B,{className:"h-5 w-5"}),"Performance by Question Type"]})}),e.jsx(c,{className:"p-4 pt-0 sm:p-6 md:pt-0",children:e.jsx("div",{className:"space-y-4",children:Object.entries(h).map(([s,a])=>e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex flex-col justify-between sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{type:s}),e.jsxs("span",{className:"text-sm text-gray-600",children:[a.correct,"/",a.total," correct"]})]}),e.jsxs("span",{className:"text-sm font-semibold",children:[a.marks,"/",a.totalMarks," marks"]})]}),e.jsx(o,{value:a.correct/a.total*100})]},s))})})]}),e.jsxs(n,{children:[e.jsx(d,{className:"p-5 sm:p-6",children:e.jsx(m,{children:"Detailed Analysis"})}),e.jsx(c,{className:"p-4 pt-0 sm:p-6 md:pt-0",children:e.jsx("div",{className:"space-y-6",children:r.map((s,a)=>{const l=b(s);return e.jsxs("div",{className:"overflow-hidden rounded-lg border-2 border-gray-200 bg-white",children:[e.jsxs("div",{className:"border-b border-gray-200 bg-gray-50 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-1 items-start gap-3",children:[e.jsx("div",{className:"mt-1 flex-shrink-0",children:e.jsx(P,{answer:s})}),e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-lg font-semibold",children:["Question ",a+1]}),l.question_type&&e.jsx(N,{type:l.question_type}),e.jsx(Q,{answer:s})]})})]}),e.jsxs("div",{className:"flex-shrink-0 text-right",children:[e.jsxs("p",{className:"flex flex-col items-center text-lg font-bold sm:flex-row",children:[e.jsx("span",{className:"border-primary border-b sm:border-none",children:s.marks_obtained||0}),e.jsx("span",{className:"hidden sm:block",children:"/"}),e.jsx("span",{children:l.marks||0})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"marks"})]})]}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:l.title})]}),e.jsxs("div",{className:"p-4",children:[l.description&&e.jsx(q,{value:l.description}),e.jsx("div",{className:"mb-4",children:e.jsx(T,{answer:s,question:l})})]})]},s.id??a)})})})]})]})};export{K as default};