提交修改考试部分

This commit is contained in:
daihh
2022-08-07 18:33:51 +08:00
parent fca6d2c3bd
commit 223334ca89

View File

@@ -65,29 +65,31 @@
<view class="qitem-info">[{{getQuestionType(curItem.type)}}]{{curItem.title}}</view>
<view v-if="curItem.type == 3">
<view class="qitem-opts">
<view class="qitem-opt" :class="{check:curItem.userAnswer == true}"
<view class="qitem-opt" :class="{check:curItem.userAnswer == 'true'}"
@click="chooseOption(curItem,true)">
{{toLetter(1)}}.正确
<u-icon v-if="curItem.userAnswer == true" name="checkbox-mark" color="#00aa00"></u-icon>
<u-icon v-if="curItem.userAnswer == 'true'" name="checkbox-mark" color="#00aa00"></u-icon>
</view>
<view class="qitem-opt" :class="{check:curItem.userAnswer==false}"
<view class="qitem-opt" :class="{check:curItem.userAnswer=='false'}"
@click="chooseOption(curItem,false)">
{{toLetter(2)}}.错误
<u-icon v-if="curItem.userAnswer==false" name="checkbox-mark" color="#00aa00"></u-icon>
<u-icon v-if="curItem.userAnswer=='false'" name="checkbox-mark" color="#00aa00"></u-icon>
</view>
</view>
</view>
<view v-else v-for="(opt,optIdx) in curItem.optionList" :key="optIdx">
<view class="qitem-opts" v-if="curItem.type == 1">
<view class="qitem-opt" :class="{check:opt.id==curItem.userAnswer}" @click="chooseOption(opt)">
{{toLetter(optIdx+1)}}.{{opt.content}}
<u-icon v-if="opt.id==curItem.userAnswer" name="checkbox-mark" color="#00aa00"></u-icon>
<view v-else>
<view v-for="(opt,optIdx) in curItem.optionList" :key="opt.id">
<view class="qitem-opts" v-if="curItem.type == 1">
<view class="qitem-opt" :class="{check:opt.id==curItem.userAnswer}" @click="chooseOption(opt)">
{{toLetter(optIdx+1)}}.{{opt.content}}
<u-icon v-if="opt.id==curItem.userAnswer" name="checkbox-mark" color="#00aa00"></u-icon>
</view>
</view>
</view>
<view class="qitem-opts" v-if="curItem.type == 2">
<view class="qitem-opt" :class="{check:(curItem.userAnswer && curItem.userAnswer.indexOf(opt.id) > -1)}" @click="chooseOption(opt)">
{{toLetter(optIdx+1)}}.{{opt.content}}
<u-icon v-if="curItem.userAnswer && curItem.userAnswer.indexOf(opt.id) > -1" name="checkbox-mark" color="#00aa00"></u-icon>
<view class="qitem-opts" v-if="curItem.type == 2">
<view class="qitem-opt" :class="{check:(curItem.userAnswer && curItem.userAnswer.indexOf(opt.id) > -1)}" @click="chooseOption(opt)">
{{toLetter(optIdx+1)}}.{{opt.content}}
<u-icon v-if="curItem.userAnswer && curItem.userAnswer.indexOf(opt.id) > -1" name="checkbox-mark" color="#00aa00"></u-icon>
</view>
</view>
</view>
</view>
@@ -289,9 +291,9 @@
this.arrangeQuestion();
this.curItem = this.paper[this.curIndex];
if(this.curItem.type==3){
this.curItem.answer=this.curItem.answer=='true'? true:false;
}
//if(this.curItem.type==3){
//this.curItem.answer=this.curItem.answer=='true'? true:false;
//}
console.log(this.curItem,'this.curItem 1');
//进入考试阶段
this.testStatus = 2;
@@ -332,7 +334,7 @@
let avalue=answerJson[qitem.id];
//console.log(avalue,'avalue')
if(qitem.type==3){
qitem.answer=qitem.answer=='true'? true:false;
//qitem.answer=qitem.answer=='true'? true:false;
}
if(avalue){
if(qitem.type==1){ //单选
@@ -341,7 +343,8 @@
}else if(qitem.type==2){ //多选
qitem.userAnswer=avalue.split(',');
}else if(qitem.type==3){ //判断
qitem.userAnswer=avalue=='true'? true:false;
//qitem.userAnswer=avalue=='true'? true:false;
qitem.userAnswer=avalue;
}
}
paperQuestions.push(qitem);
@@ -408,23 +411,20 @@
countScore() {
let total = 0;
this.paper.forEach(item => {
if (item.type == 3) {
//console.log(item,item.answer,item.userAnswer,'item');
if (item.answer && item.userAnswer) {
if (item.answer=='true' && item.userAnswer=='true') {
total += item.defaultScore;
}else if(!item.answer && !item.userAnswer){
}else if(item.answer=='false' && item.userAnswer=='false'){
total+=item.defaultScore;
}
}
if (item.type == 1) {
}else if (item.type == 1) {
item.optionList.forEach(opt => {
if (opt.id == item.userAnswer && opt.isAnswer) {
total += item.defaultScore;
}
})
}
if (item.type == 2) {
}else if (item.type == 2) {
let tempAnswer = [];
item.optionList.forEach(opt => {
if (opt.isAnswer) {
@@ -589,12 +589,14 @@
}
} else if (curQuestion.type == 3) {
curQuestion.userAnswer=is;
curQuestion.userAnswer=is? 'true':'false';
//opt.checked = is;
//this.curItem.userAnswer = String(is);
}
//console.timeEnd(opt.id);
//console.log(this.curItem,'选择后');
this.$forceUpdate();
//console.timeEnd(opt.id);
},
prevSub() {
if (this.curIndex == 0) {
@@ -618,7 +620,7 @@
if(this.curItem.type==3){
//console.log(this.curItem.userAnswer,'判断题的值');
if(this.curItem.userAnswer==true || this.curItem.userAnswer==false){
if(this.curItem.userAnswer=='true' || this.curItem.userAnswer=='false'){
this.curIndex++;
this.curItem = this.paper[this.curIndex];
//console.log(this.curItem,'切换后2');