解决只有一道试题时,不能提交的问题

This commit is contained in:
daihh
2022-11-17 16:38:31 +08:00
parent a655175966
commit 8fce46fc10

View File

@@ -249,6 +249,7 @@
},
startTest() {
this.curTestAnswer = {};
this.aloneExamAnswerId='';
this.curIndex=0;
// 先禁用,防止重复提交
if (this.testPaper.entranceTime && this.testPaper.entranceTime !== '') {
@@ -299,9 +300,9 @@
this.testStatus = 2;
this.startReckon();
//60秒后执行保存处理,这里和pc端不一致不做延迟直接保存考试信息
// window.setTimeout(function() {
$this.saveUserTest();
// }, 10000);
//window.setTimeout(function() {
//$this.saveUserTest();
//}, 10000);
} else {
this.startButton = false;
uni.showLoading({
@@ -314,6 +315,7 @@
reStartTest(item){
//直接提取
this.curTestAnswer = {};
this.aloneExamAnswerId='';
this.curIndex=0;
apiTestPaper.getAnswerDetail(item.id).then(res => {
if (res.status === 200) {
@@ -368,6 +370,20 @@
}
})
},
clearPagerJson(){
let paperJson = [];
this.paper.forEach((item,index) => {
let option = {
id:item.id,
optionList:[]
};
item.optionList.forEach(it=>{
option.optionList.push({id:it.id})
})
paperJson.push(option);
})
return JSON.stringify(paperJson);
},
saveUserTest() { //保存用户的考试在点击开始考试1分钟后执行
if (this.handleSaveTest != null) {
window.clearTimeout(this.handleSaveTest);
@@ -385,7 +401,7 @@
data.arrange = this.testPaper.arrange;
data.passLine = this.testPaper.passLine;
data.ucode = this.userInfo.userNo;
data.paperJson = JSON.stringify(this.paper);
data.paperJson = this.clearPagerJson();
data.answerJson = this.getAnswer();
//计算总分
let total = 0;
@@ -419,11 +435,13 @@
total+=item.defaultScore;
}
}else if (item.type == 1) {
//console.log(item,item.defaultScore,'item.defaultScore')
item.optionList.forEach(opt => {
if (opt.id == item.userAnswer && opt.isAnswer) {
total += item.defaultScore;
}
})
//console.log(total,'total')
}else if (item.type == 2) {
let tempAnswer = [];
item.optionList.forEach(opt => {
@@ -470,9 +488,19 @@
data.arrange = this.testPaper.arrange;
data.passLine = this.testPaper.passLine;
data.scoreType=this.testPaper.scoringType;
data.totalScore=this.curTestAnswer.totalScore;
data.ucode = this.userInfo.userNo;
//计算总分
let total = 0;
this.paper.forEach(item => {
total += item.defaultScore;
});
data.totalScore=total;
data.answerJson = this.getAnswer();
data.realScore=this.countScore();
if(!this.aloneExamAnswerId){
data.paperJson = this.clearPagerJson();
}
data.useSecond=this.testPaper.testDuration*60-this.remainingTime;
//计算百分制显示
data.score=data.realScore*100/data.totalScore;
@@ -611,7 +639,6 @@
},
nextSub() {
//console.log(this.curItem,'this.curItem');
if (this.curIndex >= (this.total - 1)) {
return;
}