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

chore: 修改试题序号

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