1 |
- import{d as M,P as O,q as Q,r as D,x as $,e as H,y as K,a8 as F,a as t,W as z,A as c,C,Q as q,a3 as j,D as g,E as V,z as W,$ as Y,R as m,S as L}from"./index-521a9826.js";import{e as b,Q as w,C as _,D as G,K as X,P as J,i as Z,A as ee,a as se,R as te}from"./index-7695da7e.js";import{M as E}from"./index-c0ea6da9.js";import{E as ne}from"./index-0da6f576.js";import{b as oe,u as ae,a as ie}from"./index-fdaad3c0.js";import{S as le,a as re}from"./index-5b82f39e.js";import{I as ue}from"./index-25b5c9d0.js";import"./index-1f2f0321.js";import"./index-544f4e19.js";import"./howler-302efa4a.js";import"./index-1ad6a58d.js";const ce="_unitDetail_1xn4x_1",de="_unitSwipe_1xn4x_9",pe="_questionTitle_1xn4x_12",fe="_questionNum_1xn4x_21",we="_questionType_1xn4x_24",ve="_wapList_1xn4x_42",ye="_btnSection_1xn4x_48",he="_prevBtn_1xn4x_53",be="_nextBtn_1xn4x_54",xe="_activePrevBtn_1xn4x_55",Ie="_right_1xn4x_78",Ae="_error_1xn4x_81",Te="_primary_1xn4x_84",a={unitDetail:ce,unitSwipe:de,questionTitle:pe,questionNum:fe,questionType:we,wapList:ve,btnSection:ye,prevBtn:he,nextBtn:be,activePrevBtn:xe,right:Ie,error:Ae,primary:Te};function Ce(u){return typeof u=="function"||Object.prototype.toString.call(u)==="[object Object]"&&!j(u)}const Ue=M({name:"unit-detail",setup(){const u=O(),v=Q(),d=D(),e=$({type:u.query.type,knowledgePointIds:u.query.knowledgePointIds,lessonCoursewareId:u.query.lessonCoursewareId,background:"transparent",color:"#fff",visiableError:!1,visiableAnswer:!1,id:u.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:qe,pause:B}=oe(1e3,{controls:!0}),S=async()=>{try{const{data:o}=await g.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){}},k=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){V("题目尚未做答");return}if(!(l!=null&&l.analysis.isAnswer)){let f={};n.forEach((r,I)=>{I===e.currentIndex&&(f={questionId:r.id,details:r.userAnswer||[]})});const{data:h}=await g.post("/edu-app/studentUnitExamination/submitTrainingAnswer",{hideLoading:!0,data:f});i=h,n.forEach((r,I)=>{I===e.currentIndex&&(e.answerAnalysis=r.answerAnalysis,e.questionTypeCode=r.questionTypeCode,r.showAnalysis=!0,r.analysis.userResult=h,r.analysis.isAnswer=!0,r.analysis.disabled=!0)})}if(e.questionList.length===e.currentIndex+1){b.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="确认本次练习的题目都完成了吗?",window.removeEventListener("popstate",p,!1),v.back();return}i?(s=d.value)==null||s.next():e.visiableError=!0}catch(n){}},T=H(()=>{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 y=(o=!0)=>{W(()=>{o&&window.scrollTo(0,0),setTimeout(()=>{var f;const s=(f=document.querySelectorAll(".van-swipe-item")[e.currentIndex])==null?void 0:f.querySelector(".swipe-item-question"),n=s==null?void 0:s.querySelectorAll(".answerTitleImg img");let i=!0;n==null||n.forEach(h=>{h.complete||(i=!1)}),!i&&x<3&&setTimeout(()=>{x+=1,y(o)},300),i&&(x=0);const l=Y(s);e.swipeHeight=l.height},100)})},R=()=>{e.visiableInfo.operationType==="RESULT"?(e.visiableInfo.show=!1,m().isApp?L({api:"back"}):(v.back(),v.back())):e.visiableInfo.operationType==="BACK"?(e.visiableInfo.show=!1,U()):e.visiableInfo.operationType==="CONTINUE"&&P()},N=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",p,!1))},P=()=>{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},B(),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>`},p=()=>{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}道题了,继续做题可以巩固所学知识哦~`,b.emit("unitAudioStop")},U=()=>{window.removeEventListener("popstate",p,!1),m().isApp?L({api:"back"}):v.back()};return K(async()=>{ae(document,"scroll",()=>{const{y:o}=ie();o.value>52?(e.background="#fff",e.color="#323333"):(e.background="transparent",e.color="#fff")}),await S(),y(),window.history.pushState(null,"",document.URL),window.addEventListener("popstate",p,!1)}),F(()=>{b.emit("unitAudioStop")}),()=>{let o;return t("div",{class:a.unitDetail},[t(E,{position:"top"},{default:()=>[t(z,{border:!1,background:e.background,color:e.color},null)]}),t(le,{loop:!1,showIndicators:!1,ref:d,duration:300,touchable:!1,class:a.unitSwipe,style:{paddingBottom:"12px"},lazyRender:!0,height:e.swipeHeight,onChange:s=>{b.emit("unitAudioStop"),e.currentIndex=s,y()}},Ce(o=e.questionList.map((s,n)=>t(re,null,{default:()=>[t("div",{class:"swipe-item-question"},[s.questionTypeCode===w.RADIO&&t(_,{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(_,{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(G,{value:s.userAnswer,"onUpdate:value":[i=>s.userAnswer=i,()=>{const i=!(s.userAnswer&&s.userAnswer.length>0);y(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(X,{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(J,{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(E,{position:"bottom"},{default:()=>[t("div",{class:["btnGroup btnMore",a.btnSection]},[t(C,{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(C,{block:!0,round:!0,class:a.nextBtn,onClick:k,loading:e.nextStatus,disabled:e.nextStatus},{default:()=>[e.questionList.length===e.currentIndex+1?"提交":"下一题"]}),t(ue,{src:Z,class:[a.wapList,"van-haptics-feedback"],onClick:()=>e.visiableAnswer=!0},null)])]}),t(ee,{show:e.visiableAnswer,"onUpdate:show":s=>e.visiableAnswer=s,title:"题目列表",safeAreaInsetBottom:!0},{default:()=>[t(se,{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(q,{show:e.visiableError,"onUpdate:show":s=>e.visiableError=s,style:{width:"90%"},round:!0,closeOnClickOverlay:!1},{default:()=>[t(ne,{onClose:()=>e.visiableError=!1,answerAnalysis:e.answerAnalysis,questionTypeCode:e.questionTypeCode,onConform:()=>{var s;(s=d.value)==null||s.next(),setTimeout(()=>{e.answerAnalysis=""},500)}},null)]}),t(q,{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(te,{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:R,onClose:N},null)]})])}}});export{Ue as default};
|