english-front/dist/assets/QuizView-WGudUYtA.js
2026-05-12 15:06:28 +09:00

2 lines
3.2 KiB
JavaScript

import{u as C,c as o,a as t,g as b,t as a,b as f,F as V,r as N,h as S,i as B,j as R,R as j,d as r,k as z,q as A,e as i,n as F,f as L}from"./index-BcYnNRd_.js";const Q={class:"container",style:{"max-width":"600px"}},D={key:0,class:"card",style:{"text-align":"center",padding:"3rem"}},E={key:1},M={class:"quiz-progress"},T={style:{"text-align":"right","font-size":"0.85rem",color:"#718096","margin-bottom":"0.5rem"}},$={class:"card"},G={class:"quiz-question"},H={key:0,class:"quiz-sub"},I={class:"quiz-choices"},J=["disabled","onClick"],K={key:1,style:{"text-align":"center","margin-top":"1.5rem"}},O={key:2,class:"card",style:{"text-align":"center",padding:"3rem"}},P={style:{"font-size":"3rem","margin-bottom":"1rem"}},U={style:{"margin-bottom":"0.5rem"}},W={style:{color:"#718096","margin-bottom":"2rem"}},X={style:{display:"flex",gap:"0.75rem","justify-content":"center"}},te={__name:"QuizView",setup(Y){const _=C(),m=r(!1),g=r(!1),e=r([]),s=r(0),u=r(null),v=r(!1),n=r(0),k=async()=>{const d=await z.generate(5);e.value=d.data,m.value=!0},w=d=>{u.value=d,v.value=!0,d===e.value[s.value].answer&&n.value++},q=()=>{s.value<e.value.length-1?(s.value++,v.value=!1,u.value=null):(g.value=!0,z.saveResult({session_id:_.id,score:n.value,total:e.value.length}),A.complete({session_id:_.id,type:"quiz",score:n.value}))},x=()=>{m.value=!1,g.value=!1,s.value=0,n.value=0,v.value=!1,u.value=null};return(d,l)=>{var y,p,h;return i(),o("div",Q,[l[4]||(l[4]=t("h1",{class:"page-title"},"퀴즈",-1)),m.value?g.value?(i(),o("div",O,[t("div",P,a(n.value===e.value.length?"🏆":n.value>=e.value.length/2?"👏":"💪"),1),t("h2",U,a(n.value)+" / "+a(e.value.length)+" 정답",1),t("p",W,"정확도 "+a(Math.round(n.value/e.value.length*100))+"%",1),t("div",X,[t("button",{class:"btn btn-secondary",onClick:x},"다시 풀기"),S(R(j),{to:"/",class:"btn btn-primary"},{default:B(()=>[...l[3]||(l[3]=[L("홈으로",-1)])]),_:1})])])):(i(),o("div",E,[t("div",M,[t("div",{class:"quiz-progress-bar",style:b({width:s.value/e.value.length*100+"%"})},null,4)]),t("div",T,a(s.value+1)+" / "+a(e.value.length),1),t("div",$,[t("div",G,a((y=e.value[s.value])==null?void 0:y.english),1),(p=e.value[s.value])!=null&&p.pronunciation?(i(),o("div",H,"["+a(e.value[s.value].pronunciation)+"]",1)):f("",!0),t("div",I,[(i(!0),o(V,null,N((h=e.value[s.value])==null?void 0:h.choices,c=>(i(),o("button",{key:c,class:F(["quiz-choice",v.value?c===e.value[s.value].answer?"correct":c===u.value?"wrong":"":""]),disabled:v.value,onClick:Z=>w(c)},a(c),11,J))),128))]),v.value?(i(),o("div",K,[t("div",{style:b([{"margin-bottom":"1rem","font-weight":"600"},{color:u.value===e.value[s.value].answer?"#38a169":"#e53e3e"}])},a(u.value===e.value[s.value].answer?"✅ 정답!":"❌ 오답"),5),t("button",{class:"btn btn-primary",onClick:q},a(s.value<e.value.length-1?"다음":"결과 보기"),1)])):f("",!0)])])):(i(),o("div",D,[l[0]||(l[0]=t("div",{style:{"font-size":"3rem","margin-bottom":"1rem"}},"🎯",-1)),l[1]||(l[1]=t("h2",{style:{"margin-bottom":"0.5rem"}},"단어 퀴즈",-1)),l[2]||(l[2]=t("p",{style:{color:"#718096","margin-bottom":"2rem"}},"영어 단어의 뜻을 맞춰보세요!",-1)),t("button",{class:"btn btn-primary",style:{"font-size":"1rem",padding:"0.8rem 2rem"},onClick:k},"시작하기")]))])}}};export{te as default};