修改
This commit is contained in:
@@ -3,10 +3,12 @@
|
||||
<image src="../../../static/images/train/bj.jpg" class="bjImg" mode=""></image>
|
||||
<div class="con-box">
|
||||
<div class="header">
|
||||
<div>正确率:{{accuracyRate}}%</div>
|
||||
<div>用时:{{formattedTime}}</div>
|
||||
<div class="headBtn" v-if="isRunning" @click="pause">暂停</div>
|
||||
<div class="headBtn" v-if="!isRunning" @click="start">继续</div>
|
||||
<div style="font-weight: 600;font-size: 32rpx;">{{rows.name}}</div>
|
||||
<div class="headerCon">
|
||||
<div>考试时长:{{rows.timeLimit}}分钟</div>
|
||||
<div>{{formattedTime}}</div>
|
||||
<div class="headBtn" @click="exit()">退出</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="problemCard">
|
||||
<div v-for="(item,index) in problemData" :key="index">
|
||||
@@ -18,57 +20,29 @@
|
||||
<span>{{item.content}}</span>
|
||||
</div>
|
||||
<div class="options" v-if="item.type=='single'">
|
||||
<div class="opt" @click="selected(i)" :class="radio!==''&&i==radio?'active':''" v-for="(val,i) in parseOptions(item.trainChooses)">
|
||||
<div class="opt" @click="selected(i,index)" :class="item.choice!==''&&i==item.choice?'active':''" v-for="(val,i) in parseOptions(item.trainChooses)">
|
||||
<div class="optLab">{{indexToLetter(i)}}</div>
|
||||
<span>{{val}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="options" v-if="item.type=='multiple'">
|
||||
<div class="opt" @click="selected2(i)" :class="judgment(i)?'active':''" v-for="(val,i) in parseOptions(item.trainChooses)">
|
||||
<div class="opt" @click="selected2(i,index)" :class="judgment(i,index)?'active':''" v-for="(val,i) in parseOptions(item.trainChooses)">
|
||||
<div class="optLab">{{indexToLetter(i)}}</div>
|
||||
<span>{{val}}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="options" v-if="item.type=='judge'">
|
||||
<div class="opt" @click="selected3('正确')" :class="radio2=='正确'?'active':''">
|
||||
<div class="opt" @click="selected3('正确')" :class="item.choice=='正确'?'active':''">
|
||||
<span>正确</span>
|
||||
</div>
|
||||
<div class="opt" @click="selected3('错误')" :class="radio2=='错误'?'active':''">
|
||||
<div class="opt" @click="selected3('错误')" :class="item.choice=='错误'?'active':''">
|
||||
<span>错误</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="analysis" v-if="analysis">
|
||||
<div class="analysisHead correct" v-if="judgWhether=='正确'">
|
||||
<div>回答正确!</div>
|
||||
<div></div>
|
||||
</div>
|
||||
<div class="analysisHead errors" v-if="judgWhether=='错误'">
|
||||
<div>回答错误!</div>
|
||||
<div></div>
|
||||
</div>
|
||||
<div class="analysisCon">
|
||||
<div class="parse1">正确答案:</div>
|
||||
<div class="parse2" v-if="item.type=='single'" style="color: #30A0FF;font-weight: bold;">{{String.fromCharCode(65 + Number(item.answer))}}.</div>
|
||||
<div class="parse2" v-if="item.type=='multiple'" style="color: #30A0FF;font-weight: bold;">
|
||||
<span v-for="(val,i) in parseOptions(item.answer)">{{indexToLetter(val-1)}}.</span>
|
||||
</div>
|
||||
<div class="parse2" v-if="item.type=='judge'" style="color: #30A0FF;font-weight: bold;">{{item.answer}}</div>
|
||||
</div>
|
||||
<div class="analysisCon">
|
||||
<div class="parse1">答案解析:</div>
|
||||
<div class="parse2">{{item.answerDesc}}</div>
|
||||
</div>
|
||||
<div class="analysisCon">
|
||||
<div class="parse1">知识点:</div>
|
||||
<div>
|
||||
<el-tag style="margin-right: 10px;">{{item.knowledgePoint}}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="problemBtns">
|
||||
<div v-if="analysis&&judgWhether!=''&&questionIndex!=problemData.length" @click="questionIndex+=1">下一题</div>
|
||||
<div v-else :class="((radio===''&&radio2===''&&checkList.length==0&&isRunning)||analysis)?'events':''" @click="submit()">提交答案</div>
|
||||
<div :class="(problemData[questionIndex-1].type=='multiple'?problemData[questionIndex-1].choice.length==0:problemData[questionIndex-1].choice==='')?'events':''" @click="submit()">提交答案</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -77,25 +51,10 @@
|
||||
<div class="footerLeft">
|
||||
<div class="zuo" :class="questionIndex==1?'events':''" @click="questionIndex-=1"></div>
|
||||
<div class="you" :class="questionIndex==problemData.length?'events':''" @click="questionIndex+=1"></div>
|
||||
<div @click="collect(1)" style="text-align: center;font-size: 24rpx;" v-if="(problemData[questionIndex - 1]?.isCollect || 0)!=1">
|
||||
<image :src="urls+'wsc.png'" mode="" style="width: 34rpx;height: 32rpx;"></image>
|
||||
<div>收藏</div>
|
||||
</div>
|
||||
<div @click="collect(0)" style="text-align: center;font-size: 24rpx;" v-if="(problemData[questionIndex - 1]?.isCollect || 0)==1">
|
||||
<image :src="urls+'video-sc.png'" mode="" style="width: 34rpx;height: 32rpx;"></image>
|
||||
<div>取消</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="footerBtn" @click="exit()">完成练习</div>
|
||||
<div class="footerBtn" @click="complete()">完成练习</div>
|
||||
<div class="footerLeft">
|
||||
<div>
|
||||
<div class="icons" style="background-color: #1CADF5;">√</div>
|
||||
<div class="texts" style="color: #1CADF5;">{{correctIndex}}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="icons" style="background-color: #FF6668;">×</div>
|
||||
<div class="texts" style="color: #FF6668;">{{errorsIndex}}</div>
|
||||
</div>
|
||||
<div @click="dialogVisible=true">
|
||||
<div><span style="color: #1CADF5;">{{questionIndex}}</span>/{{problemData.length}}</div>
|
||||
<div>题号</div>
|
||||
@@ -124,6 +83,7 @@ const { $api,urls , navTo,navBack , vacanciesTo, formatTotal, config } = inject(
|
||||
import useUserStore from '@/stores/useUserStore';
|
||||
import useDictStore from '@/stores/useDictStore';
|
||||
const userInfo = ref({});
|
||||
const rows = ref({});
|
||||
const Authorization = ref('');
|
||||
const radio = ref('');
|
||||
const radio2 = ref('');
|
||||
@@ -131,9 +91,7 @@ const checkList = ref([]);
|
||||
const questionIndex = ref(1);
|
||||
const correctIndex = ref(0);
|
||||
const errorsIndex = ref(0);
|
||||
const accuracyRate = ref(0);
|
||||
const elapsedTime = ref(0);
|
||||
const analysis = ref(false);
|
||||
const judgWhether = ref('');
|
||||
const isRunning = ref(false);
|
||||
const dialogVisible = ref(false);
|
||||
@@ -149,7 +107,6 @@ watch(questionIndex, (newVal, oldVal) => {
|
||||
radio.value=""
|
||||
radio2.value=""
|
||||
checkList.value=[]
|
||||
analysis.value=false
|
||||
judgWhether.value=""
|
||||
});
|
||||
|
||||
@@ -161,6 +118,7 @@ watch(questionIndex, (newVal, oldVal) => {
|
||||
// });
|
||||
|
||||
onLoad((options) => {
|
||||
rows.value=options
|
||||
Authorization.value=uni.getStorageSync('Padmin-Token')||''
|
||||
getHeart();
|
||||
});
|
||||
@@ -201,16 +159,53 @@ function queryData(){
|
||||
'Authorization':Authorization.value,
|
||||
'Content-Type':"application/x-www-form-urlencoded"
|
||||
}
|
||||
$api.myRequest('/train/public/trainPractice/getQuestions', {
|
||||
userId: userInfo.value.userId
|
||||
},'post',9100,header).then((resData) => {
|
||||
resData.forEach((item,i)=>{
|
||||
problemData.value.push(item)
|
||||
problemList.value.push({index:i+1,whether:""})
|
||||
})
|
||||
start()
|
||||
accuracyRates()
|
||||
});
|
||||
if(rows.value.types==1){
|
||||
$api.myRequest('/train/public/trainExamDash/getExamTopicNoAnswer', {
|
||||
userId: userInfo.value.userId,
|
||||
examPaperId:rows.value.examPaperId
|
||||
},'post',9100,header).then((resData) => {
|
||||
elapsedTime.value=(rows.value.timeLimit*60)
|
||||
resData.forEach((item,i)=>{
|
||||
if(item.type=='multiple'){
|
||||
item.choice=[]
|
||||
}else{
|
||||
item.choice=""
|
||||
}
|
||||
problemData.value.push(item)
|
||||
problemList.value.push({index:i+1,whether:""})
|
||||
})
|
||||
start()
|
||||
});
|
||||
}else if(rows.value.types==2){
|
||||
$api.myRequest('/train/public/trainExamDash/continueExam', {
|
||||
userId: userInfo.value.userId,
|
||||
examPaperId:rows.value.examPaperId
|
||||
},'post',9100,header).then((resData) => {
|
||||
if(resData&&resData.code==200){
|
||||
elapsedTime.value=(rows.value.timeLimit*60)
|
||||
resData.data.forEach((item,i)=>{
|
||||
if(item.type=='multiple'){
|
||||
if(item.choosed){
|
||||
item.choice=item.choosed.split(",");
|
||||
item.submitAnswers=true
|
||||
}else{
|
||||
item.choice=[]
|
||||
}
|
||||
}else{
|
||||
if(item.choosed){
|
||||
item.choice=item.choosed;
|
||||
item.submitAnswers=true
|
||||
}else{
|
||||
item.choice=""
|
||||
}
|
||||
}
|
||||
problemData.value.push(item)
|
||||
problemList.value.push({index:i+1,whether:""})
|
||||
})
|
||||
start()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function collect(is){
|
||||
let header={
|
||||
@@ -225,76 +220,114 @@ function collect(is){
|
||||
problemData.value[questionIndex.value-1].isCollect=is
|
||||
});
|
||||
};
|
||||
//正确率
|
||||
function accuracyRates(){
|
||||
let header={
|
||||
'Authorization':Authorization.value,
|
||||
'Content-Type':"application/x-www-form-urlencoded"
|
||||
}
|
||||
$api.myRequest('/train/public/trainPractice/getCount', {
|
||||
userId: userInfo.value.userId,
|
||||
},'post',9100,header).then((resData) => {
|
||||
accuracyRate.value=resData.truePresent
|
||||
});
|
||||
};
|
||||
|
||||
//提交答案
|
||||
function submit(){
|
||||
let indexs=questionIndex.value-1
|
||||
let parm={
|
||||
examPaperId:rows.value.examPaperId,
|
||||
questionId:problemData.value[indexs].questionId,
|
||||
userId:userInfo.value.userId,
|
||||
answer:problemData.value[indexs].answer
|
||||
}
|
||||
if(problemData.value[indexs].type=='single'){
|
||||
parm.submitAnswer=radio.value
|
||||
}else if(problemData.value[indexs].type=='multiple'){
|
||||
parm.submitAnswer=checkList.value.join(',')
|
||||
}else if(problemData.value[indexs].type=='judge'){
|
||||
parm.submitAnswer=radio2.value
|
||||
answer:problemData.value[indexs].type=='multiple'?problemData.value[indexs].choice.join(","):problemData.value[indexs].choice,
|
||||
examId:problemData.value[indexs].examId
|
||||
}
|
||||
let header={
|
||||
'Authorization':Authorization.value,
|
||||
'Content-Type':"application/json"
|
||||
}
|
||||
$api.myRequest('/train/public/trainPractice/submitAnswer', parm,'post',9100,header).then((resData) => {
|
||||
$api.myRequest('/train/public/trainExamDash/submitAnswer', parm,'post',9100,header).then((resData) => {
|
||||
if(resData&&resData.code==200){
|
||||
analysis.value=true
|
||||
judgWhether.value=resData.msg
|
||||
problemList.value[indexs].whether=resData.msg
|
||||
if(resData.msg=='正确'){
|
||||
correctIndex.value++
|
||||
}else if(resData.msg=='错误'){
|
||||
errorsIndex.value++
|
||||
problemData.value[indexs].submitAnswers=true
|
||||
if(problemData.value.length==questionIndex.value){
|
||||
$api.msg('已经是最后一题了', '请仔细检查后交卷')
|
||||
|
||||
}else{
|
||||
questionIndex.value+=1
|
||||
}
|
||||
accuracyRates()
|
||||
}
|
||||
});
|
||||
};
|
||||
function selected(i){
|
||||
radio.value=i
|
||||
//完成练习
|
||||
function complete(){
|
||||
let arr=[]
|
||||
problemData.value.forEach((item,index)=>{
|
||||
if(!item.submitAnswers){
|
||||
arr.push(index+1)
|
||||
}
|
||||
})
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: (arr.length>0?'第'+arr.join(",")+'题还未作答,':'请仔细检查试卷 ,')+'确认是否交卷?',
|
||||
success (res) {
|
||||
if (res.confirm) {
|
||||
onpaper()
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
this.$confirm((arr.length>0?'第'+arr.join(",")+'题还未作答,':'请仔细检查试卷 ,')+'确认是否交卷?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
onpaper()
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消'
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
function onpaper(){
|
||||
let indexs=questionIndex.value-1
|
||||
let parm={
|
||||
examPaperId:rows.value.examPaperId,
|
||||
userId:userInfo.value.userId,
|
||||
examId:problemData.value[indexs].examId,
|
||||
useTime:(rows.value.timeLimit*60) - elapsedTime.value,
|
||||
}
|
||||
let header={
|
||||
'Authorization':Authorization.value,
|
||||
'Content-Type':"application/json"
|
||||
}
|
||||
$api.myRequest('/train/public/trainExamDash/submitExam', parm,'post',9100,header).then((resData) => {
|
||||
if(resData&&resData.code==200){
|
||||
$api.msg('提交成功!')
|
||||
navBack()
|
||||
}
|
||||
});
|
||||
};
|
||||
function selected(i,index){
|
||||
problemData.value[index].choice=i
|
||||
problemData.value=JSON.parse(JSON.stringify(problemData.value))
|
||||
};
|
||||
//多选
|
||||
function selected2(i){
|
||||
let arr=checkList.value.join(",")
|
||||
function selected2(i,indexs){
|
||||
let arr=problemData.value[indexs].choice.join(",")
|
||||
if(arr.indexOf(i) !== -1){
|
||||
const index = checkList.value.indexOf(i);
|
||||
const index = problemData.value[indexs].choice.indexOf(i);
|
||||
if (index !== -1) {
|
||||
checkList.value.splice(index, 1);
|
||||
problemData.value[indexs].choice.splice(index, 1);
|
||||
}
|
||||
}else{
|
||||
checkList.value.push(i)
|
||||
problemData.value[indexs].choice.push(i)
|
||||
}
|
||||
problemData.value=JSON.parse(JSON.stringify(problemData.value))
|
||||
};
|
||||
function judgment(i){
|
||||
let arr=checkList.value.join(",")
|
||||
function judgment(i,indexs){
|
||||
let arr=problemData.value[indexs].choice.join(",")
|
||||
if(arr.indexOf(i) !== -1){
|
||||
return true
|
||||
}else{
|
||||
return false
|
||||
}
|
||||
};
|
||||
function selected3(i){
|
||||
radio2.value=i
|
||||
function selected3(i,index){
|
||||
// radio2.value=i
|
||||
problemData.value[index].choice=i
|
||||
problemData.value=JSON.parse(JSON.stringify(problemData.value))
|
||||
};
|
||||
// 解析选项
|
||||
function parseOptions(options) {
|
||||
@@ -320,14 +353,16 @@ function start() {
|
||||
if (isRunning.value) return
|
||||
isRunning.value = true
|
||||
timer = setInterval(() => {
|
||||
elapsedTime.value++
|
||||
elapsedTime.value-=1
|
||||
if(elapsedTime.value==0){
|
||||
// this.$message({
|
||||
// message: '考试时间已结束,系统将自动交卷',
|
||||
// type: 'warning'
|
||||
// });
|
||||
onpaper()
|
||||
}
|
||||
}, 1000)
|
||||
};
|
||||
function pause() {
|
||||
if (!isRunning.value) return
|
||||
clearInterval(timer)
|
||||
isRunning.value = false
|
||||
};
|
||||
function clones(){
|
||||
dialogVisible.value=false
|
||||
};
|
||||
@@ -360,23 +395,26 @@ function exit(){
|
||||
padding: 20rpx 28rpx;
|
||||
box-sizing: border-box;
|
||||
.header{
|
||||
height: 100rpx;
|
||||
padding: 0 10rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 110rpx;
|
||||
padding: 10rpx 10rpx 0;
|
||||
background: linear-gradient(0deg, #4285EC 0%, #0BBAFB 100%);
|
||||
color: #fff;
|
||||
font-size: 26rpx;
|
||||
border-radius: 10rpx
|
||||
.headBtn{
|
||||
background: #499FFF;
|
||||
border-radius: 4px;
|
||||
width: 100rpx;
|
||||
text-align: center;
|
||||
height: 50rpx;
|
||||
line-height: 50rpx;
|
||||
.headerCon{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
.headBtn{
|
||||
background: #499FFF;
|
||||
border-radius: 4px;
|
||||
width: 100rpx;
|
||||
text-align: center;
|
||||
height: 50rpx;
|
||||
line-height: 50rpx;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.problemCard{
|
||||
margin-top: 30rpx;
|
||||
|
||||
Reference in New Issue
Block a user