123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445 |
- <template>
- <view class="questionBank">
- <uni-nav-bar
- @clickLeft="clickLeft"
- left-icon="back"
- ref="navbar"
- :statusBar="true"
- :title="examData.examName"
- ></uni-nav-bar>
-
- <bankExam ref="bankExam" class="swiper" @showpopups="showpopupsEvent($event)" :recordId="recordId" :examId="id" :current="current" :list="questionList" :goodsId="goodsId" :orderGoodsId="orderGoodsId" :bankType="bankType" :lastTime="lastTime" :allTimes="allTimes"></bankExam>
- <view class="dialog" v-if="showDialog">
- <image class="pointer" src="/static/pointer.png" mode=""></image>
- <view class="text">左右滑动切换上下题</view>
- <view class="btn" @click="showDialog = false">我知道了</view>
- </view>
- <view class="dialog-arrow" v-if="showArrow">
- <image class="pointer" src="/static/arrow-left.png" mode=""></image>
- <view class="text">您当前正在测试, 若想退出请点击左上角返回按钮。</view>
- <view class="btn" @click="showArrow = false">我知道了</view>
- </view>
- <view class="dialog_wrap" v-if="testOver">
- <view class="bg"></view>
- <view class="dialog">
- <view class="title">温馨提示</view>
- <view class="content">
- <view>您已完成所有题目,</view>
- <view>快去交卷吧!</view>
- </view>
- <view class="btns">
- <view class="btn" @click="noSubmit()">暂不交卷</view>
- <view class="btn active" @click="submitNow()">立即交卷</view>
- </view>
- </view>
- </view>
- <view class="dialog_wrap" v-if="isLastCount">
- <view class="bg"></view>
- <view class="dialog">
- <view class="title">温馨提示</view>
- <view class="content">
- <view
- >您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view
- >
- </view>
- <view class="btns">
- <view class="btn" @click="noLeave()">暂不离开</view>
- <view class="btn active" @click="leaveNow()">继续离开</view>
- </view>
- </view>
- </view>
- <u-popup
- v-model="showpopups"
- mode="center"
- border-radius="24"
- height="439rpx"
- width="640rpx"
- :mask-close-able="false"
- >
- <view class="popboxs">
- <view class="classTops">温馨提示</view>
- <view class="textStys">
- {{
- cgType === 7
- ? "您还未交卷,确定结束做题吗?"
- : cgType === 8
- ? `您还有${lastCount}道题未作答, 现在继续作答,还是下次继续?`
- : cgType === 6
- ? `您还有${lastCount}道题未作答, 您确定要交卷吗?`
- : cgType == 9
- ? `您已完成所有题目,快去交卷吧!`
- : ""
- }}
- </view>
- <view class="classFootsty" v-if="cgType === 6">
- <view class="btnsty btns1" @click="submit">立即交卷</view>
- <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
- </view>
- <view class="classFootsty" v-if="cgType === 7">
- <view class="btnsty btns1" @click="backPages">下次继续</view>
- <view class="btnsty btns2" @click="submit">结束做题</view>
- </view>
- <view class="classFootsty" v-if="cgType === 8">
- <view class="btnsty btns1" @click="backPages()">下次继续</view>
- <view class="btnsty btns2" @click="showpopups = false">继续作答</view>
- </view>
- <view class="classFootsty" v-if="cgType === 9">
- <view class="btnsty btns1" @click="showpopups = false">暂不交卷</view>
- <view class="btnsty btns2" @click="submit">立即交卷</view>
- </view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import bankExam from "@/components/bank-exam/bankExam.vue";
- export default {
- components:{
- bankExam
- },
- data() {
- return {
- showpopups: false,
- id: "",
- current: 0,
- questionList: [],
- ast: ["A", "B", "C", "D", "E", "F", "G"],
- judge: ["错误", "正确"],
- ans: [],
- ques: [],
- show: false,
- showDialog: false,
- bankList: [],
- collectList: [],
- goodsId: "",
- recordId: "",
- isSubmit: false,
- lastTime: 0, //剩余考试时长
- allTimes: 0, //总考试时长
- timer: null,
- wrongList: [],
- bankType: 0, //试卷类型
- needBack: false, //是否是考试
- testOver: false,
- isLastCount: false, //是否有未答题目
- lastCount: 0, //剩余没有回答的题目数
- chapterId: 0,
- moduleId: 0,
- showArrow: false, //退出提示
- isFromVideo: "",
- gradeId: "",
- examData: {},
- orderGoodsId: "",
- cgType: 0, //对应设计稿弹窗编码
- };
- },
- async onLoad(option) {
- this.orderGoodsId = option.orderGoodsId || 0;
- this.current = +option.current || 0;
- this.id = option.id;
- this.goodsId = option.goodsid;
- this.chapterId = option.chapterId || 0;
- this.moduleId = option.moduleId || 0;
- this.isFromVideo = option.isFromVideo || "";
- this.gradeId = option.gradeId || "";
- let isBack = option.isback;
- let showDialog = uni.getStorageSync("showDialog");
- if (showDialog) {
- this.showDialog = false;
- } else {
- this.showDialog = true;
- uni.setStorageSync("showDialog", "1");
- }
- //考试被迫返回
- if (isBack) {
- let app = getApp();
- let globalData = app.globalData;
- for (var k in globalData.bankData) {
- this[k] = globalData.bankData[k];
- }
- this.showArrow = true;
- this.timer = setInterval(() => {
- if (this.lastTime <= 0) {
- clearInterval(this.timer);
- uni.showToast({
- icon: "none",
- mask: true,
- title: "考试时间已到,系统将自动交卷",
- duration: 10000,
- });
- this.submit();
- return;
- }
- this.lastTime--;
- }, 1000);
- } else {
- //进入页面
- await this.bankExam();
- this.goodsQuestionList();
- }
- },
- onUnload() {
- if (this.isSubmit) {
- clearInterval(this.timer);
- return;
- }
- //考试试卷 阻止ios手势返回,自动跳回答题页
- if (this.needBack) {
- let app = getApp();
- app.globalData.bankData = this.$data;
- clearInterval(this.timer);
- uni.navigateTo({
- url:
- "/pages2/bank/questionBank?id=" +
- this.id +
- "&goodsid=" +
- this.goodsId +
- "&isback=true&orderGoodsId=" +
- this.orderGoodsId,
- });
- } else {
- //点击返回按钮确认允许退出,记录答题记录
- clearInterval(this.timer);
- this.examRecordEdit();
- }
- },
- methods: {
- /**
- * 是否有上传图片
- */
- hasImgs(bank) {
- return bank.ansText.imageList.length == 0;
- },
- /**
- * 获取试卷类型2考试,1练习
- */
- bankExam() {
- return new Promise((resolve) => {
- this.$api.bankExam(this.id).then((res) => {
- this.bankType = res.data.data.doType;
- this.examData = res.data.data;
- if (this.bankType == 2) {
- this.needBack = true;
- }
- resolve();
- });
- });
- },
- /**
- * 点击后退按钮
- */
- clickLeft() {
- console.log()
- if (this.bankType == 1) {
- let ansCount = this.$refs.bankExam.questionOverNum(true); //已答题数
- this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
- //所有题目答完
- if (this.lastCount == 0) {
- // this.testOver = true;
- this.cgType = 7;
- //未答完
- } else {
- this.cgType = 8;
- // this.isLastCount = true;
- }
- this.showpopups = true;
- } else if (this.bankType == 2) {
- let ansCount = this.$refs.bankExam.questionOverNum(true); //已答题数
- this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
- //所有题目答完
- if (this.lastCount == 0) {
- this.testOver = true;
- //未答完
- } else {
- this.isLastCount = true;
- }
- }
- },
- /**
- * 返回上一页
- */
- backPages() {
- this.needBack = false;
- uni.navigateBack({
- delta: 1,
- });
- },
- /**
- * 获取已经回答的题目数
- * hasSpecail (是否包含简答和案例)
- */
- questionOverNum(hasSpecail) {
- let count = 0;
- this.questionList.forEach((item) => {
- if (item.type == 1 || item.type == 2 || item.type == 3) {
- if (item.ques) {
- count++;
- }
- } else if (item.type == 4) {
- //案例题
- if (hasSpecail) {
- let isOver = item.jsonStr.every((jsonItem, indexs) => {
- if (
- jsonItem.type == 1 ||
- jsonItem.type == 2 ||
- jsonItem.type == 3
- ) {
- if (item.ques[indexs]) {
- return true;
- } else {
- return false;
- }
- } else if (jsonItem.type == 5) {
- if (
- item.ques[indexs] &&
- (item.ques[indexs].text || item.ques[indexs].imageList.length)
- ) {
- console.log("chil");
- return true;
- } else {
- return false;
- }
- }
- });
- if (isOver) {
- count++;
- console.log(item, 444);
- }
- }
- } else if (item.type == 5) {
- //简答题
- if (hasSpecail) {
- if (item.ques && (item.ques.text || item.ques.imageList.length)) {
- console.log(5, item);
- count++;
- }
- }
- }
- });
- return count;
- },
- /**
- * 是否做完所有题目
- */
- isDoOver() {
- let questionOverNum = this.$refs.bankExam.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
- if (this.questionList.length == questionOverNum) {
- //全部做完弹窗
- this.cgType = 9;
- this.showpopups = true;
- }
- },
- /**
- * 暂不交卷
- */
- noSubmit() {
- //设为允许退出页面
- this.needBack = false;
- uni.navigateBack({
- delta: 1,
- });
- },
- /**
- * 不离开
- */
- noLeave() {
- this.isLastCount = false;
- },
- /**
- * 立即离开并交卷
- */
- leaveNow() {
- this.needBack = false;
- this.isSubmit = true;
- uni.navigateBack({
- delta: 1,
- });
- let score = 0; //计算总分
- let reportStatus = 0;
- let number = 0; //做对的题目数量
- let doQuestionNum = 0; //做过的题目数量
- let allScore = 0; //总分
- let passScore = 0;
- let doWrongQuestionIds = []; //错题和未做题id(客观题)
- let doQuestionIds = []; //做过的题目id
- let lessQuestionNum = 0;
- let rightQuestionIds = []; //做对的题目id
- this.questionList.forEach((item, index) => {
- // passScore = item.passScore
- if (item.type == 1) {
- //正确
- if (item.ques == item.ans) {
- item.scoreResult = item.score;
- score += item.score;
- number++;
- rightQuestionIds.push(item.questionId);
- } else {
- //错误
- item.scoreResult = 0;
- if (item.ques) {
- doWrongQuestionIds.push(item.questionId);
- }
- }
- allScore += item.score;
- if (item.ques) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item.type == 2) {
- let isRight =
- item.ans &&
- item.ans.every((quesItem, quesIndex) => {
- if (item.ques) {
- return item.ques[quesIndex] == item.ans[quesIndex];
- } else {
- return false;
- }
- });
- if (isRight) {
- score += item.score;
- number++;
- item.scoreResult = item.score;
- rightQuestionIds.push(item.questionId);
- } else {
- let hasPart = false;
- let checkboxScore = 1; //获取单题总分数
- item.ques &&
- item.ques.forEach((ques, quesIndex) => {
- //选错一个全扣
- if (item.ques) {
- if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
- checkboxScore = 0;
- }
- } else {
- checkboxScore = 0;
- }
- });
- console.log(checkboxScore);
- //没选错
- if (checkboxScore) {
- checkboxScore = 0;
- item.ans.forEach((ans, quesIndex) => {
- //漏选只能得部分分数
- if (item.ques) {
- if (item.ques.indexOf(item.ans[quesIndex]) == -1) {
- checkboxScore = +item.partScore;
- hasPart = true;
- }
- } else {
- checkboxScore = 0;
- }
- });
- }
- if (!hasPart) {
- //0分
- item.scoreResult = 0;
- if (item.ques) {
- doWrongQuestionIds.push(item.questionId);
- }
- } else {
- //部分分
- // number++;
- lessQuestionNum++;
- // doWrongQuestionIds.push(item.questionId);
- item.scoreResult = checkboxScore;
- score += checkboxScore;
- // rightQuestionIds.push(item.questionId)
- }
- }
- allScore += item.score;
- if (item.ques && item.ques.length) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item.type == 3) {
- if (item.ques == item.ans) {
- item.scoreResult = item.score;
- score += item.score;
- number++;
- rightQuestionIds.push(item.questionId);
- } else {
- item.scoreResult = 0;
- if (item.ques) {
- doWrongQuestionIds.push(item.questionId);
- }
- }
- allScore += item.score;
- if (item.ques) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item.type == 4) {
- allScore += item.score;
- if (item.ques && item.ques.length) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item.type == 5) {
- allScore += item.score;
- if (item.ques && (item.ques.imageList.length || item.ques.text)) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- }
- });
- //大于60分及格
- if (score >= 60) {
- reportStatus = 1;
- } else {
- reportStatus = 0;
- }
- //交卷
- this.$api
- .examRecordEdit({
- examId: this.id,
- goodsId: this.goodsId,
- orderGoodsId: this.orderGoodsId,
- reportStatus: reportStatus,
- recordId: this.recordId,
- rightQuestionNum: number,
- status: 1,
- lessQuestionNum:lessQuestionNum,
- moduleExamId: this.moduleId || 0,
- chapterExamId: this.chapterId || 0,
- doQuestionIds: doQuestionIds.join(","),
- rightQuestionIds: rightQuestionIds.join(","),
- doQuestionNum: doQuestionNum,
- performance: score,
- totalScore: allScore,
- examTime: parseInt(this.allTimes),
- doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
- historyExamJson: JSON.stringify(this.questionList),
- })
- .then((res) => {
- this.isSubmit = true;
- if (res.data.code == 200) {
- }
- });
- //错题集id提交(客观题)
- this.$api
- .examWrongRecord({
- orderGoodsId: this.orderGoodsId,
- moduleExamId: this.moduleId || 0,
- chapterExamId: this.chapterId || 0,
- examId: this.id,
- goodsId: this.goodsId,
- questionIds: doWrongQuestionIds,
- recordId: this.recordId,
- })
- .then((res) => {});
- },
- /**
- * 立即交卷
- */
- submitNow() {
- this.showpopups = false;
- this.needBack = false;
- this.submit();
- },
- /**
- * 离开页面统计回答正确题数
- */
- examRecordEdit() {
- if (!this.isSubmit) {
- let number = 0;
- let score = 0;
- let doQuestionNum = 0;
- let doQuestionIds = []; //做过的题目id
- this.questionList.forEach((item, index) => {
- if (item.type == 1) {
- if (item.ques == item.ans) {
- score += item.score;
- number++;
- }
- if (item.ques) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item.type == 2) {
- let isRight =
- item.ans &&
- item.ans.every((quesItem, quesIndex) => {
- if (item.ques) {
- return item.ques[quesIndex] == item.ans[quesIndex];
- } else {
- return false;
- }
- });
- if (isRight) {
- score += item.score;
- number++;
- } else {
- let checkboxScore = 1; //获取单题总分数
- item.ques &&
- item.ques.forEach((ques, quesIndex) => {
- //选错一个全扣
- if (item.ques) {
- if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
- checkboxScore = 0;
- }
- } else {
- checkboxScore = 0;
- }
- });
- console.log(checkboxScore);
- //没选错
- if (checkboxScore) {
- checkboxScore = 0;
- item.ans.forEach((ans, quesIndex) => {
- //漏选扣一部分,对n题给n X partScore 分
- if (item.ques) {
- if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
- checkboxScore += item.partScore;
- }
- } else {
- checkboxScore = 0;
- }
- });
- }
- if (checkboxScore <= 0) {
- //0分
- } else {
- //部分分
- // number++;
- score += checkboxScore;
- }
- }
- if (item.ques && item.ques.length) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item.type == 3) {
- if (item.ques == item.ans) {
- score += item.score;
- number++;
- }
- if (item.ques) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item == 4) {
- if (item.ques.length) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item.type == 5) {
- if (item.ques && (item.ques.imageList.length || item.ques.text)) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- }
- });
- this.$api
- .examRecordEdit({
- orderGoodsId: this.orderGoodsId,
- examId: this.id,
- goodsId: this.goodsId,
- recordId: this.recordId,
- doQuestionIds: doQuestionIds.join(","),
- rightQuestionNum: number,
- moduleExamId: this.moduleId || 0,
- chapterExamId: this.chapterId || 0,
- status: 0,
- doQuestionNum: doQuestionNum,
- historyExamJson: JSON.stringify(this.questionList),
- })
- .then((res) => {});
- }
- },
- /**
- * 记录总题数
- * hasSpecial (是否包含简答和案例) true 包含 false 不包含
- */
- examRecord(hasSpecial) {
- let questionList = 0;
- // if(!hasSpecial) {
- this.questionList.forEach((item, index) => {
- if (item.type == 1 || item.type == 2 || item.type == 3) {
- questionList++;
- }
- });
- // } else {
- // questionList = this.questionList.length;
- // }
- this.$api
- .examRecord({
- chapterExamId: this.chapterId || 0,
- orderGoodsId: this.orderGoodsId,
- moduleExamId: this.moduleId || 0,
- examId: this.id,
- goodsId: this.goodsId,
- totalQuestionNum: questionList,
- allQuestionNum: this.questionList.length,
- })
- .then((res) => {
- this.recordId = res.data.data;
- //获取recordId 初始化先提交题目 以防突然下次继续做题退出报错
- if (this.bankType == 1) {
- this.examRecordEdit();
- }
- });
- },
- /**
- * @param {Object} second倒计时过滤器
- */
- countdown(second) {
- if (second) {
- let h = parseInt((second / 60 / 60) % 24); // 计算小时
- let m = parseInt((second / 60) % 60); // 计算分数
- let s = parseInt(second % 60); // 计算当前秒数
- if (h < 10) h = "0" + h;
- if (m < 10) m = "0" + m;
- if (s < 10) s = "0" + s;
- return h + ":" + m + ":" + s;
- } else {
- return "";
- }
- },
-
- hideDialog() {
- this.showDialog = false
- },
- /**
- * 请求题目列表
- */
- goodsQuestionList() {
- this.$api
- .goodsQuestionList({
- examId: this.id,
- })
- .then((res) => {
- if (!res.data.data.length) {
- this.hideDialog();
- uni.showModal({
- showCancel: false,
- content: "该试卷暂无题目",
- success: (k) => {
- if (k.confirm) {
- this.isSubmit = true;
- uni.navigateBack();
- }
- },
- });
- return;
- }
- this.allTimes = res.data.data[0].answerTime * 60;
- this.lastTime =
- res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
- //考试时间到了自动交卷
- if (this.lastTime) {
- this.timer = setInterval(() => {
- if (this.lastTime <= 0) {
- clearInterval(this.timer);
- uni.showToast({
- icon: "none",
- mask: true,
- title: "考试时间已到,系统将自动交卷",
- duration: 10000,
- });
- this.submit();
- return;
- }
- this.lastTime--;
- }, 1000);
- } else {
- }
- res.data.data.forEach((item, index) => {
- // if (typeof item.jsonStr == 'string') {
- item.jsonStr = JSON.parse(item.jsonStr);
- if (item.type == 2) {
- //多选
- item.jsonStr.forEach((str) => {
- str.optionsId = "" + str.optionsId;
- });
- let arr = item.answerQuestion.split(",");
- arr.forEach((a, i) => {
- arr[i] = "" + a;
- });
- item.ans = arr;
- item.analysisContent &&
- (item.analysisContent = item.analysisContent.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- item.content &&
- (item.content = item.content.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- return;
- } else if (item.type == 5) {
- //简答题
- item.ansText = {
- text: "",
- imageList: [],
- };
- item.ques = {
- text: "",
- imageList: [],
- };
- item.analysisContent &&
- (item.analysisContent = item.analysisContent.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- item.content &&
- (item.content = item.content.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- } else if (item.type == 4) {
- //案例题
- item.ques = [];
- item.current = 0;
- let ansArr = [];
- item.jsonStr.forEach((json, index) => {
- if (json.type == 1) {
- ansArr[index] = json.answerQuestion;
- json.content &&
- (json.content = json.content.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- } else if (json.type == 2) {
- json.optionsList.forEach((str) => {
- str.optionsId = "" + str.optionsId;
- });
- let arr = json.answerQuestion.split(",");
- arr.forEach((a, i) => {
- arr[i] = "" + a;
- });
- ansArr[index] = arr;
- json.content &&
- (json.content = json.content.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- } else if (json.type == 3) {
- ansArr[index] = json.answerQuestion;
- json.content &&
- (json.content = json.content.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- } else if (json.type == 5) {
- ansArr[index] = {
- text: json.answerQuestion,
- imageList: [],
- };
- json.ansText = {
- text: "",
- imageList: [],
- };
- json.content &&
- (json.content = json.content.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- }
- });
- item.analysisContent &&
- (item.analysisContent = item.analysisContent.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- item.content &&
- (item.content = item.content.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- item.ans = ansArr;
- return;
- }
- item.analysisContent &&
- (item.analysisContent = item.analysisContent.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- item.content &&
- (item.content = item.content.replace(
- /<img/gi,
- '<img style="max-width:100%;"'
- ));
- item.ans = item.answerQuestion;
- // }
- });
- this.questionList = res.data.data;
- this.lastCount = this.questionList.length;
- this.examRecord();
- this.getCollectInfo(this.current);
- });
- },
- /**
- * @param {Object} e单选点击
- */
- radioSelect(optionsId, bindex) {
- if (this.questionList[bindex].ques) return;
- this.$set(this.questionList[bindex], "ques", optionsId);
- this.isDoOver();
- // 回答错误
- if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
- this.$api
- .examWrongRecord({
- orderGoodsId: this.orderGoodsId,
- examId: this.id,
- goodsId: this.goodsId,
- moduleExamId: this.moduleId || 0,
- chapterExamId: this.chapterId || 0,
- questionIds: [this.questionList[bindex].questionId],
- recordId: this.recordId,
- })
- .then((res) => {});
- } else {
- // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
- // if(question) {
- // this.$api.wrongRecordDelete({
- // "examId": +this.id,
- // "goodsId": +this.goodsId,
- // "questionId": this.questionList[bindex].questionId,
- // }).then(res => {
- // })
- // }
- }
- },
- /**
- * @param {Object} e案例单选点击
- */
- radioSelectChild(optionsId, ansIndex, bindex) {
- if (this.questionList[bindex].ques[ansIndex]) return;
- this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
- this.isDoOver();
- },
- /**
- * @param {Object} 多选点击
- */
- checkboxSelect(optionsId, bindex, index) {
- this.$set(
- this.questionList[bindex].jsonStr[index],
- "checked",
- !this.questionList[bindex].jsonStr[index].checked
- );
- },
- /**
- * @param {Object} 案例多选点击
- */
- checkboxSelectChild(bindex, ansIndex, childIndex) {
- this.$set(
- this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],
- "checked",
- !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex]
- .checked
- );
- },
- isCheckboxChecked(arr) {
- return arr.some((item) => {
- if (item.checked) {
- return true;
- }
- });
- },
- /**
- * @param {Object} 多选确认
- */
- checkboxSubmit(bindex) {
- if (this.questionList[bindex].ques) return;
- let arr = [];
- this.questionList[bindex].jsonStr.forEach((item) => {
- if (item.checked) {
- arr.push(item.optionsId);
- }
- });
- if (!arr.length) {
- uni.showToast({
- title: "请选择答案",
- icon: "none",
- });
- return;
- }
- this.$set(this.questionList[bindex], "ques", arr);
- this.isDoOver();
- let isWrong = this.questionList[bindex].ques.some(
- (quesItem, quesIndex) => {
- return (
- this.questionList[bindex].ques[quesIndex] !=
- this.questionList[bindex].ans[quesIndex]
- );
- }
- );
- // 回答错误
- if (isWrong) {
- this.$api
- .examWrongRecord({
- orderGoodsId: this.orderGoodsId,
- examId: this.id,
- goodsId: this.goodsId,
- moduleExamId: this.moduleId || 0,
- chapterExamId: this.chapterId || 0,
- questionIds: [this.questionList[bindex].questionId],
- recordId: this.recordId,
- })
- .then((res) => {});
- } else {
- // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
- // if(question) {
- // this.$api.wrongRecordDelete({
- // "examId": +this.id,
- // "goodsId": +this.goodsId,
- // "questionId": this.questionList[bindex].questionId,
- // }).then(res => {
- // })
- // }
- }
- },
- /**
- * @param {Object} 案例多选确认
- */
- checkboxSubmitChild(bindex, ansIndex) {
- if (this.questionList[bindex].ques[ansIndex]) return;
- let arr = [];
- this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
- (item) => {
- if (item.checked) {
- arr.push(item.optionsId);
- }
- }
- );
- if (!arr.length) {
- uni.showToast({
- title: "请选择答案",
- icon: "none",
- });
- return;
- }
- this.$set(this.questionList[bindex].ques, ansIndex, arr);
- this.isDoOver();
- },
- /**
- * @param {Object} index
- * @param {Object} bindex
- * 判断题
- */
- judgeSelect(index, bindex) {
- if (this.questionList[bindex].ques) return;
- this.$set(this.questionList[bindex], "ques", index + "");
- this.isDoOver();
- // 回答错误
- if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
- this.$api
- .examWrongRecord({
- orderGoodsId: this.orderGoodsId,
- examId: this.id,
- goodsId: this.goodsId,
- moduleExamId: this.moduleId || 0,
- chapterExamId: this.chapterId || 0,
- questionIds: [this.questionList[bindex].questionId],
- recordId: this.recordId,
- })
- .then((res) => {});
- } else {
- // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
- // if(question) {
- // this.$api.wrongRecordDelete({
- // "examId": +this.id,
- // "goodsId": +this.goodsId,
- // "questionId": this.questionList[bindex].questionId,
- // }).then(res => {
- // })
- // }
- }
- },
- /**
- * @param {Object} ansindex
- * @param {Object} childindex
- * @param {Object} bindex
- * 案例判断题
- */
- judgeSelectChild(ansindex, childindex, bindex) {
- if (this.questionList[bindex].ques[ansindex]) return;
- this.$set(this.questionList[bindex].ques, ansindex, childindex + "");
- this.isDoOver();
- },
- openFooterTab() {
- this.show = true;
- },
- changeIndex(index) {
- this.current = index;
- },
- swiperChange(e) {
- this.current = e.detail.current;
- this.getCollectInfo(this.current);
- },
- /**
- * @param {Object} current
- * 获取收藏信息
- */
- getCollectInfo(current) {
- this.$api
- .getCollectInfo({
- examId: this.id,
- questionId: this.questionList[current].questionId,
- goodsId: this.goodsId,
- orderGoodsId: this.orderGoodsId,
- })
- .then((res) => {
- if (res.data.code == 500) {
- this.$set(this.collectList, current, false);
- } else if (res.data.code == 200) {
- this.$set(this.collectList, current, res.data.data);
- }
- });
- },
- showpopupsEvent(data) {
- this.cgType = data;
- this.showpopups = true;
- },
- pdsubmit() {
- // if (this.bankType == 1) {
- let ansCount = this.$refs.bankExam.questionOverNum(true); //已答题数
- this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
- //没有答完
- if (this.lastCount !== 0) {
- this.cgType = 6;
- this.showpopups = true;
- return;
- }
- // }
- if (this.bankType == 2) {
- if (this.lastTime > 0) {
- let lastTime = this.countdown(this.lastTime);
- uni.showModal({
- title: "提示",
- content: `时间还剩余${lastTime},确定交卷吗?`,
- confirmText: "交卷",
- cancelText: "继续答题",
- success: (res) => {
- if (res.confirm) {
- //确定
- this.submit();
- } else {
- //取消
- }
- },
- });
- return;
- }
- }
- this.submit();
- },
- /**
- * 交卷
- */
- submit() {
- let score = 0; //计算总分
- let reportStatus = 0;
- let number = 0; //做对的题目数量
- let doQuestionNum = 0; //做过的题目数量
- let allScore = 0; //总分
- let passScore = 0;
- let doWrongQuestionIds = []; //错题和未做题id(客观题)
- let doQuestionIds = []; //做过的题目id
- let lessQuestionNum = 0;
- let rightQuestionIds = []; //做对的题目id
- this.questionList.forEach((item, index) => {
- passScore = item.passScore;
- if (item.type == 1) {
- //正确
- if (item.ques == item.ans) {
- item.scoreResult = item.score;
- score += item.score;
- number++;
- rightQuestionIds.push(item.questionId);
- } else {
- //错误
- item.scoreResult = 0;
- if (item.ques) {
- doWrongQuestionIds.push(item.questionId);
- }
- }
- allScore += item.score;
- if (item.ques) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item.type == 2) {
- let isRight =
- item.ans &&
- item.ans.every((quesItem, quesIndex) => {
- if (item.ques) {
- return item.ques[quesIndex] == item.ans[quesIndex];
- } else {
- return false;
- }
- });
- if (isRight) {
- score += item.score;
- number++;
- item.scoreResult = item.score;
- rightQuestionIds.push(item.questionId);
- } else {
- let hasPart = false;
- let checkboxScore = 1; //获取单题总分数
- item.ques &&
- item.ques.forEach((ques, quesIndex) => {
- //选错一个全扣
- if (item.ques) {
- if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
- checkboxScore = 0;
- }
- } else {
- checkboxScore = 0;
- }
- });
- //没选错
- if (checkboxScore) {
- checkboxScore = 0;
- item.ans.forEach((ans, quesIndex) => {
- //漏选扣一部分,对n题给n X partScore 分
- if (item.ques) {
- if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
- checkboxScore += item.partScore;
- hasPart = true;
- }
- } else {
- checkboxScore = 0;
- }
- });
- }
- if (!hasPart) {
- //0分
- item.scoreResult = 0;
- if (item.ques) {
- doWrongQuestionIds.push(item.questionId);
- }
- } else {
- //部分分
- // number++;
- lessQuestionNum++
- // doWrongQuestionIds.push(item.questionId);
- item.scoreResult = checkboxScore;
- score += checkboxScore;
- // rightQuestionIds.push(item.questionId)
- }
- }
- allScore += item.score;
- if (item.ques && item.ques.length) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item.type == 3) {
- if (item.ques == item.ans) {
- item.scoreResult = item.score;
- score += item.score;
- number++;
- rightQuestionIds.push(item.questionId);
- } else {
- item.scoreResult = 0;
- if (item.ques) {
- doWrongQuestionIds.push(item.questionId);
- }
- }
- allScore += item.score;
- if (item.ques) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item.type == 4) {
- allScore += item.score;
- if (item.ques && item.ques.length) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- } else if (item.type == 5) {
- allScore += item.score;
- if (item.ques && (item.ques.imageList.length || item.ques.text)) {
- doQuestionNum++;
- doQuestionIds.push(item.questionId);
- }
- }
- });
- //大于及格
- if (score >= passScore) {
- reportStatus = 1;
- } else {
- reportStatus = 0;
- }
- //交卷
- this.$api
- .examRecordEdit({
- examId: this.id,
- goodsId: this.goodsId,
- reportStatus: reportStatus,
- recordId: this.recordId,
- rightQuestionNum: number,
- orderGoodsId: this.orderGoodsId,
- status: 1,
- lessQuestionNum:lessQuestionNum,
- moduleExamId: this.moduleId || 0,
- chapterExamId: this.chapterId || 0,
- doQuestionIds: doQuestionIds.join(","),
- rightQuestionIds: rightQuestionIds.join(","),
- doQuestionNum: doQuestionNum,
- performance: score,
- totalScore: allScore,
- examTime: parseInt(this.allTimes),
- doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
- historyExamJson: JSON.stringify(this.questionList),
- })
- .then((res) => {
- this.isSubmit = true;
- if (res.data.code == 200) {
- uni.showToast({
- title: "交卷成功",
- duration: 1000,
- icon: "none",
- });
- setTimeout(() => {
- uni.redirectTo({
- url:
- "/pages2/bank/question_report?goodsId=" +
- this.goodsId +
- "&chapterId=" +
- this.chapterId +
- "&moduleId=" +
- this.moduleId +
- "&examId=" +
- this.id +
- "&id=" +
- this.recordId +
- "&orderGoodsId=" +
- this.orderGoodsId,
- });
- }, 1000);
- }
- });
- //错题集id提交(客观题)
- this.$api
- .examWrongRecord({
- examId: this.id,
- goodsId: this.goodsId,
- orderGoodsId: this.orderGoodsId,
- questionIds: doWrongQuestionIds,
- recordId: this.recordId,
- })
- .then((res) => {});
- },
- /**
- * @param {Object} state
- * @param {Object} index
- * 收藏
- */
- collect(state, index) {
- if (!state) {
- this.$api
- .collectQuestion({
- examId: this.id,
- questionId: this.questionList[index].questionId,
- goodsId: this.goodsId || "",
- orderGoodsId: this.orderGoodsId,
- })
- .then((res) => {
- if (res.data.code == 200) {
- this.$set(this.collectList, index, true);
- uni.showToast({
- title: "收藏成功",
- duration: 2000,
- icon: "none",
- });
- this.getCollectInfo(index);
- }
- });
- } else {
- this.$api
- .deleteCollectQuestion(this.collectList[index].collectQuestionId)
- .then((res) => {
- if (res.data.code == 200) {
- this.$set(this.collectList, index, false);
- uni.showToast({
- title: "取消收藏成功",
- duration: 2000,
- icon: "none",
- });
- }
- });
- }
- return;
- },
- /**
- * @param {Object} imgIndex
- * @param {Object} bankIndex
- * 删除简答图片
- */
- deleteImg(imgIndex, bankIndex) {
- this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
- },
- /**
- * @param {Object} imgIndex
- * @param {Object} bankIndex
- * @param {Object} ansIndex
- * 删除案例题简答图片
- */
- deleteImgChild(imgIndex, bankIndex, ansIndex) {
- this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
- imgIndex,
- 1
- );
- },
- /**
- * @param {Object} bankindex
- * 选择上传图片
- */
- chooseImg(bankindex) {
- if (
- this.questionList[bankindex] &&
- this.questionList[bankindex].ansText &&
- this.questionList[bankindex].ansText.imageList.length >= 4
- ) {
- uni.showToast({
- icon: "none",
- title: "最多选择4张",
- });
- return;
- }
- uni.chooseImage({
- count: 1, //默认9
- sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ["album", "camera"], //从相册选择
- success: (res) => {
- let self = this;
- // console.log(JSON.stringify(res.tempFilePaths));
- let img = res.tempFilePaths[0];
- uni.getImageInfo({
- src: img,
- success: async (res) => {
- let canvasWidth = res.width; //图片原始长宽
- let canvasHeight = res.height;
- if (canvasWidth > 1000 || canvasHeight > 1000) {
- uni.compressImage({
- src: img,
- quality: 75,
- width: "50%",
- height: "50%",
- success: async (rest) => {
- const dir = await self.uploadFile(rest.tempFilePath, 0);
- this.questionList[bankindex].ansText.imageList.push(dir);
- },
- });
- } else {
- const dir = await self.uploadFile(img, 0);
- this.questionList[bankindex].ansText.imageList.push(dir);
- }
- },
- });
- },
- });
- },
- /**
- * @param {Object} bankindex
- * @param {Object} ansindex
- * 案例题选择上传图片
- */
- chooseImgChild(bankindex, ansindex) {
- if (
- this.questionList[bankindex].jsonStr[ansindex] &&
- this.questionList[bankindex].jsonStr[ansindex].ansText &&
- this.questionList[bankindex].jsonStr[ansindex].ansText.imageList
- .length >= 4
- ) {
- uni.showToast({
- icon: "none",
- title: "最多选择4张",
- });
- return;
- }
- uni.chooseImage({
- count: 1, //默认9
- sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ["album", "camera"], //从相册选择
- success: (res) => {
- let self = this;
- // console.log(JSON.stringify(res.tempFilePaths));
- let img = res.tempFilePaths[0];
- uni.getImageInfo({
- src: img,
- success: async (res) => {
- let canvasWidth = res.width; //图片原始长宽
- let canvasHeight = res.height;
- if (canvasWidth > 1000 || canvasHeight > 1000) {
- uni.compressImage({
- src: img,
- quality: 75,
- width: "50%",
- height: "50%",
- success: async (rest) => {
- const dir = await self.uploadFile(rest.tempFilePath, 0);
- this.questionList[bankindex].jsonStr[
- ansindex
- ].ansText.imageList.push(dir);
- },
- });
- } else {
- const dir = await self.uploadFile(img, 0);
- this.questionList[bankindex].jsonStr[
- ansindex
- ].ansText.imageList.push(dir);
- }
- },
- });
- },
- });
- },
- uploadFile(options, int) {
- var self = this;
- return new Promise((resolve, reject) => {
- var data = {
- orderGoodsId: this.orderGoodsId,
- imageStatus: int,
- };
- self.$api.aliyunpolicy(data).then((res) => {
- console.log(res.data, 6);
- if (res.data.code != 200) {
- self.$method.showToast("签名错误" + JSON.stringify(res.data));
- return;
- }
- var ossToken = res.data.data.resultContent;
- if (ossToken.host == null || ossToken.host == undefined) {
- self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
- return;
- }
- uni.uploadFile({
- url: ossToken.host,
- name: "file",
- filePath: options,
- fileType: "image",
- header: {
- AuthorizationToken: "WX " + uni.getStorageSync("token"),
- },
- formData: {
- key: ossToken.dir,
- OSSAccessKeyId: ossToken.accessid,
- policy: ossToken.policy,
- Signature: ossToken.signature,
- callback: ossToken.callback,
- success_action_status: 200,
- },
- success: (result) => {
- if (result.statusCode === 200) {
- resolve(ossToken.dir);
- } else {
- uni.showToast({
- title: "上传失败",
- icon: "none",
- });
- return;
- }
- },
- fail: (error) => {
- uni.showToast({
- title: "上传接口报错" + error,
- icon: "none",
- });
- return;
- },
- });
- });
- });
- },
- /**
- * @param {Object} type
- * @param {Object} bankindex
- * 简答题答案确认
- */
- submitAns(bankindex) {
- console.log(this.questionList[bankindex]);
- if (
- !this.questionList[bankindex].ansText.text &&
- !this.questionList[bankindex].ansText.imageList.length
- ) {
- uni.showToast({
- title: "请输入内容或上传图片",
- duration: 2000,
- icon: "none",
- });
- return;
- }
- this.$set(this.questionList[bankindex], "ques", {
- imageList: this.questionList[bankindex].ansText.imageList || [],
- text: this.questionList[bankindex].ansText.text || "",
- });
- this.isDoOver();
- },
- /**
- * @param {Object} bankindex
- * @param {Object} ansindex
- * 案例题简答答案确认
- */
- submitAnsChild(bankindex, ansindex) {
- if (
- !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
- !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
- ) {
- uni.showToast({
- title: "请输入内容或上传图片",
- duration: 2000,
- icon: "none",
- });
- return;
- }
- this.$set(this.questionList[bankindex].ques, ansindex, {
- imageList:
- this.questionList[bankindex].jsonStr[ansindex].ansText.imageList ||
- [],
- text: this.questionList[bankindex].jsonStr[ansindex].ansText.text || "",
- });
- this.isDoOver();
- },
- isRight(item, index) {
- //单选
- if (this.questionList[index].ques) {
- if (item.type == 1) {
- return this.questionList[index].ques == this.questionList[index].ans;
- //多选
- } else if (item.type == 2) {
- //每一项都相等
- return this.questionList[index].ans.every((item, i) => {
- return item == this.questionList[index].ques[i];
- });
- //判断
- } else if (item.type == 3) {
- return this.questionList[index].ques == this.questionList[index].ans;
- // } else if (item.type == 5) {
- // if(this.questionList[index].ques.text){
- // return true
- // }else{
- // return false
- // }
- } else {
- return false;
- }
- } else {
- return false;
- }
- },
- right(bankIndex, ansIndex, option) {
- if (
- this.questionList[bankIndex].ques[ansIndex] &&
- this.questionList[bankIndex].ans[ansIndex]
- ) {
- if (
- this.questionList[bankIndex].ques[ansIndex].indexOf(
- option.optionsId
- ) != -1 ||
- this.questionList[bankIndex].ans[ansIndex].indexOf(
- option.optionsId
- ) != -1
- ) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- },
- wrong(bankIndex, ansIndex, option) {
- if (
- this.questionList[bankIndex].ques[ansIndex] &&
- this.questionList[bankIndex].ans[ansIndex]
- ) {
- if (
- this.questionList[bankIndex].ques[ansIndex].indexOf(
- option.optionsId
- ) != -1 &&
- this.questionList[bankIndex].ans[ansIndex].indexOf(
- option.optionsId
- ) == -1
- ) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- },
- isWrong(item, index) {
- if (this.questionList[index].ques) {
- //单选
- if (item.type == 1) {
- return this.questionList[index].ques != this.questionList[index].ans;
- //多选
- } else if (item.type == 2) {
- //每一项都相等
- return this.questionList[index].ques.some((item, i) => {
- return this.questionList[index].ans.indexOf(item) == -1;
- });
- //判断
- } else if (item.type == 3) {
- return this.questionList[index].ques != this.questionList[index].ans;
- } else {
- return false;
- }
- } else {
- return false;
- }
- },
- isPart(item, index) {
- if (this.questionList[index].ques) {
- if (item.type == 2) {
- let isWrong = this.questionList[index].ques.some((item, i) => {
- return this.questionList[index].ans.indexOf(item) == -1;
- });
- let isRight = this.questionList[index].ans.every((item, i) => {
- return item == this.questionList[index].ques[i];
- });
- if (!isRight && !isWrong) {
- return true;
- }
- }
- } else {
- return false;
- }
- },
- isOver(item, index) {
- if (this.questionList[index].ques) {
- if (item.type == 4) {
- //案例题
- let isOver = item.jsonStr.every((jsonItem, indexs) => {
- if (
- jsonItem.type == 1 ||
- jsonItem.type == 2 ||
- jsonItem.type == 3
- ) {
- if (item.ques[indexs]) {
- return true;
- } else {
- return false;
- }
- } else if (jsonItem.type == 5) {
- if (
- item.ques[indexs] &&
- (item.ques[indexs].text || item.ques[indexs].imageList.length)
- ) {
- console.log("chil");
- return true;
- } else {
- return false;
- }
- }
- });
- if (isOver) {
- return true;
- } else {
- return false;
- }
- } else if (item.type == 5) {
- //简答题
- //每一项都相等
- if (item.ques && (item.ques.imageList.length || item.ques.text)) {
- return true;
- }
- //判断
- } else {
- return false;
- }
- } else {
- return false;
- }
- },
- tabSelect(index, bankindex) {
- this.$set(this.questionList[bankindex], "current", index);
- },
- showPhoto(contentStr) {
- if (contentStr && typeof contentStr == "string") {
- let reg = /<img[^>]*src[=\'\"\s]+([^\'\"]*)[\'\"]?[^>]*>/gi;
- let strArr = contentStr.match(reg);
- strArr.forEach((str, index) => {
- strArr[index] = str.replace(reg, "$1");
- });
- // 预览图片
- uni.previewImage({
- urls: strArr,
- longPressActions: {
- itemList: ["发送给朋友", "保存图片", "收藏"],
- success: function (data) {
- console.log(
- "选中了第" +
- (data.tapIndex + 1) +
- "个按钮,第" +
- (data.index + 1) +
- "张图片"
- );
- },
- fail: function (err) {
- console.log(err.errMsg);
- },
- },
- });
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .questionBank {
- width: 100%;
- height: 100vh;
- display: flex;
- flex-direction: column;
- }
- .swiper {
- width: 100%;
- flex: 1;
- }
- .lisSty {
- margin-bottom: 16rpx;
- display: flex;
- align-items: center;
- .flex_auto {
- flex: 1;
- }
- }
- .activeTI {
- vertical-align: middle;
- display: inline-block;
- border: 1rpx solid #eee;
- border-radius: 50rpx;
- height: 48rpx;
- line-height: 46rpx;
- text-align: center;
- width: 48rpx;
- margin-right: 15rpx;
- color: #666;
- font-size: 30rpx;
- &.right {
- color: #fff;
- background: #36c75a;
- }
- &.wrong {
- color: #fff;
- background: #ff3b30;
- }
- &.checked {
- color: #fff;
- background: #007aff;
- }
- }
- .submit_checkbox {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 120rpx;
- margin: 20rpx auto;
- width: 526rpx;
- height: 80rpx;
- background: rgba(0, 122, 255, 1);
- color: #fff;
- text-align: center;
- line-height: 80rpx;
- font-size: 30rpx;
- border-radius: 40rpx;
- &.disabled {
- opacity: 0.6;
- }
- }
- .titles {
- overflow: hidden;
- margin-bottom: 24rpx;
- }
- .titBox {
- padding: 41rpx 25rpx 24rpx 25rpx;
- }
- .titBox_title {
- padding: 21rpx;
- }
- .tabs {
- margin: 10rpx;
- display: flex;
- .tab {
- margin: 0 4rpx;
- padding: 10rpx 13rpx;
- text-align: center;
- color: #007aff;
- font-size: 28rpx;
- border-radius: 16rpx;
- background: #fff;
- &.current {
- color: #fff;
- background: #007aff;
- }
- }
- }
- .ans {
- margin: 8rpx 8rpx 8rpx;
- .ans_input {
- border-radius: 16rpx;
- background: #fff;
- .top {
- border-bottom: 1rpx solid #eeeeee;
- padding: 16rpx;
- display: flex;
- align-items: center;
- .icon {
- margin-right: 20rpx;
- width: 40rpx;
- height: 38rpx;
- }
- .progress {
- flex: 1;
- }
- .submit {
- width: 168rpx;
- height: 48rpx;
- line-height: 48rpx;
- text-align: center;
- color: #fff;
- font-size: 30rpx;
- background: #007aff;
- border-radius: 24rpx;
- &.disabled {
- opacity: 0.6;
- }
- }
- }
- .textarea {
- textarea {
- width: 100%;
- height: 287rpx;
- padding: 10rpx;
- }
- }
- .imgs {
- overflow: hidden;
- display: flex;
- width: 100%;
- .img {
- width: 104rpx;
- height: 104rpx;
- border-radius: 8rpx;
- position: relative;
- margin: 20rpx;
- text {
- position: absolute;
- right: -15rpx;
- top: -15rpx;
- width: 30rpx;
- height: 30rpx;
- text-align: center;
- line-height: 30rpx;
- color: #fff;
- background: #ff3b30;
- border-radius: 50%;
- }
- image {
- width: 100%;
- height: 100%;
- }
- }
- }
- }
- .ans_submit {
- padding: 16rpx;
- border-radius: 16rpx;
- background: #fff;
- .imgs {
- overflow: hidden;
- display: flex;
- width: 100%;
- .img {
- width: 104rpx;
- height: 104rpx;
- border-radius: 8rpx;
- position: relative;
- margin: 20rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- }
- }
- }
- .leftLetters {
- display: flex;
- align-items: center;
- width: 220rpx;
- .btnType {
- padding: 5rpx 10rpx;
- border: 1rpx solid #007aff;
- border-radius: 10rpx;
- background-color: rgba(0, 122, 255, 0.1);
- font-size: 28rpx;
- color: #007aff;
- margin-right: 15rpx;
- }
- }
- .firstLetter {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 30rpx;
- }
- .popupView {
- height: 100%;
- padding-bottom: 100rpx;
- .popupTops {
- height: 77rpx;
- border-bottom: 1rpx solid #eee;
- text-align: center;
- line-height: 77rpx;
- font-size: 24rpx;
- color: #999;
- position: relative;
- .topIcon {
- position: absolute;
- top: 10rpx;
- left: 50%;
- transform: translateX(-50%);
- width: 80rpx;
- height: 8rpx;
- background-color: #999;
- border-radius: 4rpx;
- }
- }
- .popupContent {
- }
- }
- .pageContent {
- position: relative;
- background-color: #eaeef1;
- height: 100%;
- padding-top: 8rpx;
- padding-bottom: 100rpx;
- overflow-y: scroll;
- }
- .pad_8 {
- background-color: #fff;
- margin: 0rpx 8rpx 8rpx;
- border-radius: 16rpx;
- &.no-margin {
- margin-top: -16rpx;
- border-radius: 0 0 16rpx 16rpx;
- }
- }
- .answer {
- height: 80rpx;
- line-height: 80rpx;
- padding: 0rpx 24rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- color: #666;
- font-size: 30rpx;
- }
- .footer_btn {
- background-color: #fff;
- z-index: 10078;
- position: fixed;
- bottom: 0rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 100%;
- height: 98rpx;
- padding: 0rpx 38rpx;
- border-top: 1rpx solid #eee;
- .flex_center {
- flex: 1;
- display: flex;
- justify-content: center;
- align-items: center;
- flex-direction: column;
- margin: 0 200rpx;
- font-size: 24rpx;
- color: #999999;
- .up-icon {
- margin-bottom: 18rpx;
- width: 100%;
- display: flex;
- justify-content: center;
- image {
- width: 58rpx;
- height: 21rpx;
- }
- }
- }
- .collect {
- visibility: hidden;
- width: 100rpx;
- &.show {
- visibility: visible;
- }
- > view {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- image {
- width: 32rpx;
- height: 32rpx;
- margin-bottom: 6rpx;
- }
- view {
- font-size: 24rpx;
- color: #999999;
- }
- }
- }
- }
- .boxSty {
- padding: 44rpx 41rpx 0rpx;
- }
- .liListSty {
- border: 1rpx solid #eeeeee;
- width: 88rpx;
- height: 88rpx;
- border-radius: 32rpx;
- text-align: center;
- line-height: 88rpx;
- color: #333;
- font-size: 32rpx;
- float: left;
- margin: 20rpx 23rpx;
- &.isRight {
- border: 1rpx solid #eeeeee;
- color: #fff;
- background: #36c75a;
- }
- &.isWrong {
- border: 1rpx solid #eeeeee;
- color: #fff;
- background: #ff3b30;
- }
- &.isPart {
- border: 1rpx solid #eeeeee;
- color: #fff;
- background: #FFC53D;
- }
- &.isOver {
- border: 1rpx solid #eeeeee;
- color: #fff;
- background: blue;
- }
- }
- .answerInfos {
- padding: 25rpx 25rpx 25rpx 23rpx;
- }
- .answerTitle {
- margin-bottom: 28rpx;
- color: #666;
- font-size: 30rpx;
- }
- .answerContent {
- font-size: 30rpx;
- color: #666;
- }
- .textChild {
- display: inline-block;
- vertical-align: middle;
- }
- .dialog {
- position: fixed;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.8);
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- z-index: 20000;
- .pointer {
- width: 338rpx;
- height: 240rpx;
- }
- .text {
- font-size: 32rpx;
- color: #ffffff;
- text-align: center;
- }
- .btn {
- width: 242rpx;
- height: 82rpx;
- border: 2rpx solid #ffffff;
- border-radius: 16rpx;
- text-align: center;
- line-height: 82rpx;
- margin: 41rpx auto;
- color: #fff;
- font-size: 32rpx;
- }
- }
- .dialog-arrow {
- padding-top: 124rpx;
- position: fixed;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.8);
- z-index: 20000;
- .pointer {
- margin-left: 87rpx;
- display: block;
- width: 95rpx;
- height: 98rpx;
- }
- .text {
- padding-left: 177rpx;
- font-size: 32rpx;
- color: #ffffff;
- }
- .btn {
- width: 242rpx;
- height: 82rpx;
- border: 2rpx solid #ffffff;
- border-radius: 16rpx;
- text-align: center;
- line-height: 82rpx;
- margin: 500rpx auto 0;
- color: #fff;
- font-size: 32rpx;
- }
- }
- .dialog_wrap {
- position: fixed;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- z-index: 9999999999;
- .bg {
- background: rgba(0, 0, 0, 0.3);
- position: absolute;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- }
- .dialog {
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate3D(-50%, -50%, 0);
- width: 640rpx;
- height: 439rpx;
- background: #ffffff;
- border-radius: 24rpx;
- .title {
- font-size: 30rpx;
- font-weight: bold;
- color: #333333;
- line-height: 48rpx;
- text-align: center;
- margin-top: 40rpx;
- }
- .content {
- margin: 35rpx 35rpx 0;
- font-size: 30rpx;
- color: #666666;
- line-height: 48rpx;
- }
- .btns {
- margin-top: 35rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- .btn {
- width: 200rpx;
- height: 80rpx;
- line-height: 80rpx;
- text-align: center;
- background: #f5f5f5;
- border-radius: 40rpx;
- font-size: 30rpx;
- color: rgba(0, 122, 255, 1);
- background: #f5f5f5;
- margin: 0 20rpx;
- &.active {
- color: #f5f5f5;
- background: rgba(0, 122, 255, 1);
- }
- }
- }
- }
- }
- .popboxs {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .classTops {
- flex-shrink: 0;
- padding: 39rpx 0rpx 4rpx;
- font-weight: bold;
- color: #333;
- font-size: 30rpx;
- }
- .textStys {
- width: 100%;
- flex: 1;
- padding: 36rpx;
- }
- .classFootsty {
- flex-shrink: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 10rpx 0rpx 40rpx;
- .btnsty {
- width: 200rpx;
- height: 80rpx;
- border-radius: 40rpx;
- font-weight: bold;
- font-size: 30rpx;
- text-align: center;
- line-height: 80rpx;
- }
- .btns1 {
- background-color: #f5f5f5;
- color: #007aff;
- }
- .btns2 {
- margin-left: 40rpx;
- background-color: #007aff;
- color: #ffffff;
- }
- }
- </style>
|