提交 4d89d072 authored 作者: 王鹏飞's avatar 王鹏飞

chore: 修改试题序号

上级 b915e964
......@@ -19,7 +19,7 @@
<template v-for="items in questions">
<exam-item
v-for="(item, index) in items"
:index="index"
:index="item.index"
:type="item.type"
:data="item"
:value="item.formModel"
......@@ -88,6 +88,7 @@ export default {
if (!this.questions.length) {
this.questions = data.paper ? this.genQuestions(data.paper.examination) : []
}
console.log(this.questions)
}
}
},
......@@ -144,27 +145,34 @@ export default {
if (!list) {
return []
}
return list.map(data => {
let index = -1
return list.map((data) => {
let { radioList = [], checkboxList = [], shortAnswerList = [], judgeList = [] } = data
// 单选
radioList = radioList.map(item => {
radioList = radioList.map((item) => {
index++
const temp = {
index,
type: 1,
formModel: { id: item.id, user_answer: item.user_answer || '' }
}
return Object.assign({}, item, temp)
})
// 多选
checkboxList = checkboxList.map(item => {
checkboxList = checkboxList.map((item) => {
index++
const temp = {
index,
type: 2,
formModel: { id: item.id, user_answer: item.user_answer || [] }
}
return Object.assign({}, item, temp)
})
// 问答
shortAnswerList = shortAnswerList.map(item => {
shortAnswerList = shortAnswerList.map((item) => {
index++
const temp = {
index,
type: 3,
formModel: {
id: item.id,
......@@ -175,8 +183,10 @@ export default {
return Object.assign({}, item, temp)
})
// 判断题
judgeList = judgeList.map(item => {
judgeList = judgeList.map((item) => {
index++
const temp = {
index,
type: 4,
formModel: { id: item.id, user_answer: item.user_answer || '' }
}
......@@ -190,12 +200,13 @@ export default {
this.loading = true
api
.getCourseExamResult(this.sid, this.cid, this.pid, { paper_type: 0 })
.then(response => {
.then((response) => {
// 设置问题列表数据
if (response.code !== 8001) {
this.isStartExam = true
this.exam = response
this.questions = this.genQuestions(response.sheet)
console.log(this.questions)
// 自动提交
if (this.isStartExam && !this.isSubmited && !this.isExamComplete) {
this.autoSubmit()
......@@ -252,7 +263,7 @@ export default {
},
// 处理请求接口答案数据
handleSubmitData() {
return this.questions.map(questions => {
return this.questions.map((questions) => {
return questions.reduce(
(result, item) => {
// 单选题
......@@ -285,7 +296,7 @@ export default {
params.paper_type = 0
api
.submitCourseExam(this.sid, this.cid, this.pid, params)
.then(response => {
.then((response) => {
if (params.type === 0) {
console.log('暂存成功')
return
......@@ -298,7 +309,7 @@ export default {
this.$message.error(response.data.error)
}
})
.catch(error => {
.catch((error) => {
this.$message.error(error.message)
})
.finally(() => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论