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

fix: 修改错题页面

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