考试
This commit is contained in:
@@ -12,15 +12,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<div >
|
<div >
|
||||||
<!-- 题目 -->
|
<!-- 题目 -->
|
||||||
<div>{{ item.title }}</div>
|
<div>{{ item.title }}{{score}}</div>
|
||||||
<!-- 单选 -->
|
<!-- 单选,判断 -->
|
||||||
<!-- <div class="answer_list" v-if="item.type==0">
|
|
||||||
<div class="answer_item" v-for="(opt,inx) in item.items" :key="inx"
|
|
||||||
:class="{'Checked': clickIndex == inx}">
|
|
||||||
{{ opt.sort }}: {{ opt.content}}
|
|
||||||
</div>
|
|
||||||
</div> -->
|
|
||||||
<!-- 判断 -->
|
|
||||||
<div class="answer_list" v-if="item.type==0 || item.type==2">
|
<div class="answer_list" v-if="item.type==0 || item.type==2">
|
||||||
<div class="answer_item" v-for="(opt,inx) in item.items" :key="inx"
|
<div class="answer_item" v-for="(opt,inx) in item.items" :key="inx"
|
||||||
:class="{'Checked': clickIndex === inx, 'Succeed': showAnalysis && opt.checked == 1, 'Error': showAnalysis && clickIndex === inx && opt.checked == 0}"
|
:class="{'Checked': clickIndex === inx, 'Succeed': showAnalysis && opt.checked == 1, 'Error': showAnalysis && clickIndex === inx && opt.checked == 0}"
|
||||||
@@ -31,9 +24,9 @@
|
|||||||
<!-- 多选 -->
|
<!-- 多选 -->
|
||||||
<div class="answer_list" v-if="item.type==1">
|
<div class="answer_list" v-if="item.type==1">
|
||||||
<div class="answer_item" v-for="(opt,inx) in item.items" :key="inx"
|
<div class="answer_item" v-for="(opt,inx) in item.items" :key="inx"
|
||||||
:class="{'Checked': item.isCheked,'Succeed': showAnalysis && opt.checked == 1, 'Error': showAnalysis && item.isCheked && opt.checked == 0}"
|
:class="{'Checked': opt.isChecked,'Succeed': showAnalysis && opt.checked == 1, 'Error': showAnalysis && opt.isChecked && opt.checked == 0}"
|
||||||
@click="itemClick(inx)">
|
@click="itemClick(inx)">
|
||||||
{{ opt.sort }}: {{ opt.content}}
|
{{ opt.sort }}: {{ opt.content}} {{opt.isChecked}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -52,11 +45,15 @@
|
|||||||
|
|
||||||
<div class="btn" @click="nextTopic" v-if="activeIndex < list.length - 1 && showNext">下一题</div>
|
<div class="btn" @click="nextTopic" v-if="activeIndex < list.length - 1 && showNext">下一题</div>
|
||||||
<div class="btn" v-show="showConfirm" @click="confirm">确定</div>
|
<div class="btn" v-show="showConfirm" @click="confirm">确定</div>
|
||||||
|
<div class="btn" v-show="showTiJiao" @click="submit">提交</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import dayjs from "dayjs"
|
||||||
export default {
|
export default {
|
||||||
customNavigation: true,
|
customNavigation: true,
|
||||||
data() {
|
data() {
|
||||||
@@ -67,65 +64,120 @@ export default {
|
|||||||
},
|
},
|
||||||
list: [],
|
list: [],
|
||||||
activeIndex: 0, // 当前第几题
|
activeIndex: 0, // 当前第几题
|
||||||
|
activeAnswer:undefined,
|
||||||
endTime: '', // 结束时间
|
endTime: '', // 结束时间
|
||||||
id: '', // 题库id
|
id: '', // 题库id
|
||||||
showConfirm: false,
|
showConfirm: false,
|
||||||
showNext: false,
|
showNext: false,
|
||||||
|
showTiJiao: false,
|
||||||
clickIndex: '',
|
clickIndex: '',
|
||||||
showAnalysis: false,
|
showAnalysis: false,
|
||||||
subjectConfigs: [],
|
subjectConfigs: [],
|
||||||
|
score: 0,
|
||||||
|
assessments: [], // 不合格的分数段
|
||||||
|
status: 1, // 考试结果,0:未通过、1:通过
|
||||||
|
startTime: '',
|
||||||
|
nowTime: '', // 时间戳
|
||||||
|
studyDuration: 0,
|
||||||
|
assessmentType: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getList(id) {
|
getList(id) {
|
||||||
this.$instance.post(`/app/appexaminationinfo/queryDetailById?id=${id}`).then(res=> {
|
this.$instance.post(`/app/appexaminationinfo/queryDetailById?id=${id}`).then(res=> {
|
||||||
if(res?.data) {
|
if(res?.data) {
|
||||||
this.list = res.data.questions
|
res.data.questions.forEach(item => {
|
||||||
|
item.items.forEach(item1 =>{
|
||||||
|
item1.isChecked = false
|
||||||
|
})
|
||||||
|
});
|
||||||
|
this.list = res.data.questions
|
||||||
this.subjectConfigs = res.data.subjectConfigs
|
this.subjectConfigs = res.data.subjectConfigs
|
||||||
|
this.assessments = res.data.assessments
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
itemClick(i) {
|
itemClick(i) {
|
||||||
if (this.showAnalysis) return
|
if (this.showAnalysis) return
|
||||||
|
this.showConfirm = true
|
||||||
if(this.list[this.activeIndex].type==0) { // 单选
|
if(this.list[this.activeIndex].type==0 || this.list[this.activeIndex].type==2){ // 单选判断
|
||||||
|
this.clickIndex = i
|
||||||
} else if(this.list[this.activeIndex].type==1) { // 多选
|
}
|
||||||
this.list[this.activeIndex].items[i].isCheked = !this.list[this.index].items[i].isCheked
|
if(this.list[this.activeIndex].type==1) { // 多选
|
||||||
this.list[this.activeIndex].items.map((item) => {
|
this.list[this.activeIndex].items[i].isChecked=!this.list[this.activeIndex].items[i].isChecked
|
||||||
if (item.isCheked) {
|
|
||||||
// this.showTopBtn = true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
} else if(this.list[this.activeIndex].type==2) { // 判断
|
|
||||||
this.clickIndex = i
|
|
||||||
this.showConfirm = true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 下一题
|
// 下一题
|
||||||
nextTopic() {
|
nextTopic() {
|
||||||
|
|
||||||
this.activeIndex ++;
|
this.activeIndex ++;
|
||||||
this.clickIndex = ''
|
this.clickIndex = ''
|
||||||
this.showAnalysis = false
|
this.showAnalysis = false
|
||||||
},
|
},
|
||||||
// 确定
|
// 确定
|
||||||
confirm() {
|
confirm() {
|
||||||
|
|
||||||
this.showAnalysis = true;
|
this.showAnalysis = true;
|
||||||
|
// 单选判断
|
||||||
|
if(this.list[this.activeIndex].type==0 || this.list[this.activeIndex].type==2){
|
||||||
|
if(this.list[this.activeIndex].items[this.clickIndex].checked==1) {
|
||||||
|
this.score=this.score + this.subjectConfigs[this.list[this.activeIndex].type].eachScore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(this.list[this.activeIndex].type==1) { // 多选
|
||||||
|
if(this.list[this.activeIndex].items.every(item=>item.checked===item.isChecked)){
|
||||||
|
this.score=this.score + this.subjectConfigs[this.list[this.activeIndex].type].eachScore
|
||||||
|
}
|
||||||
|
}
|
||||||
if(this.activeIndex < this.list.length - 1) {
|
if(this.activeIndex < this.list.length - 1) {
|
||||||
this.showNext = true;
|
this.showNext = true;
|
||||||
this.showConfirm = false;
|
this.showConfirm = false;
|
||||||
} else {
|
} else {
|
||||||
uni.navigateTo({url: './result'})
|
this.showTiJiao = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 提交
|
||||||
|
submit() {
|
||||||
|
// 分数段
|
||||||
|
// switch(this.assessments) {
|
||||||
|
// case 1: console.log(1);
|
||||||
|
// break;
|
||||||
|
// case 2:
|
||||||
|
// }
|
||||||
|
// 用时
|
||||||
|
const endTime = new Date().getTime()
|
||||||
|
this.studyDuration = Math.ceil((endTime - this.nowTime) / 1000 / 60)
|
||||||
|
// 是否合格
|
||||||
|
const buhege = this.assessments.filter(e=> e.assessmentType == 3)
|
||||||
|
if(buhege.upCondition == 3) { // 3:小于等于、4:小于
|
||||||
|
if(this.score <= buhege.upScore) {
|
||||||
|
this.status = 0
|
||||||
|
}
|
||||||
|
} else if(buhege.upCondition == 4) {
|
||||||
|
if(this.score < buhege.upScore) {
|
||||||
|
this.status = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// this.$instance.post(`/app/appexaminationinfo/commit`,{
|
||||||
|
// assessmentType: this.assessmentType,
|
||||||
|
// examinationId: this.id,
|
||||||
|
// startTime: this.startTime,
|
||||||
|
// status: this.status,
|
||||||
|
// studyDuration: this.studyDuration,
|
||||||
|
// }).then(res=> {
|
||||||
|
// if(res?.code == 0) {
|
||||||
|
// uni.navigateTo({url: './result'})
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
},
|
||||||
},
|
},
|
||||||
onReachBottom() {
|
onReachBottom() {
|
||||||
this.current ++;
|
this.current ++;
|
||||||
},
|
},
|
||||||
onLoad(o) {
|
onLoad(o) {
|
||||||
this.getList(o.id)
|
this.getList(o.id)
|
||||||
|
this.startTime = dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
this.nowTime = new Date().getTime()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user