import{_ as D,E as $,r as b,h as C,i as B,f as M,I as R,z as A,j,S as F,c,a as t,t as s,e as d,d as r,F as V,A as E,s as I,o as m,b as Q,W as L,H as x,X as N}from"./app-Cn5Lr4xA.js";import{u as U}from"./quiz-9bvNfDe5.js";import{h as Y,F as H}from"./index-CTSRKHAd.js";/* empty css            */const P={key:0,class:"d-flex align-items-center justify-content-center",style:{height:"calc(100vh - 170px)"}},W={class:"text-danger"},X={href:"/dashboard",class:"btn btn-primary mt-4 w-100"},G={key:1,class:"quiz-container shadow my-5"},J={class:"mb-4"},K={key:0,class:"question-section"},O={class:"d-flex justify-content-between align-items-center"},Z={class:"timer"},ee={class:"fs-6 fw-bold text-primary"},te={class:"timer text-end fw-bold"},se={class:"questionText"},ae={class:"options"},oe=["value","name"],ie=["value","name"],ne={class:"navigation d-flex justify-content-between align-items-center mt-5"},re={key:1,class:"result-section"},le={class:"container"},ue={class:"row"},ce={class:"col-12 col-md-4 offset-md-4 mt-5"},de={class:"card border-primary"},me={class:"card-header bg-primary text-white"},he={class:"card-title"},_e={class:"card-body"},pe={class:"card-text fw-bold"},ve={class:"fs-5"},be={href:"/dashboard",class:"btn btn-primary mt-4 w-100"},fe={__name:"Quiz",setup(ye){const g=$(),e=U(),q=R(),z=M(),f=b("");let l=b([]);const v=b(!1),y=b(!1),k=()=>{const o=e.quizData.id,a=e.quizData.question_type,u={question_id:o,...a==="multiple_choice"?{choices:v.value?[]:l.value}:{choice:v.value?null:l.value},skip:v.value};e.answers=u,l.value=a==="multiple_choice"?[]:[null]};C(e,()=>{e.currentTimer==0&&!y.value&&(w(),y.value=!0)},{deep:!0}),B(async()=>{var a,u,h;const o=z.beforeEach((i,n,_)=>{q.name===n.name?S(i,n,_):_()});z.afterEach(()=>{o()});try{const i=await A.get(`/quiz/start/${q.params.id}`,{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${g.authToken}`}}),n=(a=i.data.data)==null?void 0:a.quiz_session;e.totalQuestion=(u=i.data.data)==null?void 0:u.question_count,e.authToken=g.authToken,e.quizData=(h=i.data.data)==null?void 0:h.question,e.quizSession=n,e.timerManager=(n==null?void 0:n.quiz_duration)||0,e.isResetTimer&&(e.isQuizSubmitted=!1,e.resetTimer()),e.timerManager=(n==null?void 0:n.quiz_duration)||0}catch(i){f.value=i.response.data.message}e.startTimer()});const w=()=>{v.value=!0,k(),T()},T=()=>{k(),e.resetTimer(),e.nextQuestion()};j(()=>{y.value=!1,e.currentTimer=0,e.timerManager=0,e.currentQuestion=1,e.quizData={},e.isQuizSubmitted=!1,e.stopTimer(),e.score=0,l.value=[]});const S=(o,a,u)=>{F.fire({title:"Are you sure?",text:"Your progress may be lost if you leave the exam.",icon:"warning",showCancelButton:!0,confirmButtonText:"Leave Quiz",cancelButtonText:"Stay on Page"}).then(h=>{h.isConfirmed?u():u(!1)})};return(o,a)=>{var u,h;return f.value?(m(),c("div",P,[t("div",null,[t("h3",W,s(f.value),1),t("a",X,[d(s(o.$t("Move to Dashboard"))+" ",1),a[3]||(a[3]=t("i",{class:"bi bi-arrow-right"},null,-1))])])])):(m(),c("div",G,[t("h1",J,s(o.$t("Start Your Quiz")),1),r(e).isQuizSubmitted?(m(),c("div",re,[t("h2",null,s(o.$t("Congretulations"))+", "+s(o.$t("Quiz Completed"))+"!",1),t("div",le,[t("div",ue,[t("div",ce,[t("div",de,[t("div",me,[t("h5",he,s(o.$t("Scoreboard")),1)]),t("div",_e,[t("p",pe,[d(s(o.$t("You scored"))+": ",1),t("strong",ve,s(r(e).score),1)])])])])]),t("a",be,[d(s(o.$t("Move to Dashboard"))+" ",1),a[6]||(a[6]=t("i",{class:"bi bi-arrow-right"},null,-1))])])])):(m(),c("div",K,[t("div",O,[t("p",Z,[d(s(o.$t("Time Remaining"))+" : ",1),t("span",ee,s(r(e).formattedTime),1)]),t("div",null,[t("p",te,s(o.$t("Total Question"))+" : "+s(r(e).currentQuestion)+"/"+s(r(e).totalQuestion),1)])]),t("h2",null,s(o.$t("Question"))+" "+s(r(e).currentQuestion),1),t("div",null,[t("p",se,[a[4]||(a[4]=t("i",{class:"bi bi-chevron-double-right"},null,-1)),d(" "+s((u=r(e).quizData)==null?void 0:u.question_text),1)]),t("div",ae,[(m(!0),c(V,null,E((h=r(e).quizData)==null?void 0:h.options,(i,n)=>{var _;return m(),c("label",{key:n,class:"option"},[((_=r(e).quizData)==null?void 0:_.question_type)==="multiple_choice"?Q((m(),c("input",{key:0,value:i==null?void 0:i.text,"onUpdate:modelValue":a[0]||(a[0]=p=>x(l)?l.value=p:l=p),type:"checkbox",name:"question_"+n},null,8,oe)),[[L,r(l)]]):Q((m(),c("input",{key:2,type:"radio",value:i==null?void 0:i.text,"onUpdate:modelValue":a[2]||(a[2]=p=>x(l)?l.value=p:l=p),name:"question_"+n},null,8,ie)),[[N,r(l)]]),d(" "+s(i==null?void 0:i.text),1)])}),128))])]),t("div",ne,[t("button",{class:"btn btn-danger btn-sm px-5 py-2",onClick:w},[d(s(o.$t("Skip"))+" ",1),I(r(H),{icon:r(Y)},null,8,["icon"])]),t("button",{class:"btn btn-primary btn-sm px-5 py-2",onClick:T},[d(s(o.$t("Next"))+" ",1),a[5]||(a[5]=t("i",{class:"bi bi-arrow-right"},null,-1))])])]))]))}}},we=D(fe,[["__scopeId","data-v-59c2752b"]]);export{we as default};
