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

优化课后考试

上级 06bb1660
......@@ -95,3 +95,10 @@ export function paySuccess(id) {
export function getAcitivityReportList(id) {
return httpRequest.get(`/api/lms/v2/education/symposium/${id}/report`)
}
// 上传文件
export function uploadFile(data) {
return httpRequest.post('/api/lms/v2/lobby/tools/upload', data, {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
......@@ -179,21 +179,30 @@ export default {
},
// 获取考试结果
getExamResult() {
api.getCourseExamResult(this.sid, this.cid, this.pid, { paper_type: 0 }).then(response => {
// 设置问题列表数据
if (response.code !== 8001) {
this.isStartExam = true
this.exam = response
this.questions = this.genQuestions(response.sheet)
// 自动提交
if (this.isStartExam && !this.isSubmited && !this.isExamComplete) {
this.autoSubmit()
this.loading = true
api
.getCourseExamResult(this.sid, this.cid, this.pid, { paper_type: 0 })
.then(response => {
// 设置问题列表数据
if (response.code !== 8001) {
this.isStartExam = true
this.exam = response
this.questions = this.genQuestions(response.sheet)
// 自动提交
if (this.isStartExam && !this.isSubmited && !this.isExamComplete) {
this.autoSubmit()
}
}
}
})
})
.finally(() => {
this.loading = false
})
},
// 提交校验
checkSubmit() {
if (!this.questions.length) {
return
}
for (let i = 0; i < this.questions.length; i++) {
const questions = this.questions[i]
for (let k = 0; k < questions.length; k++) {
......
......@@ -61,7 +61,7 @@ export default {
immediate: true,
handler(data) {
if (!this.questions.length) {
this.questions = data.homework ? this.genQuenstions(data.homework.questions) : []
this.questions = data.homework ? this.genQuestions(data.homework.questions) : []
}
}
}
......@@ -120,7 +120,7 @@ export default {
}
return item
})
this.questions = this.genQuenstions(this.questions)
this.questions = this.genQuestions(this.questions)
}
})
.finally(() => {
......@@ -128,7 +128,7 @@ export default {
})
},
// 组装问题数据
genQuenstions(list) {
genQuestions(list) {
if (!list) {
return []
}
......@@ -167,9 +167,12 @@ export default {
},
// 提交校验
checkSubmit() {
const quenstions = this.questions
for (let i = 0; i < quenstions.length; i++) {
const value = quenstions[i].formModel.user_answer
const questions = this.questions
if (!questions.length) {
return
}
for (let i = 0; i < questions.length; i++) {
const value = questions[i].formModel.user_answer
if (Array.isArray(value) ? !value.length : !value) {
return false
}
......
......@@ -117,7 +117,7 @@ export default {
immediate: true,
handler(data) {
if (!this.questions.length) {
this.questions = data.homework ? this.genQuenstions(data.homework.questions) : []
this.questions = data.homework ? this.genQuestions(data.homework.questions) : []
}
}
}
......@@ -185,7 +185,7 @@ export default {
}
return item
})
this.questions = this.genQuenstions(this.questions)
this.questions = this.genQuestions(this.questions)
}
})
.finally(() => {
......@@ -193,7 +193,7 @@ export default {
})
},
// 组装问题数据
genQuenstions(list) {
genQuestions(list) {
if (!list) {
return []
}
......@@ -232,9 +232,9 @@ export default {
},
// 提交校验
checkSubmit() {
const quenstions = this.questions
for (let i = 0; i < quenstions.length; i++) {
const value = quenstions[i].formModel.user_answer
const questions = this.questions
for (let i = 0; i < questions.length; i++) {
const value = questions[i].formModel.user_answer
if (Array.isArray(value) ? !value.length : !value) {
return false
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论