From 700eb98db0151940cc91abcc5b3149ce23ec42de Mon Sep 17 00:00:00 2001 From: 马宇豪 <978517621@qq.com> Date: 星期四, 08 八月 2024 08:55:49 +0800 Subject: [PATCH] 提交 --- pages/tabBar/firstPage/exam.vue | 84 ++++++++++++++++++++++++++++++++++++------ 1 files changed, 72 insertions(+), 12 deletions(-) diff --git a/pages/tabBar/firstPage/exam.vue b/pages/tabBar/firstPage/exam.vue index 9771e02..2171269 100644 --- a/pages/tabBar/firstPage/exam.vue +++ b/pages/tabBar/firstPage/exam.vue @@ -39,7 +39,6 @@ placement="column" class="myRadio" iconPlacement="right" - :disabled="viewType==1?false:true" @change="checkboxChange" > <u-checkbox @@ -59,7 +58,7 @@ placement="column" class="myRadio" iconPlacement="right" - :disabled="viewType==1?false:true" + disabled @change="checkboxChange" > <u-checkbox @@ -73,7 +72,7 @@ </u-checkbox> </u-checkbox-group> - <u-radio-group v-model="currentA" class="myRadio" iconPlacement="right" placement="column" @change="groupChange" v-if="viewType == 1 && (currentQ.questionType==1||currentQ.questionType==3)" :disabled="viewType==1?false:true"> + <u-radio-group v-model="currentA" class="myRadio" iconPlacement="right" placement="column" @change="groupChange" v-if="viewType == 1 && (currentQ.questionType==1||currentQ.questionType==3)"> <u-radio :customStyle="{marginBottom: '15px'}" v-for="(item, index) in currentQ.content.items" @@ -87,7 +86,7 @@ </u-radio> </u-radio-group> - <u-radio-group v-model="currentA" class="myRadio" iconPlacement="right" placement="column" @change="groupChange" v-if="viewType == 2 && (currentQ.questionType==1||currentQ.questionType==3)" :disabled="viewType==1?false:true"> + <u-radio-group v-model="currentA" class="myRadio" iconPlacement="right" placement="column" @change="groupChange" v-if="viewType == 2 && (currentQ.questionType==1||currentQ.questionType==3)" disabled> <u-radio :customStyle="{marginBottom: '15px'}" v-for="(item, index) in currentQ.content.items" @@ -100,12 +99,16 @@ > </u-radio> </u-radio-group> + + <u--textarea v-model="currentA" v-if="viewType == 1 &&(currentQ.questionType==4)" style="margin-bottom: 15px" :maxlength="-1" placeholder="请输入答案" autoHeight @focus="openAnswer"></u--textarea> + <u--textarea v-model="currentA" v-if="viewType == 2 &&(currentQ.questionType==4)" :class="currentQ.answer == currentA?'pickedText':'wrongText'" style="margin-bottom: 15px" :maxlength="-1" placeholder="请输入答案" autoHeight disabled></u--textarea> + <u-button style="width: 80%;margin: 5px auto 15px" v-if="currentQ.questionType==2 && currentB.length>0 && viewType ==1" type="primary" shape="circle" text="确认答案" @click="confirmAnswer(2)"></u-button> - <view class="answers" v-if="viewType == 2 && currentQ.studentAnswer && currentQ.studentAnswer.answer"> + <view class="answers" v-if="viewType == 2"> <view>你的答案: - <span :class="currentQ.answer == currentQ.studentAnswer.answer?'right':'wrong'">{{currentQ.studentAnswer.answer}}</span> + <span :class="(currentQ.studentAnswer && currentQ.studentAnswer.answer) && (currentQ.answer == currentQ.studentAnswer.answer)?'right':'wrong'">{{(currentQ.studentAnswer && currentQ.studentAnswer.answer)?currentQ.studentAnswer.answer:'暂未作答'}}</span> <!-- <span v-else :class="currentQ.answer == currentQ.studentAnswer.answer?'right':'wrong'">{{currentQ.studentAnswer.answer}}</span>--> </view> <view>正确答案:<span class="right">{{currentQ.answer}}</span></view> @@ -120,10 +123,21 @@ <u-button v-if="curTotalIndex == idList.length - 1 && viewType == 2" style="width: 30%" type="primary" shape="circle" size="small" text="退出" @click="goBack"></u-button> </view> <u-popup :show="showPanel" :round="40" mode="bottom" @close="close" @open="open"> - <view class="panel"> - <view :class="(viewType==2 && item.passed==1)?'right-a':(viewType==2 && item.passed==0)?'wrong-a':''" v-for="(item,index) in idList" @click="toQuestion(item,index)"> + <view class="panel" v-if="viewType == 1"> + <view :class="item.state==1?'right-a':''" v-for="(item,index) in idList" @click="toQuestion(item,index)"> {{index + 1}} </view> + </view> + <view class="panel" v-else> + <view :class="item.passed==1?'right-a':item.passed==0?'wrong-a':''" v-for="(item,index) in idList" @click="toQuestion(item,index)"> + {{index + 1}} + </view> + </view> + </u-popup> + <u-popup :show="showInput" :round="40" mode="bottom" @close="closeInput" @open="openInput"> + <view class="panelTwo"> + <u--textarea v-model="currentA" :maxlength="-1" placeholder="请输入答案"></u--textarea> + <u-button shape="circle" type="primary" style="width: 80%;margin-top: 20px" text="确认答案" @click="confirmAnswer(1)"></u-button> </view> </u-popup> </view> @@ -164,6 +178,7 @@ elapsedTime: 0, timerInterval: null, showPanel: false, + showInput: false, limitTime: 0 } }, @@ -176,14 +191,15 @@ this.startTime = this.bank.startTime?this.bank.startTime:0 this.getQuestionIds(this.bank.paperId) this.limitTime = this.bank.examPaper.limited == 1?this.bank.examPaper.limitTime:0 + if(this.viewType == 1){ + this.startTimer() + } }, onShow(){ }, mounted() { - if(this.viewType == 1){ - this.startTimer() - } + }, computed: { formattedTime() { @@ -194,6 +210,7 @@ return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`; } }, + beforeUnmount() { }, @@ -222,7 +239,10 @@ uni.$u.toast(res.message) } }, - + openAnswer(){ + const t = this + t.showInput = true + }, async toQuestion(item,index){ this.curTotalIndex = index const curIdList = this.idList.slice(this.curTotalIndex,this.curTotalIndex + 20) @@ -239,6 +259,13 @@ close() { this.showPanel = false // console.log('close'); + }, + + openInput() { + // console.log('open'); + }, + closeInput(){ + this.showInput = false }, updateTimer() { @@ -325,6 +352,10 @@ }, confirmAnswer(type){ + if(type == 1 && this.currentA == ''){ + uni.$u.toast('答案为空,请先作答') + return + } const data = { answer: this.currentQ.questionType==2?this.currentB.join(','):this.currentA, paperId: this.bank.paperId, @@ -340,6 +371,9 @@ Vue.set(this.currentQ.studentAnswer, 'answer', data.answer); if(type == 2){ this.nextQ() + } + if(this.showInput == true){ + this.showInput = false } // uni.$u.toast('答案已提交') }else{ @@ -555,6 +589,17 @@ } } +.panelTwo{ + height: 60vh; + background: #f2f2f2; + padding: 15px; + box-sizing: border-box; + + /deep/ .u-textarea__field{ + height: calc(60vh - 110px) !important; + } +} + .m-p-15{ width: 100%; padding: 0 15px; @@ -623,6 +668,17 @@ .content{ padding-left: 10rpx; + .pickedText{ + border: 1.5px solid #2979ff !important; + } + .wrongText{ + border: 1.5px solid #ed6464 !important; + } + + /deep/ .u-textarea__field{ + min-height: 80px; + } + .answers{ background: #ecf5ff; padding: 10px; @@ -631,7 +687,11 @@ } span{ + width: 100%; + display: block; + white-space: pre-wrap; font-weight: bolder; + word-break: break-word; } .right{ color: #3c9cff -- Gitblit v1.9.2