index-2ee37d12.js 11 KB

1
  1. import{d as U,P as k,q as D,r as N,x as R,ag as O,D as p,y as P,Q as M,a as s,V as Q,A as l,C as A,R as K,S as T,a3 as H,N as $,z as F,$ as z,U as g}from"./index-869d77fb.js";import{e as f,Q as v,C as E,D as V,K as j,P as W,i as G,A as X,a as Y,R as J}from"./index-8029f624.js";import{M as q}from"./index-3eb77ad0.js";import{u as Z,a as ee}from"./index-155c29c2.js";import{S as te,a as se}from"./index-d45dfe1a.js";import{I as ne}from"./index-e76f2a88.js";import"./index-3fd44b77.js";import"./index-70d6770d.js";import"./howler-ae3abd7b.js";import"./index-1c6c2ec0.js";const ie="_unitDetail_s5imy_1",ae="_unitSwipe_s5imy_9",oe="_questionTitle_s5imy_12",ue="_questionNum_s5imy_21",le="_questionType_s5imy_24",re="_wapList_s5imy_31",ce="_btnSection_s5imy_37",de="_prevBtn_s5imy_42",pe="_nextBtn_s5imy_43",fe="_activePrevBtn_s5imy_44",ve="_right_s5imy_67",we="_error_s5imy_70",ye="_minutes_s5imy_73",Ie="_unitDetailTablet_s5imy_76",i={unitDetail:ie,unitSwipe:ae,questionTitle:oe,questionNum:ue,questionType:le,wapList:re,btnSection:ce,prevBtn:de,nextBtn:pe,activePrevBtn:fe,right:ve,error:we,minutes:ye,unitDetailTablet:Ie};function me(r){return typeof r=="function"||Object.prototype.toString.call(r)==="[object Object]"&&!H(r)}const _e=U({name:"unit-detail",setup(){const r=k(),w=D(),y=N(),e=R({type:r.query.type,knowledgePointIds:r.query.knowledgePointIds,lessonCoursewareId:r.query.lessonCoursewareId,studentUnitExaminationId:"",background:"transparent",visiableAnswer:!1,examDetail:{},currentIndex:0,time:0,questionList:[],visiableInfo:{show:!1,operationType:"RESULT",type:"DEFAULT",content:"",showCancelButton:!1,confirmButtonText:"",cancelButtonText:"",title:""},nextStatus:!1,swipeHeight:"auto",countDownOver:!1}),u=O({time:e.time,onChange(n){if(3e5>=n.total&&!e.countDownOver){if(e.visiableInfo.show){e.countDownOver=!0;return}e.visiableInfo.show=!0,e.visiableInfo.title="倒计时5分钟",e.visiableInfo.showCancelButton=!1,e.visiableInfo.operationType="TIME",e.visiableInfo.type="COUNTDOWN",e.visiableInfo.confirmButtonText="确认",e.visiableInfo.content="距离交卷时间还剩五分钟哦,请尽快答题~",e.countDownOver=!0}},onFinish:async()=>{f.emit("unitAudioStop"),await h(),window.removeEventListener("popstate",c,!1),w.back()}}),L=async()=>{try{let n={};if(e.type==="ai"){const{data:t}=await p.post("/edu-app/studentUnitExamination/pointRandomSave",{data:{knowledgePointIds:e.knowledgePointIds}});n=t||{}}else{const{data:t}=await p.post("/edu-app/studentUnitExamination/mockExamination",{data:{lessonCoursewareId:e.lessonCoursewareId,knowledgePointIds:e.knowledgePointIds}});n=t||{}}n.examinationQuestionAdds.forEach(t=>{t.showAnalysis=!1,t.analysis={message:t.answerAnalysis,topic:!0,userResult:!1},t.userAnswer=[]}),e.questionList=n.examinationQuestionAdds||[],e.studentUnitExaminationId=n.unitExaminationId,e.examDetail=n||{},S()}catch(n){}},S=async()=>{const t=(e.examDetail||{}).timeMinutes||0;e.time=Math.ceil(t*60*1e3),setTimeout(()=>{u.reset(t*60*1e3),u.start()},10)},_=async()=>{var n,t;e.nextStatus=!0;try{const o=e.questionList||[],a=o[e.currentIndex];if(((n=a==null?void 0:a.userAnswer)==null?void 0:n.length)<=0){$("题目尚未做答"),e.nextStatus=!1;return}const m=[];if(o.forEach((d,x)=>{d.userAnswer&&d.userAnswer.length>0&&m.push({questionId:d.id,details:d.userAnswer})}),e.questionList.length===e.currentIndex+1){f.emit("unitAudioStop"),e.visiableInfo.show=!0,e.visiableInfo.title="测验完成",e.visiableInfo.showCancelButton=!0,e.visiableInfo.operationType="CONTINUE",e.visiableInfo.type="DEFAULT",e.visiableInfo.cancelButtonText="再等等",e.visiableInfo.confirmButtonText="确认完成",e.visiableInfo.content="确认本次测验的题目都完成了吗?",e.nextStatus=!1,window.removeEventListener("popstate",c,!1),w.back();return}await p.post("/edu-app/studentUnitExamination/submitAnswer",{hideLoading:!0,data:{answers:m,studentUnitExaminationId:e.studentUnitExaminationId}}),(t=y.value)==null||t.next()}catch(o){}e.nextStatus=!1};let b=0;const I=(n=!0)=>{F(()=>{n&&window.scrollTo(0,0),setTimeout(()=>{var d;const t=(d=document.querySelectorAll(".van-swipe-item")[e.currentIndex])==null?void 0:d.querySelector(".swipe-item-question"),o=t==null?void 0:t.querySelectorAll(".answerTitleImg img");let a=!0;o==null||o.forEach(x=>{x.complete||(a=!1)}),!a&&b<3&&setTimeout(()=>{b+=1,I(n)},300),a&&(b=0);const m=z(t);e.swipeHeight=m.height},100)})},B=()=>{e.visiableInfo.operationType==="RESULT"?(e.visiableInfo.show=!1,T().isApp&&e.type!=="ai"?g({api:"back"}):(window.removeEventListener("popstate",c,!1),w.go(-2))):e.visiableInfo.operationType==="BACK"||e.visiableInfo.operationType==="CONTINUE"?h():e.visiableInfo.operationType==="TIME"&&(e.visiableInfo.show=!1)},C=async n=>{if(e.visiableInfo.operationType==="BACK"){if(n){e.visiableInfo.show=!1,window.history.pushState(null,"",document.URL),window.addEventListener("popstate",c,!1);return}try{await p.get("/edu-app/studentUnitExamination/dropExamination",{params:{studentUnitExaminationId:e.studentUnitExaminationId}}),e.visiableInfo.show=!1,T().isApp&&e.type!=="ai"?g({api:"back"}):(window.removeEventListener("popstate",c,!1),w.go(-2))}catch(t){}}else e.visiableInfo.operationType==="CONTINUE"&&(e.visiableInfo.show=!1,window.history.pushState(null,"",document.URL),window.addEventListener("popstate",c,!1))},h=async()=>{try{const n=e.questionList||[],t=[];n.forEach(a=>{a.userAnswer&&a.userAnswer.length>0&&t.push({questionId:a.id,details:a.userAnswer})});const{data:o}=await p.post("/edu-app/studentUnitExamination/completionExamination",{hideLoading:!1,data:{answers:t,studentUnitExaminationId:e.studentUnitExaminationId}});e.visiableInfo.show=!0,e.visiableInfo.title=o.score+"分",e.visiableInfo.showCancelButton=!1,e.visiableInfo.operationType="RESULT",e.visiableInfo.confirmButtonText="确认",o.status==="A_EXCELLENT"?(e.visiableInfo.type="GOOD",e.visiableInfo.content="<div>你很棒,题目掌握的非常不错,"):o.status==="B_PASS"?(e.visiableInfo.type="PASS",e.visiableInfo.content="<div>还需要加油哦,"):(e.visiableInfo.type="FAIL",e.visiableInfo.content="<div>别气馁,继续努力,"),e.visiableInfo.content+=`您本次获得了<span class='${i.right}'>${o.score}分</span>,正确率<span class='${i.error}'>${o.rightRate}%</span>,实际用时<span class='${i.minutes}'>${Math.ceil(o.answerTime/60)}</span>分钟~</div>`}catch(n){}},c=()=>{e.visiableInfo.show=!0,e.visiableInfo.title="确认要离开吗?",e.visiableInfo.showCancelButton=!0,e.visiableInfo.operationType="BACK",e.visiableInfo.type="DEFAULT",e.visiableInfo.cancelButtonText="弃考",e.visiableInfo.confirmButtonText="提交",e.visiableInfo.content="还有题目未完成哦,是否要提前交卷?",f.emit("unitAudioStop")};return P(async()=>{Z(document,"scroll",()=>{const{y:n}=ee();n.value>52?e.background="#fff":e.background="transparent"}),await L(),I(),window.history.pushState(null,"",document.URL),window.addEventListener("popstate",c,!1)}),M(()=>{f.emit("unitAudioStop")}),()=>{let n;return s("div",{class:[i.unitDetail,T().isTablet?i.unitDetailTablet:""]},[s(q,{position:"top"},{default:()=>[s(Q,{border:!1,background:e.background},null)]}),s(te,{loop:!1,showIndicators:!1,ref:y,duration:300,touchable:!1,class:i.unitSwipe,style:{paddingBottom:"12px"},lazyRender:!0,height:e.swipeHeight,onChange:t=>{f.emit("unitAudioStop"),e.currentIndex=t,I()}},me(n=e.questionList.map((t,o)=>s(se,null,{default:()=>[s("div",{class:"swipe-item-question"},[t.questionTypeCode===v.RADIO&&s(E,{value:t.userAnswer,"onUpdate:value":a=>t.userAnswer=a,index:o+1,data:t,type:"radio",showAnalysis:t.showAnalysis,analysis:t.analysis},{title:()=>s("div",{class:i.questionTitle},[s("div",{class:i.questionNum},[s("span",null,[e.currentIndex+1]),l("/"),e.questionList.length]),s("div",{class:i.questionType},[u.current.value.minutes+u.current.value.hours*60,l(":"),u.current.value.seconds])])}),t.questionTypeCode===v.CHECKBOX&&s(E,{value:t.userAnswer,"onUpdate:value":a=>t.userAnswer=a,index:o+1,data:t,type:"checkbox",showAnalysis:t.showAnalysis,analysis:t.analysis},{title:()=>s("div",{class:i.questionTitle},[s("div",{class:i.questionNum},[s("span",null,[e.currentIndex+1]),l("/"),e.questionList.length]),s("div",{class:i.questionType},[u.current.value.minutes+u.current.value.hours*60,l(":"),u.current.value.seconds])])}),t.questionTypeCode===v.SORT&&s(V,{value:t.userAnswer,"onUpdate:value":[a=>t.userAnswer=a,()=>{const a=!(t.userAnswer&&t.userAnswer.length>0);I(a)}],data:t,index:o+1,showAnalysis:t.showAnalysis,analysis:t.analysis},{title:()=>s("div",{class:i.questionTitle},[s("div",{class:i.questionNum},[s("span",null,[e.currentIndex+1]),l("/"),e.questionList.length]),s("div",{class:i.questionType},[u.current.value.minutes+u.current.value.hours*60,l(":"),u.current.value.seconds])])}),t.questionTypeCode===v.LINK&&s(j,{value:t.userAnswer,"onUpdate:value":a=>t.userAnswer=a,data:t,index:o+1,showAnalysis:t.showAnalysis,analysis:t.analysis},{title:()=>s("div",{class:i.questionTitle},[s("div",{class:i.questionNum},[s("span",null,[e.currentIndex+1]),l("/"),e.questionList.length]),s("div",{class:i.questionType},[u.current.value.minutes+u.current.value.hours*60,l(":"),u.current.value.seconds])])}),t.questionTypeCode===v.PLAY&&s(W,{value:t.userAnswer,"onUpdate:value":a=>t.userAnswer=a,data:t,index:o+1,unitId:e.studentUnitExaminationId,showAnalysis:t.showAnalysis,analysis:t.analysis},{title:()=>s("div",{class:i.questionTitle},[s("div",{class:i.questionNum},[s("span",null,[e.currentIndex+1]),l("/"),e.questionList.length]),s("div",{class:i.questionType},[u.current.value.minutes+u.current.value.hours*60,l(":"),u.current.value.seconds])])})])]})))?n:{default:()=>[n]}),s(q,{position:"bottom"},{default:()=>[s("div",{class:["btnGroup btnMore",i.btnSection]},[s(A,{round:!0,block:!0,class:e.currentIndex>0?i.activePrevBtn:i.prevBtn,disabled:!(e.currentIndex>0),onClick:()=>{var t;(t=y.value)==null||t.prev()}},{default:()=>[l("上一题")]}),s(A,{block:!0,round:!0,class:i.nextBtn,onClick:_,loading:e.nextStatus,disabled:e.nextStatus},{default:()=>[e.questionList.length===e.currentIndex+1?"提交":"下一题"]}),s(ne,{src:G,class:[i.wapList,"van-haptics-feedback"],onClick:()=>e.visiableAnswer=!0},null)])]}),s(X,{show:e.visiableAnswer,"onUpdate:show":t=>e.visiableAnswer=t,title:"题目列表",safeAreaInsetBottom:!0},{default:()=>[s(Y,{value:e.questionList,onSelect:t=>{var o;(o=y.value)==null||o.swipeTo(t,{immediate:!0}),e.visiableAnswer=!1}},null)]}),s(K,{show:e.visiableInfo.show,"onUpdate:show":t=>e.visiableInfo.show=t,closeOnClickOverlay:!1,style:{background:"transparent",width:"100%",maxWidth:"100%",transform:"translateY(-55%)"}},{default:()=>[s(J,{title:e.visiableInfo.title,showCancelButton:e.visiableInfo.showCancelButton,cancelButtonText:e.visiableInfo.cancelButtonText,confirmButtonText:e.visiableInfo.confirmButtonText,status:e.visiableInfo.type,content:e.visiableInfo.content,closeable:e.visiableInfo.operationType==="BACK",contentHtml:!0,onConform:B,onClose:C},null)]})])}}});export{_e as default};