mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-06 17:36:45 +08:00
提交修改
This commit is contained in:
@@ -13,13 +13,13 @@
|
||||
<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.answer && curItem.userAnswer}">
|
||||
<view class="qitem-opt" :class="{check:curItem.userAnswer==true}">
|
||||
{{toLetter(1)}}.正确
|
||||
<u-icon v-if="curItem.answer && curItem.userAnswer" 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.answer && !curItem.userAnswer}">
|
||||
<view class="qitem-opt" :class="{check:curItem.userAnswer==false}">
|
||||
{{toLetter(2)}}.错误
|
||||
<u-icon v-if="!curItem.answer && !curItem.userAnswer" name="checkbox-mark" color="#00aa00"></u-icon>
|
||||
<u-icon v-if="curItem.userAnswer==false" name="checkbox-mark" color="#00aa00"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
let $this=this;
|
||||
let item=this.curItem;
|
||||
//console.log(this.curItem,'curItem');
|
||||
console.log(this.curItem,'curItem');
|
||||
if(item.type!=3){
|
||||
item.optionList.forEach((opt,idx)=>{
|
||||
//填充正确答案,判断题不用处理
|
||||
@@ -162,8 +162,10 @@
|
||||
$this.userOptIdxs.push(idx);
|
||||
}
|
||||
}else if(item.type==2){ //多选
|
||||
if(item.userAnswer.indexOf(opt.id)>-1){
|
||||
$this.userOptIdxs.push(idx);
|
||||
if(item.userAnswer){
|
||||
if(item.userAnswer.indexOf(opt.id)>-1){
|
||||
$this.userOptIdxs.push(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</view>
|
||||
<view v-if="examStatus==2" style="text-align: center;color:#6d6d6d; ">考试已结束</view>
|
||||
</view>
|
||||
<view class="" style="padding: 20upx;" v-if="canExam">
|
||||
<view class="" style="padding: 20upx;" v-if="canExam && tableData.length>0">
|
||||
<view class="" style="margin-bottom: 20upx;">
|
||||
考试记录:
|
||||
</view>
|
||||
@@ -70,10 +70,10 @@
|
||||
{{toLetter(1)}}.正确
|
||||
<u-icon v-if="curItem.userAnswer == true" name="checkbox-mark" color="#00aa00"></u-icon>
|
||||
</view>
|
||||
<view class="qitem-opt" :class="{check:String(curItem.userAnswer) != '' && !curItem.userAnswer}"
|
||||
<view class="qitem-opt" :class="{check:curItem.userAnswer==false}"
|
||||
@click="chooseOption(curItem,false)">
|
||||
{{toLetter(2)}}.错误
|
||||
<u-icon v-if="String(curItem.userAnswer) != '' && !curItem.userAnswer" name="checkbox-mark" color="#00aa00"></u-icon>
|
||||
<u-icon v-if="curItem.userAnswer==false" name="checkbox-mark" color="#00aa00"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -85,9 +85,9 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="qitem-opts" v-if="curItem.type == 2">
|
||||
<view class="qitem-opt" :class="{check:curItem.userAnswer.indexOf(opt.id) > -1}" @click="chooseOption(opt)">
|
||||
<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.indexOf(opt.id) > -1" name="checkbox-mark" color="#00aa00"></u-icon>
|
||||
<u-icon v-if="curItem.userAnswer && curItem.userAnswer.indexOf(opt.id) > -1" name="checkbox-mark" color="#00aa00"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -245,27 +245,6 @@
|
||||
formatSeconds(time) {
|
||||
return formatSeconds(time);
|
||||
},
|
||||
chooseOption(opt, is) {
|
||||
if (this.curItem.type == 1) {
|
||||
this.curItem.userAnswer=opt.id;
|
||||
} else if (this.curItem.type == 2) {
|
||||
|
||||
if (this.curItem.userAnswer.indexOf(opt.id) > -1) {
|
||||
//需要移除
|
||||
this.curItem.userAnswer.forEach((item, index) => {
|
||||
if (item === opt.id) {
|
||||
this.curItem.userAnswer.splice(index, 1)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.curItem.userAnswer.push(opt.id);
|
||||
}
|
||||
} else if (this.curItem.type == 3) {
|
||||
this.curItem.userAnswer=is;
|
||||
//opt.checked = is;
|
||||
//this.curItem.userAnswer = String(is);
|
||||
}
|
||||
},
|
||||
startTest() {
|
||||
this.curTestAnswer = {};
|
||||
this.curIndex=0;
|
||||
@@ -309,7 +288,11 @@
|
||||
this.total=this.paper.length;//计算试题总数
|
||||
this.arrangeQuestion();
|
||||
this.curItem = this.paper[this.curIndex];
|
||||
//console.log(this.paper,'this.paper');
|
||||
|
||||
if(this.curItem.type==3){
|
||||
this.curItem.answer=this.curItem.answer=='true'? true:false;
|
||||
}
|
||||
console.log(this.curItem,'this.curItem 1');
|
||||
//进入考试阶段
|
||||
this.testStatus = 2;
|
||||
this.startReckon();
|
||||
@@ -455,13 +438,16 @@
|
||||
item.userAnswer.sort(function(n1, n2) {
|
||||
return n1 > n2 ? -1 : 1;
|
||||
});
|
||||
|
||||
//console.log()
|
||||
let str1 = item.userAnswer.join();
|
||||
let str2 = tempAnswer.join();
|
||||
//console.log(str1,str2,'aaa');
|
||||
if (str1 == str2) {
|
||||
total += item.defaultScore;
|
||||
}
|
||||
}
|
||||
let str1 = item.userAnswer.join();
|
||||
let str2 = tempAnswer.join();
|
||||
//console.log(str1,str2,'aaa');
|
||||
if (str1 == str2) {
|
||||
total += item.defaultScore;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
return total;
|
||||
@@ -576,6 +562,40 @@
|
||||
stopReckon: function() {
|
||||
window.clearInterval(this.reckonTimeer)
|
||||
},
|
||||
chooseOption(opt, is) {
|
||||
let curQuestion=this.curItem;
|
||||
//console.log(curQuestion,'选择前');
|
||||
//curQuestion.userAnswer='';
|
||||
if (curQuestion.type == 1) {
|
||||
curQuestion.userAnswer=opt.id;
|
||||
} else if (curQuestion.type == 2) {
|
||||
if (!curQuestion.userAnswer){
|
||||
curQuestion.userAnswer=[];
|
||||
}
|
||||
//如果存在就删除,如果不存在就添加
|
||||
let hasIndex=-1;
|
||||
curQuestion.userAnswer.some((item, index) => {
|
||||
if (item == opt.id) {
|
||||
hasIndex=index;
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
})
|
||||
if(hasIndex>-1){
|
||||
curQuestion.userAnswer.splice(hasIndex,1);
|
||||
}else{
|
||||
curQuestion.userAnswer.push(opt.id);
|
||||
}
|
||||
|
||||
} else if (curQuestion.type == 3) {
|
||||
curQuestion.userAnswer=is;
|
||||
//opt.checked = is;
|
||||
//this.curItem.userAnswer = String(is);
|
||||
}
|
||||
//console.timeEnd(opt.id);
|
||||
//console.log(this.curItem,'选择后');
|
||||
},
|
||||
prevSub() {
|
||||
if (this.curIndex == 0) {
|
||||
return;
|
||||
@@ -586,13 +606,35 @@
|
||||
}
|
||||
},
|
||||
nextSub() {
|
||||
//console.log(this.curItem,'this.curItem');
|
||||
|
||||
if (this.curIndex >= (this.total - 1)) {
|
||||
return;
|
||||
}
|
||||
this.curIndex++;
|
||||
this.curItem = this.paper[this.curIndex];
|
||||
//console.log(this.curItem,'curItem');
|
||||
this.updateAnswer();
|
||||
|
||||
if(this.curItem.userAnswer=='undefined' || this.curItem.userAnswer==''){
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.curItem.type==3){
|
||||
//console.log(this.curItem.userAnswer,'判断题的值');
|
||||
if(this.curItem.userAnswer==true || this.curItem.userAnswer==false){
|
||||
this.curIndex++;
|
||||
this.curItem = this.paper[this.curIndex];
|
||||
//console.log(this.curItem,'切换后2');
|
||||
this.updateAnswer();
|
||||
}
|
||||
}else{
|
||||
//检查当前的是否已选答案
|
||||
if(this.curItem.userAnswer){
|
||||
this.curIndex++;
|
||||
this.curItem = this.paper[this.curIndex];
|
||||
//console.log(this.curItem,'切换后2');
|
||||
this.updateAnswer();
|
||||
}
|
||||
}
|
||||
//console.log(this.curItem,'this.curItem');
|
||||
|
||||
},
|
||||
// 人工提交
|
||||
manualSubmit() {
|
||||
|
||||
Reference in New Issue
Block a user