1import{L as P}from"./exam-BtOLG55O.js";import{P as B,n as v,a as b,R as A}from"./PlayerScreen-DX9nsPsF.js";import{_ as S,c as i,t as h,e as p,i as c,b as I,h as m,o,f as w,n as d,ab as $,$ as f,S as x,a as k,d as C,F as T}from"./index-6P0cCGxP.js";import{r as y}from"./examPosition-CEUAsw8-.js";import"./plan_price-DzeBaqF-.js";const R=(e,t)=>{const s={};if(!e||!Array.isArray(e.questions))return s;for(const n of t||[]){if(!n||!n.answer)continue;const r=e.questions.find(u=>u.uuid===n.questionUuid||u.id===n.questionUuid);if(!r)continue;const a=n.answer;s[r.id]=a.likely??a.rank??a.multi??a.uuid}return s},L={components:{PlayerScreen:B},props:{attempt:{type:Object,required:!0},loadExam:{type:Function,required:!0},loadSolutions:{type:Function,default:null},packageSlug:{type:String,default:null}},emits:["close"],data:()=>({bundle:null,index:0,navOpen:!1,loading:!0,error:null}),computed:{given(){return R(this.bundle,this.attempt.answers)}},mounted(){this.load(),window.addEventListener("keydown",this.navigateKey)},beforeUnmount(){window.removeEventListener("keydown",this.navigateKey)},methods:{async load(){var e;this.loading=!0,this.error=null;try{const t=await this.loadExam(),s=t.data||t;if(s.slug!==this.attempt.examSlug)throw new Error("different-test");const n=v(s);if(n.refusal)throw new Error(n.refusal);const r=this.loadSolutions?await Promise.resolve(this.loadSolutions()).catch(()=>null):null;this.bundle=b(n,r||{entitlement:null,grantedQuestionId:null,lockedQuestionIds:n.questions.filter(a=>!a.solution.length).map(a=>a.id),solutions:{}})}catch(t){this.error=((e=t.response)==null?void 0:e.status)===403?"Your account does not currently have access to this test. Your saved result is still available.":"We could not load the answers for this test. Please try again."}finally{this.loading=!1}},next(){this.index===this.bundle.questions.length-1?this.$emit("close"):this.index++},navigateKey(e){var t,s;!this.bundle||this.navOpen||e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey||(s=(t=e.target)==null?void 0:t.closest)!=null&&s.call(t,'input, textarea, select, [contenteditable="true"]')||(e.key==="ArrowLeft"&&(e.preventDefault(),this.index=Math.max(0,this.index-1)),e.key==="ArrowRight"&&(e.preventDefault(),this.next()))}}},N={key:0,class:"sr-only"},O={key:2,class:"review-loading"},F={key:0,role:"status"},K={key:1,role:"alert"};function U(e,t,s,n,r,a){const u=m("PlayerScreen");return o(),i("div",null,[e.bundle?(o(),i("h1",N,"Review your answers: "+h(e.bundle.name),1)):p("",!0),e.bundle?(o(),c(u,{key:1,bundle:e.bundle,index:e.index,given:a.given,"nav-open":e.navOpen,"package-slug":s.packageSlug,mode:"practice",solutions:"",onPrev:t[0]||(t[0]=l=>e.index=Math.max(0,e.index-1)),onNext:a.next,onBackToResults:t[1]||(t[1]=l=>e.$emit("close")),onToggleNav:t[2]||(t[2]=l=>e.navOpen=!e.navOpen),onJump:t[3]||(t[3]=l=>{e.index=l,e.navOpen=!1})},null,8,["bundle","index","given","nav-open","package-slug","onNext"])):(o(),i("div",O,[e.loading?(o(),i("p",F,"Loading your answers and worked solutionsâ¦")):(o(),i("p",K,h(e.error),1)),e.loading?p("",!0):(o(),i("button",{key:2,type:"button",class:"pl-btn",onClick:t[4]||(t[4]=(...l)=>a.load&&a.load(...l))},"Try again")),I("button",{type:"button",class:"pl-btn",onClick:t[5]||(t[5]=l=>e.$emit("close"))},"Back to results")]))])}const V=S(L,[["render",U],["__scopeId","data-v-0a35eb0e"]]),W={components:{LayoutExam:P,ResultsScreen:A,SavedAnswerReview:V},data:()=>({attempt:null,rows:[],loading:!0,error:null,actionError:null,reviewing:!1,loadId:0,reviewBundle:null,solutions:null,solutionsPending:!1,examRequest:null}),computed:{row(){return this.rows.find(e=>{var t;return e.slug===((t=this.attempt)==null?void 0:t.examSlug)})},benchmark(){return x({...this.row||{},slug:this.attempt.examSlug,profile:this.attempt.profile})},given(){return this.reviewBundle?R(this.reviewBundle,this.attempt.answers):{}},saleBundle(){return this.reviewBundle?{...this.reviewBundle,name:this.bundle.name}:this.bundle},programme(){var e,t,s,n;return(e=this.attempt)!=null&&e.packageSlug?{slug:this.attempt.packageSlug,name:((n=(s=(t=this.$store.getters)["bankPackages/bankPackageBySlug"])==null?void 0:s.call(t,this.attempt.packageSlug))==null?void 0:n.name)||f(this.attempt.packageSlug)}:null},canReview(){return!this.attempt.profile&&Array.isArray(this.attempt.answers
1)&&(this.attempt.answers.length>0||this.attempt.questionsAnswered===0)},bundle(){var e;return{name:((e=this.row)==null?void 0:e.uniqueName)||f(this.attempt.examSlug),questions:Array.from({length:this.attempt.questionsTotal||0},(t,s)=>({id:`q-${s}`}))}}},watch:{"$route.params.uuid":"load"},mounted(){this.load()},beforeUnmount(){this.loadId++},methods:{async load(){var s;const e=++this.loadId,t=this.$route.params.uuid;this.loading=!0,this.error=null,this.actionError=null,this.reviewing=!1,this.attempt=null,this.rows=[],this.reviewBundle=null,this.solutions=null,this.solutionsPending=!1,this.examRequest=null;try{const n=await $.get();if(e!==this.loadId)return;if(this.attempt=n.find(r=>String(r.uuid)===String(t))||null,(s=this.attempt)!=null&&s.packageSlug)try{const r=await d.exams(this.attempt.packageSlug);e===this.loadId&&(this.rows=r.data.data)}catch{}}catch{e===this.loadId&&(this.error="We could not load your results. Please try again.")}finally{e===this.loadId&&(this.loading=!1)}e===this.loadId&&this.loadSale(e)},loadSolutions(){return d.solutions(this.attempt.examSlug).then(e=>e.data)},async loadSale(e){if(!(!this.attempt||this.attempt.profile||!this.canReview)){this.solutionsPending=!0;try{const t=await this.loadReviewExam();if(e!==this.loadId)return;const s=t.data||t;if(s.slug!==this.attempt.examSlug)throw new Error("different-test");const n=v(s);if(n.refusal)throw new Error(n.refusal);const r=await this.loadSolutions().catch(()=>null);if(e!==this.loadId)return;this.solutions=r,this.reviewBundle=r?b(n,r):n}catch{}finally{e===this.loadId&&(this.solutionsPending=!1)}}},async findRow(){if(!this.row&&this.attempt.packageSlug&&(this.rows=(await d.exams(this.attempt.packageSlug)).data.data),!this.row)throw new Error("Test unavailable");return this.row},loadReviewExam(){return this.examRequest||(this.examRequest=(async()=>{var t;const e=await this.findRow();return(t=e.apiPath)!=null&&t.startsWith("content/")?d.contentTest(e.slug):d.packageExam(this.attempt.packageSlug,y(e))})().catch(e=>{throw this.examRequest=null,e})),this.examRequest},async retake(){this.actionError=null;try{const e=await this.findRow();this.$router.push({name:"exam",params:{package_slug:this.attempt.packageSlug,order:y(e)}})}catch{this.actionError="This test could not be opened. Please try again or return to the package."}},close(){this.$router.push(this.attempt.packageSlug?{name:"package",params:{slug:this.attempt.packageSlug}}:{name:"dashboard"})}}},D={key:0,class:"result-message"},Y={key:0,role:"status"},M={key:1,role:"alert"},Q={key:0,class:"result-message",role:"status"},j={key:1,class:"result-message",role:"alert"};function J(e,t,s,n,r,a){const u=m("router-link"),l=m("SavedAnswerReview"),E=m("ResultsScreen"),q=m("LayoutExam");return o(),c(q,null,{default:w(()=>[e.loading||e.error||!e.attempt?(o(),i("div",D,[e.loading?(o(),i("p",Y,"Loading your resultsâ¦")):(o(),i("p",M,h(e.error||"We could not find that sitting on your account."),1)),e.error?(o(),i("button",{key:2,class:"pl-btn",onClick:t[0]||(t[0]=(...g)=>a.load&&a.load(...g))},"Try again")):p("",!0),k(u,{to:{name:"dashboard"}},{default:w(()=>[C("Back to dashboard")]),_:1})])):e.reviewing?(o(),c(l,{key:e.attempt.uuid,attempt:e.attempt,"load-exam":a.loadReviewExam,"load-solutions":a.loadSolutions,"package-slug":e.attempt.packageSlug||null,onClose:t[1]||(t[1]=g=>e.reviewing=!1)},null,8,["attempt","load-exam","load-solutions","package-slug"])):(o(),i(T,{key:2},[k(E,{bundle:a.saleBundle,exam:null,score:e.attempt.scorePercentage,correct:e.attempt.questionsCorrect??0,answered:e.attempt.questionsAnswered??0,total:e.attempt.questionsTotal??0,benchmark:a.benchmark,"seconds-taken":e.attempt.speedCompleted,profile:e.attempt.profile||null,given:e.reviewBundle?a.given:null,solutions:e.solutions,"solutions-pending":e.solutionsPending,programme:a.programme,"package-slug":e.attempt.packageSlug||null,"in-package":!!e.attempt.packageSlug,reviewable:a.canReview,onSolutions:t[2]||(t[2]=g=>e.reviewing=!0),onRetake:a.retake,onClose:a.close},null,8,["bundle","score","correct","answered","total","benchmark","seconds-taken","profile","given","solutions","solutions-pending","programme","package-slug","in-package","reviewable","onRetake","onClose"]),!a.canReview&&!e.attempt.profile?(o(),i("p",Q,"Your score is saved, but the individual answers for this sitting are no longer available.")):p("",!0),e.actionError?(o(),i("p",j,h(e.actionError),1)):p("",!0)],64))]),_:1})}const _=S(W,[["render",J],["__scopeId","data-v-6a137adc"]]);export{_ 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.