import{d as _,ah as C,ag as b,R as L,r as N,$ as D,g as d,b7 as O,c as n,aj as U,a5 as k,q as f,B as m,al as Q,m as x,_ as H,at as B}from"./index.f2940478.js";import{i as F}from"./icon-question-nums.dee74fa0.js";import{e as A,Q as p,C as q,D as K,K as j,P as z,i as G,A as J}from"./index.dd514d04.js";import{O as P}from"./index.38d69c78.js";import{C as V}from"./index.d77afd61.js";import{S as M,a as $}from"./index.6d175053.js";import{I as X}from"./index.a76f4d1e.js";import{A as Y}from"./index.e6ece4dd.js";import"./index.497ffc92.js";import"./index.9cdfbaae.js";import"./index.bb9b9e58.js";import"./index.5c31d467.js";const W="_unitDetail_1qg73_1",Z="_unitSection_1qg73_4",ee="_unitTitle_1qg73_11",te="_unitCount_1qg73_16",se="_qNums_1qg73_22",ae="_num_1qg73_29",ne="_icon_1qg73_32",oe="_wapList_1qg73_37";var u={unitDetail:W,unitSection:Z,unitTitle:ee,unitCount:te,qNums:se,num:ae,icon:ne,wapList:oe};function ie(r){return typeof r=="function"||Object.prototype.toString.call(r)==="[object Object]"&&!Q(r)}var xe=_({name:"unit-detail",setup(){const r=C(),g=b(),w=L(),t=N({id:r.query.id,examDetail:{},visiableAnswer:!1,currentIndex:0,questionList:[],time:0,resultInfo:{},answerResult:[],nextStatus:!1,swipeHeight:"auto"}),S=async()=>{try{const{data:a}=await x.post("/api-student/studentUnitExamination/detail",{requestType:"form",data:{studentUnitExaminationId:t.id}}),{questionJson:e,studentAnswerJson:s,answerResult:o,...l}=a,c=e||[];t.answerResult=o?JSON.parse(o):[],c.forEach(i=>{i.userAnswer=R(i,s),i.showAnalysis=!0,i.showScore=!0,i.analysis={message:i.answerAnalysis,topic:!0,userResult:E(i.id)}}),t.questionList=c,t.examDetail={...l}}catch{}},v=async()=>{try{const{data:a}=await x.post(d.platformApi+"/classGroupUnitExamination/report",{requestType:"form",data:{classGroupUnitExaminationId:t.id,level:r.query.level}});t.examDetail={unitExaminationName:a.unitExaminationName,questionNum:a.questionNum||0};const e=a.examinationQuestionAdds||[];e.forEach(s=>{const o=s.rightAnswers||[];s.userAnswer=T(o),s.showAnalysis=!0,s.showRate=!0,s.showScore=!1,s.analysis={message:s.answerAnalysis,topic:!1}}),t.questionList=e}catch{}},T=a=>{const e=[];return a.forEach(s=>{if(s.rightAnswerFlag){const o=a.find(l=>l.questionExtra===s.questionExtra);e.push({answer:s.questionAnswer,answerId:s.examinationQuestionAnswerId,answerExtra:o?o.questionExtra:null})}}),e||[]},R=(a,e)=>{if(!e)return[];const s=e||[];return s[a.id]?s[a.id]:[]},E=a=>{let e=!1;return t.answerResult.forEach(s=>{s.questionId===a&&(e=s.rightFlag)}),e};let y=0;const h=(a=!0)=>{H(()=>{a&&window.scrollTo(0,0),setTimeout(()=>{var c;const e=(c=document.querySelectorAll(".van-swipe-item")[t.currentIndex])==null?void 0:c.querySelector(".swipe-item-question"),s=e.querySelectorAll(".answerTitleImg img");let o=!0;s.forEach(i=>{i.complete||(o=!1)}),!o&&y<3&&setTimeout(()=>{y+=1,h(a)},300),o&&(y=0);const l=B(e);t.swipeHeight=l.height},100)})},I=async()=>{var a;try{t.nextStatus=!0,t.questionList.length===t.currentIndex+1&&(A.emit("unitAudioStop"),g.back()),(a=w.value)==null||a.next(),t.nextStatus=!1}catch{t.nextStatus=!1}};return D(async()=>{d.platformType==="TEACHER"||d.platformType==="SCHOOL"?await v():await S(),h()}),O(()=>{A.emit("unitAudioStop")}),()=>{let a;return n("div",{class:u.unitDetail},[n(U,null,null),n(V,{center:!0,class:u.unitSection,border:!1},{title:()=>n("div",{class:u.unitTitle},[t.examDetail.unitExaminationName]),label:()=>n("div",{class:u.unitCount},[n("div",{class:u.qNums},[n(k,{class:u.icon,name:F},null),f("\u9898\u76EE\u6570\u91CF")," ",n("span",{class:u.num,style:{paddingLeft:"6px"}},[t.currentIndex+1]),f("/"),t.examDetail.questionNum||0])])}),n(M,{loop:!1,showIndicators:!1,ref:w,duration:300,touchable:!1,lazyRender:!0,style:{paddingBottom:"12px"},height:t.swipeHeight,onChange:e=>{A.emit("unitAudioStop"),t.currentIndex=e,h()}},ie(a=t.questionList.map((e,s)=>n($,null,{default:()=>[n("div",{class:"swipe-item-question"},[e.questionTypeCode===p.RADIO&&n(q,{value:e.userAnswer,"onUpdate:value":o=>e.userAnswer=o,index:s+1,data:e,readOnly:!0,type:"radio",showRate:e.showRate,showAnalysis:e.showAnalysis,analysis:e.analysis},null),e.questionTypeCode===p.CHECKBOX&&n(q,{value:e.userAnswer,"onUpdate:value":o=>e.userAnswer=o,index:s+1,data:e,readOnly:!0,type:"checkbox",showRate:e.showRate,showAnalysis:e.showAnalysis,analysis:e.analysis},null),e.questionTypeCode===p.SORT&&n(K,{readOnly:!0,value:e.userAnswer,"onUpdate:value":o=>e.userAnswer=o,data:e,index:s+1,showRate:e.showRate,showAnalysis:e.showAnalysis,analysis:e.analysis},null),e.questionTypeCode===p.LINK&&n(j,{readOnly:!0,value:e.userAnswer,"onUpdate:value":o=>e.userAnswer=o,data:e,index:s+1,showRate:e.showRate,showAnalysis:e.showAnalysis,analysis:e.analysis},null),e.questionTypeCode===p.PLAY&&n(z,{readOnly:!0,value:e.userAnswer,"onUpdate:value":o=>e.userAnswer=o,data:e,index:s+1,unitId:t.id,showScore:e.showScore,showRate:e.showRate,showAnalysis:e.showAnalysis,analysis:e.analysis},null)])]})))?a:{default:()=>[a]}),n(P,{position:"bottom",background:"white"},{default:()=>[n("div",{class:["btnGroup btnMore"]},[t.currentIndex>0&&n(m,{round:!0,block:!0,type:"primary",plain:!0,onClick:()=>{var e;(e=w.value)==null||e.prev()}},{default:()=>[f("\u4E0A\u4E00\u9898")]}),n(m,{block:!0,round:!0,type:"primary",onClick:I,loading:t.nextStatus,disabled:t.nextStatus},{default:()=>[t.questionList.length===t.currentIndex+1?"\u786E\u5B9A":"\u4E0B\u4E00\u9898"]}),n(X,{src:G,class:[u.wapList,"van-haptics-feedback"],onClick:()=>t.visiableAnswer=!0},null)])]}),n(Y,{show:t.visiableAnswer,"onUpdate:show":e=>t.visiableAnswer=e,title:"\u9898\u76EE\u5217\u8868",safeAreaInsetBottom:!0},{default:()=>[n(J,{value:t.questionList,answerResult:t.answerResult,index:t.currentIndex,lookType:d.platformType==="STUDENT"?"RESULT":"CLICK",statusList:d.platformType==="STUDENT"?[{text:"\u7B54\u5BF9",color:"#71B0FF"},{text:"\u7B54\u9519",color:"#FF8486"}]:[],onSelect:e=>{var s;(s=w.value)==null||s.swipeTo(e,{immediate:!0}),t.visiableAnswer=!1}},null)]})])}}});export{xe as default};