Commit a8eecbf2 authored by Damon's avatar Damon

feat: 答题-考试

parent 4b21073b
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
:numberList="complete.result" :numberList="complete.result"
:type="complete.type" :type="complete.type"
:visible.sync="complete.visible" :visible.sync="complete.visible"
:timeout="complete.timeout"
@cancel="cancel" @cancel="cancel"
@submit="submit" @submit="submit"
> >
...@@ -151,6 +152,7 @@ export default { ...@@ -151,6 +152,7 @@ export default {
type: 'pass', type: 'pass',
result: [], result: [],
visible: false, visible: false,
timeout: false
}, },
timestamp: 60 * 60, timestamp: 60 * 60,
list: [], list: [],
...@@ -220,7 +222,6 @@ export default { ...@@ -220,7 +222,6 @@ export default {
if (this.questionList.length === 0) { if (this.questionList.length === 0) {
this.show = true this.show = true
} }
this.init() this.init()
}, },
methods: { methods: {
...@@ -234,7 +235,13 @@ export default { ...@@ -234,7 +235,13 @@ export default {
// 列表总长度,一定要在第一次请求列表数据前明确该值 // 列表总长度,一定要在第一次请求列表数据前明确该值
// 否则无法知道下一页是否还有数据 // 否则无法知道下一页是否还有数据
let total = parseInt(res) || 0 let total = parseInt(res) || 0
// 考试
if (this.type === 2) {
this.pageSize = 100
total = 100
}
this.total = total this.total = total
// 练习模式-初始化答题卡列表 // 练习模式-初始化答题卡列表
if (this.type === 1) Utils.initAnswerCardList(total, this) if (this.type === 1) Utils.initAnswerCardList(total, this)
this.cachePageDataMap = new Map() this.cachePageDataMap = new Map()
...@@ -353,7 +360,8 @@ export default { ...@@ -353,7 +360,8 @@ export default {
this.model = i this.model = i
}, },
timeEnd() { timeEnd() {
this.complete.timeout = true
this.handPapers()
}, },
// 作答完毕 // 作答完毕
answerChange(status, lists) { answerChange(status, lists) {
...@@ -365,12 +373,13 @@ export default { ...@@ -365,12 +373,13 @@ export default {
item.errShow = this.type === 2 ? true : status === 'fail' item.errShow = this.type === 2 ? true : status === 'fail'
// 更新答题卡 // 更新答题卡
if (this.type === 1){
this.questionList[this.currentIndex] = item this.questionList[this.currentIndex] = item
this.$u.vuex('questionList', this.questionList) this.$u.vuex('questionList', this.questionList)
this.$u.vuex('lastIndex', this.currentIndex) this.$u.vuex('lastIndex', this.currentIndex)
// 每日一练数量统计 // 每日一练数量统计
if (this.type === 1 && this.daily.status) { if (this.daily.status) {
if (this.daily.count < 9) this.daily.count++ if (this.daily.count < 9) this.daily.count++
if (this.daily.count === 9) { if (this.daily.count === 9) {
this.daily.visible = true this.daily.visible = true
...@@ -378,10 +387,15 @@ export default { ...@@ -378,10 +387,15 @@ export default {
return 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.currentIndex + 1 > this.total - 1) {
if (this.type === 2) {
this.handPapers(1)
this.submit()
}
return return
} }
this.$nextTick(() => { this.$nextTick(() => {
...@@ -389,19 +403,20 @@ export default { ...@@ -389,19 +403,20 @@ export default {
}) })
} }
}, },
// 交卷 // 统计分数
handPapers() { handPapers(type) {
const fail = this.list.filter((v) => v.result === 'fail').length // 错题数 const fail = this.list.filter((v) => v.result === 'fail').length // 错题数
const noStart = this.list.filter((v) => !v.result).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.result = [fail, noStart, fraction]
this.complete.type = 'pass' this.complete.type = fraction < 60 ? 'fail' : 'pass'
this.complete.visible = true if (!type) this.complete.visible = true
}, },
// 考试成绩弹框确认 // 考试成绩弹框确认
submit() { submit() {
// 提前交卷 // 提前交卷
this.$u.route({ this.$u.route({
type: 'redirect',
url: '/pages/learn/score', url: '/pages/learn/score',
}) })
}, },
...@@ -415,7 +430,10 @@ export default { ...@@ -415,7 +430,10 @@ export default {
}, },
// 每日一练弹框取消 // 每日一练弹框取消
dailyCancel() { dailyCancel() {
this.$u.route('/pages/learn/record') this.$u.route({
type: 'redirect',
url: '/pages/learn/record',
})
}, },
// 收藏 // 收藏
collection() { 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