|
|
@ -4,7 +4,7 @@ |
|
|
|
<template #center> |
|
|
|
<view class="flex"> |
|
|
|
<view class="lastText">剩余时间</view> |
|
|
|
<view class="lastText" style="margin-left: 8rpx;">44:00</view> |
|
|
|
<view class="lastText" style="margin: 8rpx 0 0 8rpx"><up-count-down :time="totalExamTime * 60 * 1000" format="mm:ss" @finish="finishFn" ref="countDownRef"></up-count-down></view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
</up-navbar> |
|
|
@ -19,7 +19,7 @@ |
|
|
|
<view class="count">{{ noNum }}</view> |
|
|
|
</view> |
|
|
|
<view class="mr"> |
|
|
|
<view class="count">{{currentIndex}}/<text>{{questionBankList.length}}</text></view> |
|
|
|
<view class="count">{{currentIndex+1}}/<text>{{questionBankList.length}}</text></view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
@ -64,8 +64,8 @@ |
|
|
|
|
|
|
|
<view class="btn_row flex-b"> |
|
|
|
<!-- @click="$goPage('/pages/exercises/lastPage/lastPage')" --> |
|
|
|
<button class="btn border" @click="debounce(nextQuestion(-1), 500)" :class="{disable: currentIndex==1}" :disabled="currentIndex==1">上一题</button> |
|
|
|
<button class="btn bg" @click="debounce(nextQuestion(1), 500)" :class="{disable: currentIndex>=questionBankList.length}" :disabled="currentIndex>=questionBankList.length">下一题</button> |
|
|
|
<button class="btn border" @click="debounce(nextQuestion(-1), 500)" :class="{disable: currentIndex==0}" :disabled="currentIndex==0">上一题</button> |
|
|
|
<button class="btn bg" @click="debounce(nextQuestion(1), 500)" :class="{disable: currentIndex>=questionBankList.length-1}" :disabled="currentIndex>=questionBankList.length-1">下一题</button> |
|
|
|
</view> |
|
|
|
<view class="analysis" v-if="currentNav==2||(curOption.answer&&curOption.answer!=questionBank.answer)"> |
|
|
|
<view class="tit">题目解析</view> |
|
|
@ -109,7 +109,7 @@ |
|
|
|
<view class="text">收藏</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="submitBtn">交卷</view> |
|
|
|
<view class="submitBtn" @click="handApaper">交卷</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
@ -127,14 +127,14 @@ |
|
|
|
<view class="text">答错</view> |
|
|
|
</view> |
|
|
|
<view class="li" style="margin-left: auto;"> |
|
|
|
<view class="icon">{{currentIndex}}/<text style="color: #999; font-size: 24rpx;">{{quesIdList.length}}</text></view> |
|
|
|
<view class="icon">{{currentIndex+1}}/<text style="color: #999; font-size: 24rpx;">{{questionBankList.length}}</text></view> |
|
|
|
<view class="text">题目</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="ul2"> |
|
|
|
<view class="li2" v-for="(item,index) in questionBankList" :key="index" @click="quesIdListClick(item,index)"> |
|
|
|
<view class="num" :class="{active: index+1==currentIndex}">{{ index+1 }}</view> |
|
|
|
<view class="num" :class="{yes: item.yes==1, no: item.yes==0}">{{ index+1 }} <text v-if="index==currentIndex">当前</text> </view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -143,7 +143,39 @@ |
|
|
|
<up-popup :show="showCommt" @close="showCommtClose" mode="bottom" round="20rpx" closeable> |
|
|
|
<view class="commtCon" style="padding: 30rpx"> |
|
|
|
<up-textarea v-model.trim="contentStr" placeholder="请输入反馈内容" style="margin-top: 50rpx;" maxlength="300"></up-textarea> |
|
|
|
<up-button text="提 交" style="margin-top: 20rpx;" type="primary" @click="submitCommt"></up-button> |
|
|
|
<up-button text="提 交" style="margin-top: 20rpx;" type="primary" @click="submitClick"></up-button> |
|
|
|
</view> |
|
|
|
</up-popup> |
|
|
|
|
|
|
|
<up-popup :show="showCommit" @close="closeCommitPopup" mode="center" round="20rpx" closeable > |
|
|
|
<view class="commitCon"> |
|
|
|
<view class="tit" v-if="remaining">当前考试进度</view> |
|
|
|
<view class="tit" style="color: red;" v-else-if="passScore.value*1>yesNum.value">成绩不合格</view> |
|
|
|
<view class="flex"> |
|
|
|
<view class="commitItem"> |
|
|
|
<view class="num">{{ remaining }}</view> |
|
|
|
<view class="lab">未答题数</view> |
|
|
|
</view> |
|
|
|
<view class="commitItem"> |
|
|
|
<view class="num">{{ questionBankList.length - remaining}}</view> |
|
|
|
<view class="lab">已答题数</view> |
|
|
|
</view> |
|
|
|
<view class="commitItem"> |
|
|
|
<view class="num"><up-count-down :time="totalExamTime * 60 * 60 * 1000" format="HH:mm" ref="countDownRef"/></view> |
|
|
|
<view class="lab">剩余时间</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="imgAdd"> |
|
|
|
<image src="@/static/images/bigImg/addImg.png" mode="widthFix"></image> |
|
|
|
</view> |
|
|
|
<view class="btn_commit_row flex-b" v-if="remaining"> |
|
|
|
<view class="border btn" @click="goBack" >放弃考试</view> |
|
|
|
<view class="btn" @click="closeCommitPopup">继续考试</view> |
|
|
|
</view> |
|
|
|
<view class="btn_commit_row flex-b" v-else> |
|
|
|
<view class="border btn" @click="closeCommitPopup" >继续答题</view> |
|
|
|
<view class="btn" @click="submitBtnFn">现在交卷</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</up-popup> |
|
|
|
|
|
|
@ -156,12 +188,13 @@ |
|
|
|
window.speechSynthesis.speak(speech); // 播报消息 |
|
|
|
} |
|
|
|
|
|
|
|
import { startExam, submitAnswerResultApi, getQuestionApi, questionCommentAdd, startExamDo, questionWrongColle } from '@/config/api.js' |
|
|
|
import { startExam, getQuestionApi, questionCommentAdd, startExamDo, questionWrongColle } from '@/config/api.js' |
|
|
|
import { debounce } from '@/uni_modules/uview-plus'; |
|
|
|
import { |
|
|
|
ref, |
|
|
|
reactive, |
|
|
|
watch |
|
|
|
watch, |
|
|
|
nextTick, |
|
|
|
} from 'vue'; |
|
|
|
const currentNav = ref('1') |
|
|
|
const types = ref([ |
|
|
@ -172,7 +205,7 @@ |
|
|
|
const yesNum = ref(0) |
|
|
|
const noNum = ref(0) |
|
|
|
|
|
|
|
|
|
|
|
let showCommit = ref(false) |
|
|
|
|
|
|
|
import carStore from '@/store/modules/car.js' |
|
|
|
let usecarStore = carStore() |
|
|
@ -181,6 +214,13 @@ |
|
|
|
onLoad, |
|
|
|
onReady |
|
|
|
} from "@dcloudio/uni-app" |
|
|
|
|
|
|
|
let totalExamTime = ref(45) |
|
|
|
let passScore = ref(90) |
|
|
|
onLoad((options)=>{ |
|
|
|
totalExamTime.value = options.totalExamTime |
|
|
|
passScore.value = options.score |
|
|
|
}) |
|
|
|
// 1:单选题,2:多选题,3:判断题 |
|
|
|
function changeNav(val) { |
|
|
|
console.log(window) |
|
|
@ -231,8 +271,8 @@ |
|
|
|
// 请求数据 |
|
|
|
const questionBank = ref({}) |
|
|
|
const questionBankList = ref([]) |
|
|
|
let quesIdList = ref([]) |
|
|
|
let currentIndex = ref(1) |
|
|
|
let examInfo = ref([]) |
|
|
|
let currentIndex = ref(0) |
|
|
|
async function startQuestionFn() { |
|
|
|
try{ |
|
|
|
uni.showLoading({ |
|
|
@ -248,7 +288,7 @@ |
|
|
|
questionBank.value = res.questionBank[0] |
|
|
|
questionBankList.value = res.questionBank |
|
|
|
initOptionArr() |
|
|
|
quesIdList.value = res.quesIdList |
|
|
|
examInfo.value = res |
|
|
|
}catch(e){ |
|
|
|
uni.hideLoading() |
|
|
|
} |
|
|
@ -298,12 +338,14 @@ |
|
|
|
// 如果没有请求就请求一下 |
|
|
|
if(!curOption.value.answer) { |
|
|
|
curOption.value.answer = curOption.value.ans |
|
|
|
await submitAnswerResultFn() |
|
|
|
} |
|
|
|
// 如果答案不一样,并且是第一次请求 |
|
|
|
if(questionBank.value.answer != curOption.value.ans&&curOption.value.isNext != 'next') { |
|
|
|
curOption.value.isNext = 'next' |
|
|
|
questionBank.value.yes = 0 |
|
|
|
return false |
|
|
|
}else if(questionBank.value.answer == curOption.value.ans) { |
|
|
|
questionBank.value.yes = 1 |
|
|
|
} |
|
|
|
} |
|
|
|
curOption.value = {} |
|
|
@ -324,12 +366,13 @@ |
|
|
|
// } |
|
|
|
// const {data: res} = await getQuestionApi(obj) |
|
|
|
questionBank.value = questionBankList.value[currentIndex.value] |
|
|
|
curOption.value = {} |
|
|
|
curOption.value.isNext = '' |
|
|
|
initOptionArr() |
|
|
|
} |
|
|
|
async function quesIdListClick(id, index) { |
|
|
|
curOption.value = {} |
|
|
|
currentIndex.value = index + 1 |
|
|
|
currentIndex.value = index |
|
|
|
getQuestionFn() |
|
|
|
show.value = false |
|
|
|
} |
|
|
@ -355,8 +398,10 @@ |
|
|
|
if(questionBank.value.answer==item.key) { |
|
|
|
questionBank.value.yes = 1 |
|
|
|
currentIndex.value = currentIndex.value + 1 |
|
|
|
curOption.value = {} |
|
|
|
curOption.value = item |
|
|
|
setTimeout(()=>{ |
|
|
|
getQuestionFn() |
|
|
|
},500) |
|
|
|
}else { |
|
|
|
item.answer = item.key |
|
|
|
curOption.value = item |
|
|
@ -373,27 +418,62 @@ |
|
|
|
// console.log(curOption.value.ans) |
|
|
|
} |
|
|
|
} |
|
|
|
// 提交请求 |
|
|
|
async function submitAnswerResultFn() { |
|
|
|
let obj = { |
|
|
|
answer: curOption.value.answer, |
|
|
|
carType: 'car', |
|
|
|
questionId: questionBank.value.id, |
|
|
|
result: '0', |
|
|
|
stepType: 1, |
|
|
|
tempId: questionBank.value.questionDoTemp.id |
|
|
|
} |
|
|
|
const res = await submitAnswerResultApi(obj) |
|
|
|
if(res.errorcode!=0) return |
|
|
|
if(curOption.value.answer==questionBank.value.answer) { |
|
|
|
console.log('答对了') |
|
|
|
curOption.value = {} |
|
|
|
yesNum.value ++ |
|
|
|
nextQuestion(1) |
|
|
|
// 点击交卷 |
|
|
|
let remaining = ref(0) |
|
|
|
let countDownRef = ref(null) |
|
|
|
function handApaper() { |
|
|
|
let arr = questionBankList.value.filter(item=>item.yes==undefined) |
|
|
|
// 不及格或者有没有做完的题 |
|
|
|
if(arr.length || passScore.value*1>yesNum.value) { |
|
|
|
remaining.value = arr.length |
|
|
|
showCommit.value = true |
|
|
|
if (countDownRef.value) { |
|
|
|
countDownRef.value.pause(); |
|
|
|
} |
|
|
|
}else { |
|
|
|
noNum.value ++ |
|
|
|
submitBtnFn() |
|
|
|
} |
|
|
|
} |
|
|
|
// console.log(res) |
|
|
|
// 关闭交卷弹框 |
|
|
|
function closeCommitPopup() { |
|
|
|
showCommit.value = false |
|
|
|
if (countDownRef.value) { |
|
|
|
countDownRef.value.start(); |
|
|
|
} |
|
|
|
} |
|
|
|
// 交卷 |
|
|
|
async function submitBtnFn() { |
|
|
|
let wrongArr = questionBankList.value.filter(item=>item.yes!=1) |
|
|
|
let worngId = wrongArr.map(item=>item.id).join(',') |
|
|
|
let obj = { |
|
|
|
"answer": null, |
|
|
|
"carType": usecarStore.carInfo.carType, |
|
|
|
"examId": examInfo.value.id, |
|
|
|
"examType": 1, |
|
|
|
"grade": questionBankList.value.length - wrongArr.length, |
|
|
|
"isEnd": 1, |
|
|
|
"pass": 1, |
|
|
|
"sort": examInfo.value.sort, |
|
|
|
"stepType": usecarStore.carInfo.stepType, |
|
|
|
"userId": examInfo.value.userId, |
|
|
|
"wrongQuestionIds": worngId |
|
|
|
} |
|
|
|
const res = await startExamDo(obj) |
|
|
|
console.log(res) |
|
|
|
uni.$u.toast('已交卷') |
|
|
|
setTimeout(()=>{ |
|
|
|
uni.navigateBack() |
|
|
|
},1500) |
|
|
|
} |
|
|
|
function finishFn() { |
|
|
|
uni.$u.toast('考试时间已到,准备自动为您交卷') |
|
|
|
setTimeout(()=>{ |
|
|
|
submitBtnFn() |
|
|
|
},1500) |
|
|
|
} |
|
|
|
// 返回 |
|
|
|
function goBack() { |
|
|
|
uni.navigateBack() |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
@ -644,13 +724,91 @@ |
|
|
|
font-size: 32rpx; |
|
|
|
line-height: 100rpx; |
|
|
|
text-align: center; |
|
|
|
&.active { |
|
|
|
position: relative; |
|
|
|
text { |
|
|
|
width: 68rpx; |
|
|
|
height: 34rpx; |
|
|
|
background: #3776FF; |
|
|
|
border-radius: 17rpx; |
|
|
|
display: block; |
|
|
|
font-weight: 400; |
|
|
|
font-size: 24rpx; |
|
|
|
color: #FFFFFF; |
|
|
|
text-align: center; |
|
|
|
line-height: 34rpx; |
|
|
|
position: absolute; |
|
|
|
bottom: -14rpx; |
|
|
|
left: 16rpx; |
|
|
|
} |
|
|
|
&.yes { |
|
|
|
border: 1px solid #63C168; |
|
|
|
background: rgba(99,193,104,0.1); |
|
|
|
color: #63C168; |
|
|
|
} |
|
|
|
&.no { |
|
|
|
border: 1px solid #FF3333; |
|
|
|
background: rgba(255,51,51,0.1); |
|
|
|
color: #FF3333; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.commitCon { |
|
|
|
width: calc(100vw - 100rpx); |
|
|
|
padding: 30rpx; |
|
|
|
|
|
|
|
.tit { |
|
|
|
font-weight: 500; |
|
|
|
font-size: 36rpx; |
|
|
|
color: #333333; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
|
|
|
|
.flex { |
|
|
|
.commitItem { |
|
|
|
flex: 1; |
|
|
|
text-align: center; |
|
|
|
padding: 50rpx 0 40rpx 0; |
|
|
|
.lab { |
|
|
|
font-size: 28rpx; |
|
|
|
color: #CCCCCC; |
|
|
|
margin-top: 10rpx; |
|
|
|
} |
|
|
|
.num { |
|
|
|
font-weight: bold; |
|
|
|
font-size: 36rpx; |
|
|
|
color: #333333; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.imgAdd { |
|
|
|
width: 100%; |
|
|
|
img { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.btn_commit_row { |
|
|
|
padding-top: 40rpx; |
|
|
|
.border.btn { |
|
|
|
border: 1rpx solid #CCCCCC; |
|
|
|
color: #CCCCCC; |
|
|
|
background: none; |
|
|
|
} |
|
|
|
|
|
|
|
.btn { |
|
|
|
width: 46%; |
|
|
|
height: 77rpx; |
|
|
|
text-align: center; |
|
|
|
line-height: 77rpx; |
|
|
|
background: #3776FF; |
|
|
|
border-radius: 39rpx; |
|
|
|
font-size: 28rpx; |
|
|
|
color: #FFFFFF; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |