Commit a8eecbf2 authored by Damon's avatar Damon

feat: 答题-考试

parent 4b21073b
......@@ -96,6 +96,7 @@
:numberList="complete.result"
:type="complete.type"
:visible.sync="complete.visible"
:timeout="complete.timeout"
@cancel="cancel"
@submit="submit"
>
......@@ -151,6 +152,7 @@ export default {
type: 'pass',
result: [],
visible: false,
timeout: false
},
timestamp: 60 * 60,
list: [],
......@@ -215,12 +217,11 @@ export default {
this.type = 1
break;
}
// 第一次进入,显示提示
if (this.questionList.length === 0) {
this.show = true
}
this.init()
},
methods: {
......@@ -234,7 +235,13 @@ export default {
// 列表总长度,一定要在第一次请求列表数据前明确该值
// 否则无法知道下一页是否还有数据
let total = parseInt(res) || 0
// 考试
if (this.type === 2) {
this.pageSize = 100
total = 100
}
this.total = total
// 练习模式-初始化答题卡列表
if (this.type === 1) Utils.initAnswerCardList(total, this)
this.cachePageDataMap = new Map()
......@@ -353,7 +360,8 @@ export default {
this.model = i
},
timeEnd() {
this.complete.timeout = true
this.handPapers()
},
// 作答完毕
answerChange(status, lists) {
......@@ -365,23 +373,29 @@ export default {
item.errShow = this.type === 2 ? true : status === 'fail'
// 更新答题卡
this.questionList[this.currentIndex] = item
this.$u.vuex('questionList', this.questionList)
this.$u.vuex('lastIndex', this.currentIndex)
if (this.type === 1){
this.questionList[this.currentIndex] = item
this.$u.vuex('questionList', this.questionList)
this.$u.vuex('lastIndex', this.currentIndex)
// 每日一练数量统计
if (this.type === 1 && this.daily.status) {
if (this.daily.count < 9) this.daily.count++
if (this.daily.count === 9) {
this.daily.visible = true
this.daily.status = false
return
// 每日一练数量统计
if (this.daily.status) {
if (this.daily.count < 9) this.daily.count++
if (this.daily.count === 9) {
this.daily.visible = true
this.daily.status = false
return
}
}
}
// 如果回答错误或者是考试模式,自动进入下一题
if ((status === 'pass' && this.model !== 2)|| this.type === 2) {
if ((status === 'pass' && this.model !== 2) || this.type === 2) {
if (this.currentIndex + 1 > this.total - 1) {
if (this.type === 2) {
this.handPapers(1)
this.submit()
}
return
}
this.$nextTick(() => {
......@@ -389,19 +403,20 @@ export default {
})
}
},
// 交卷
handPapers() {
// 统计分数
handPapers(type) {
const fail = this.list.filter((v) => v.result === 'fail').length // 错题数
const noStart = this.list.filter((v) => !v.result).length // 未做题数
const fraction = 0 // 分数
const fraction = this.total - noStart - fail// 分数
this.complete.result = [fail, noStart, fraction]
this.complete.type = 'pass'
this.complete.visible = true
this.complete.type = fraction < 60 ? 'fail' : 'pass'
if (!type) this.complete.visible = true
},
// 考试成绩弹框确认
submit() {
// 提前交卷
this.$u.route({
type: 'redirect',
url: '/pages/learn/score',
})
},
......@@ -415,7 +430,10 @@ export default {
},
// 每日一练弹框取消
dailyCancel() {
this.$u.route('/pages/learn/record')
this.$u.route({
type: 'redirect',
url: '/pages/learn/record',
})
},
// 收藏
collection() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment