提交 cf194517 authored 作者: lihuihui's avatar lihuihui

fix: 修改错题页面

上级 7b5fff92
......@@ -8,6 +8,8 @@
submitButtonText="清空记录,重新答题"
@submitExam="handleSubmit"
@page-change="handlePageChange"
@deleteQuestion="deleteQuestion"
ref="exam"
v-if="Object.keys(data).length"
></exam-card>
</template>
......@@ -38,6 +40,22 @@ export default {
this.getTopic()
},
methods: {
// 删除题目
deleteQuestion(data) {
const param = {
question_id: data.question_list[0].question_id,
type: this.$route.query.type
}
api
.deleteQuestion(param)
.then(response => {
// this.getTopic()
this.$router.go(0)
})
.finally(() => {
})
console.log(data)
},
// 获取考卷
getTopic() {
const query = this.$route.query
......@@ -51,44 +69,44 @@ export default {
this.data = response
})
},
// 缓存答案
handleCache(data) {
const params = this.genSubmitData(data)
api.setCourseCache(Object.assign(params, { status: 0 }))
},
// 清空
handleSubmit(data) {
const params = this.genSubmitData(data)
api.setCourseCache(Object.assign(params, { status: 1 })).then(res => {
this.$router.replace({
path: '/course/chapter/result',
query: Object.assign({}, this.$route.query, { type: 2 })
})
const param = {
type: this.$route.query.type,
question_type: this.$route.query.qType,
clear: 1
}
this.cacheQuestion(param, () => {
this.$router.go(0)
})
},
// 缓存答案
handlePageChange(data) {
console.log(data)
this.cacheQuestion(this.genSubmitData(this.$refs.exam.questionItems))
},
cacheQuestion(param, call) {
api
.setMyCache(param)
.then(response => {
call()
})
.finally(() => {
})
},
// 组装提交数据
genSubmitData(questionList) {
const answers = {}
questionList.forEach(item => {
if (!answers[item.question_item_id]) {
answers[item.question_item_id] = {}
}
item.question_list.forEach(cItem => {
answers[item.question_item_id][cItem.id] = {
sign: cItem.sign ? cItem.sign : false,
answers: cItem.user_answer
if (cItem.user_answer.length) {
answers[cItem.question_id] = cItem.user_answer
}
})
})
return {
type: 1,
sheet_id: this.data.id,
status: 0,
answers: JSON.stringify(answers),
duration: 0
type: this.$route.query.type,
question_type: this.$route.query.qType,
answer: JSON.stringify(answers)
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论