index-2e0f16a3.js 9.8 KB

1
  1. import{d as U,U as P,q as O,r as M,x as D,e as Q,y as H,a8 as K,a as t,S as $,A as c,C as q,V as g,a2 as F,D as m,E as z,z as V,_ as j}from"./index-618de94a.js";import{e as h,Q as w,C as L,D as W,K as Y,P as G,i as X,A as J,a as Z,R as ee}from"./index-8eaad674.js";import{M as _}from"./index-3c640b6c.js";import{E as se}from"./index-f0177c09.js";import{b as te,u as ne,a as oe}from"./index-af130878.js";import{S as ae,a as ie}from"./index-75eea76b.js";import{I as le}from"./index-7812c01a.js";import"./index-93d23e9b.js";import"./index-d88dfb54.js";import"./index-a24f2213.js";const ue="_unitDetail_1xn4x_1",re="_unitSwipe_1xn4x_9",ce="_questionTitle_1xn4x_12",de="_questionNum_1xn4x_21",pe="_questionType_1xn4x_24",fe="_wapList_1xn4x_42",we="_btnSection_1xn4x_48",ve="_prevBtn_1xn4x_53",ye="_nextBtn_1xn4x_54",he="_activePrevBtn_1xn4x_55",be="_right_1xn4x_78",xe="_error_1xn4x_81",Ie="_primary_1xn4x_84",a={unitDetail:ue,unitSwipe:re,questionTitle:ce,questionNum:de,questionType:pe,wapList:fe,btnSection:we,prevBtn:ve,nextBtn:ye,activePrevBtn:he,right:be,error:xe,primary:Ie};function Ae(r){return typeof r=="function"||Object.prototype.toString.call(r)==="[object Object]"&&!F(r)}const Re=U({name:"unit-detail",setup(){const r=P(),b=O(),d=M(),e=D({type:r.query.type,knowledgePointIds:r.query.knowledgePointIds,lessonCoursewareId:r.query.lessonCoursewareId,background:"transparent",color:"#fff",visiableError:!1,visiableAnswer:!1,id:r.query.id,currentIndex:0,questionList:[],visiableInfo:{show:!1,operationType:"RESULT",type:"DEFAULT",content:"",showCancelButton:!1,confirmButtonText:"",cancelButtonText:"",title:""},nextStatus:!1,swipeHeight:"auto",answerAnalysis:"",questionTypeCode:"",overResult:{time:"00:00",questionLength:0,errorLength:0,rate:0}}),{counter:A,resume:Te,pause:E}=te(1e3,{controls:!0}),B=async()=>{try{const{data:o}=await m.post("/edu-app/studentUnitExamination/queryPracticeModeExam",{data:{lessonCoursewareId:e.lessonCoursewareId,knowledgePointIds:e.knowledgePointIds}}),s=o||{};s.examinationQuestionAdds.forEach(n=>{n.showAnalysis=!1,n.analysis={message:n.answerAnalysis,topic:!0,isAnswer:!1,userResult:!1,disabled:!1},n.userAnswer=[]}),e.questionList=s.examinationQuestionAdds||[]}catch(o){}},S=async()=>{var o,s;try{const n=e.questionList||[];let i=!0;const l=n[e.currentIndex];if(((o=l==null?void 0:l.userAnswer)==null?void 0:o.length)<=0){z("题目尚未做答");return}if(!(l!=null&&l.analysis.isAnswer)){let p={};n.forEach((u,I)=>{I===e.currentIndex&&(p={questionId:u.id,details:u.userAnswer||[]})});const{data:f}=await m.post("/edu-app/studentUnitExamination/submitTrainingAnswer",{hideLoading:!0,data:p});i=f,n.forEach((u,I)=>{I===e.currentIndex&&(e.answerAnalysis=u.answerAnalysis,e.questionTypeCode=u.questionTypeCode,u.showAnalysis=!0,u.analysis.userResult=f,u.analysis.isAnswer=!0,u.analysis.disabled=!0)})}if(e.questionList.length===e.currentIndex+1){h.emit("unitAudioStop"),e.visiableInfo.show=!0,e.visiableInfo.title="练习完成",e.visiableInfo.showCancelButton=!0,e.visiableInfo.operationType="CONTINUE",e.visiableInfo.cancelButtonText="再等等",e.visiableInfo.confirmButtonText="确认完成",e.visiableInfo.content="确认本次练习的题目都完成了吗?",C();return}i?(s=d.value)==null||s.next():e.visiableError=!0}catch(n){}},T=Q(()=>{const o=e.questionList||[];let s=0,n=0,i=0;return o.forEach(l=>{l.showAnalysis&&(s+=1,l.analysis.userResult?n+=1:i+=1)}),{count:s,passCount:n,noPassCount:i}});let x=0;const v=(o=!0)=>{V(()=>{o&&window.scrollTo(0,0),setTimeout(()=>{var p;const s=(p=document.querySelectorAll(".van-swipe-item")[e.currentIndex])==null?void 0:p.querySelector(".swipe-item-question"),n=s==null?void 0:s.querySelectorAll(".answerTitleImg img");let i=!0;n==null||n.forEach(f=>{console.log(f.complete),f.complete||(i=!1)}),!i&&x<3&&setTimeout(()=>{x+=1,v(o)},300),i&&(x=0);const l=j(s);e.swipeHeight=l.height},100)})},k=()=>{e.visiableInfo.operationType==="RESULT"?(e.visiableInfo.show=!1,b.back(),b.back()):e.visiableInfo.operationType==="BACK"?(e.visiableInfo.show=!1,C()):e.visiableInfo.operationType==="CONTINUE"&&N()},R=async()=>{e.visiableInfo.operationType==="RESULT"||(e.visiableInfo.operationType==="BACK"||e.visiableInfo.operationType==="CONTINUE")&&(e.visiableInfo.show=!1,window.history.pushState(null,"",document.URL),window.addEventListener("popstate",y,!1))},N=()=>{const o=T.value;let s=0;o.count>0&&(s=Math.floor(o.passCount/o.count*100));const n=A.value,i=Math.floor(n/60)>=10?Math.floor(n/60):"0"+Math.floor(n/60),l=n%60>=10?n%60:"0"+n%60;e.overResult={time:i+":"+l,questionLength:o.count,errorLength:o.noPassCount,rate:s},E(),A.value=0,e.visiableInfo.show=!0,e.visiableInfo.title="已完成~",e.visiableInfo.showCancelButton=!1,e.visiableInfo.operationType="RESULT",e.visiableInfo.confirmButtonText="确认",e.visiableInfo.content=`<div>您已完成本次测试,答对<span class='${a.right}'>${o.passCount}</span>,答错<span class='${a.error}'>${o.count-o.passCount}</span>,正确率<span class='${a.primary}'>${s}%</span>~</div>`},y=()=>{const o=T.value;e.visiableInfo.show=!0,e.visiableInfo.title="确认退出吗?",e.visiableInfo.showCancelButton=!0,e.visiableInfo.operationType="BACK",e.visiableInfo.cancelButtonText="取消",e.visiableInfo.confirmButtonText="确定",e.visiableInfo.content=`您已经完成${o.passCount+o.noPassCount}道题了,继续做题可以巩固所学知识哦~`,h.emit("unitAudioStop")},C=()=>{window.removeEventListener("popstate",y,!1),b.back()};return H(async()=>{ne(document,"scroll",()=>{const{y:o}=oe();o.value>52?(e.background="#fff",e.color="#323333"):(e.background="transparent",e.color="#fff")}),await B(),v(),window.history.pushState(null,"",document.URL),window.addEventListener("popstate",y,!1)}),K(()=>{h.emit("unitAudioStop")}),()=>{let o;return t("div",{class:a.unitDetail},[t(_,{position:"top"},{default:()=>[t($,{border:!1,background:e.background,color:e.color},null)]}),t(ae,{loop:!1,showIndicators:!1,ref:d,duration:300,touchable:!1,class:a.unitSwipe,style:{paddingBottom:"12px"},lazyRender:!0,height:e.swipeHeight,onChange:s=>{h.emit("unitAudioStop"),e.currentIndex=s,v()}},Ae(o=e.questionList.map((s,n)=>t(ie,null,{default:()=>[t("div",{class:"swipe-item-question"},[s.questionTypeCode===w.RADIO&&t(L,{value:s.userAnswer,"onUpdate:value":i=>s.userAnswer=i,index:n+1,data:s,type:"radio",showAnalysis:s.showAnalysis,analysis:s.analysis},{title:()=>t("div",{class:a.questionTitle},[t("div",{class:a.questionNum},[t("span",null,[e.currentIndex+1]),c("/"),e.questionList.length]),t("div",{class:a.questionType},[t("i",null,null),t("span",null,[s.knowledgePointName])])])}),s.questionTypeCode===w.CHECKBOX&&t(L,{value:s.userAnswer,"onUpdate:value":i=>s.userAnswer=i,index:n+1,data:s,type:"checkbox",showAnalysis:s.showAnalysis,analysis:s.analysis},{title:()=>t("div",{class:a.questionTitle},[t("div",{class:a.questionNum},[t("span",null,[e.currentIndex+1]),c("/"),e.questionList.length]),t("div",{class:a.questionType},[t("i",null,null),t("span",null,[s.knowledgePointName])])])}),s.questionTypeCode===w.SORT&&t(W,{value:s.userAnswer,"onUpdate:value":[i=>s.userAnswer=i,()=>{const i=!(s.userAnswer&&s.userAnswer.length>0);v(i)}],data:s,index:n+1,showAnalysis:s.showAnalysis,analysis:s.analysis},{title:()=>t("div",{class:a.questionTitle},[t("div",{class:a.questionNum},[t("span",null,[e.currentIndex+1]),c("/"),e.questionList.length]),t("div",{class:a.questionType},[t("i",null,null),t("span",null,[s.knowledgePointName])])])}),s.questionTypeCode===w.LINK&&t(Y,{value:s.userAnswer,"onUpdate:value":i=>s.userAnswer=i,data:s,index:n+1,showAnalysis:s.showAnalysis,analysis:s.analysis},{title:()=>t("div",{class:a.questionTitle},[t("div",{class:a.questionNum},[t("span",null,[e.currentIndex+1]),c("/"),e.questionList.length]),t("div",{class:a.questionType},[t("i",null,null),t("span",null,[s.knowledgePointName])])])}),s.questionTypeCode===w.PLAY&&t(G,{value:s.userAnswer,"onUpdate:value":i=>s.userAnswer=i,data:s,index:n+1,unitId:e.id,showAnalysis:s.showAnalysis,analysis:s.analysis},{title:()=>t("div",{class:a.questionTitle},[t("div",{class:a.questionNum},[t("span",null,[e.currentIndex+1]),c("/"),e.questionList.length]),t("div",{class:a.questionType},[t("i",null,null),t("span",null,[s.knowledgePointName])])])})])]})))?o:{default:()=>[o]}),t(_,{position:"bottom"},{default:()=>[t("div",{class:["btnGroup btnMore",a.btnSection]},[t(q,{round:!0,block:!0,class:e.currentIndex>0?a.activePrevBtn:a.prevBtn,disabled:!(e.currentIndex>0),onClick:()=>{var s;(s=d.value)==null||s.prev()}},{default:()=>[c("上一题")]}),t(q,{block:!0,round:!0,class:a.nextBtn,onClick:S,loading:e.nextStatus,disabled:e.nextStatus},{default:()=>[e.questionList.length===e.currentIndex+1?"提交":"下一题"]}),t(le,{src:X,class:[a.wapList,"van-haptics-feedback"],onClick:()=>e.visiableAnswer=!0},null)])]}),t(J,{show:e.visiableAnswer,"onUpdate:show":s=>e.visiableAnswer=s,title:"题目列表",safeAreaInsetBottom:!0},{default:()=>[t(Z,{value:e.questionList,statusList:[{text:"答对",color:"#1CACF1"},{text:"答错",color:"#FF8486"},{text:"未答",color:"#EAEAEA"}],lookType:"PRACTICE",onSelect:s=>{var n;(n=d.value)==null||n.swipeTo(s,{immediate:!0}),e.visiableAnswer=!1}},null)]}),t(g,{show:e.visiableError,"onUpdate:show":s=>e.visiableError=s,style:{width:"90%"},round:!0,closeOnClickOverlay:!1},{default:()=>[t(se,{onClose:()=>e.visiableError=!1,answerAnalysis:e.answerAnalysis,questionTypeCode:e.questionTypeCode,onConform:()=>{var s;(s=d.value)==null||s.next(),e.answerAnalysis=""}},null)]}),t(g,{show:e.visiableInfo.show,"onUpdate:show":s=>e.visiableInfo.show=s,closeOnClickOverlay:!1,style:{background:"transparent",width:"100%",maxWidth:"100%",transform:"translateY(-55%)"}},{default:()=>[t(ee,{title:e.visiableInfo.title,showCancelButton:e.visiableInfo.showCancelButton,cancelButtonText:e.visiableInfo.cancelButtonText,confirmButtonText:e.visiableInfo.confirmButtonText,status:e.visiableInfo.type,content:e.visiableInfo.content,contentHtml:!0,onConform:k,onClose:R},null)]})])}}});export{Re as default};