提交 e7fb77f3 authored 作者: lhh's avatar lhh

修改考试相关

上级 4be84df0
...@@ -41,7 +41,7 @@ const goExam = function () { ...@@ -41,7 +41,7 @@ const goExam = function () {
></CourseCatalog> ></CourseCatalog>
</div> </div>
<van-button <van-button
v-if="data.course?.exams && data.course?.exams.length" v-if="data.course?.exams && data.course?.exams.length && data.course.is_free_name !== '收费'"
@click="goExam" @click="goExam"
type="primary" type="primary"
size="large" size="large"
......
...@@ -24,8 +24,13 @@ if (route.query.type) { ...@@ -24,8 +24,13 @@ if (route.query.type) {
getExam(initParams).then((res: any) => { getExam(initParams).then((res: any) => {
data = res.data data = res.data
if (res.data?.questions || res.data?.questions !== '') { if (res.data?.questions || res.data?.questions !== '') {
questions = changeData(JSON.parse(res.data.questions).question_items) const allQ = changeData(JSON.parse(res.data.questions).question_items)
console.log(questions, 'questions') questions = allQ.reduce((a: any, b: any) => {
b.question_list.forEach((item: any) => {
a.push({ ...b, question_list: [item] })
})
return a
}, [])
} }
}) })
...@@ -109,8 +114,14 @@ const submit = function () { ...@@ -109,8 +114,14 @@ const submit = function () {
const params: any = {} const params: any = {}
questions.forEach((item: any) => { questions.forEach((item: any) => {
item.question_list.forEach((cItem: any) => { item.question_list.forEach((cItem: any) => {
params[item.question_item_id] = { if (params[item.question_item_id] === undefined) {
[cItem.id]: { params[item.question_item_id] = {
[cItem.id]: {
answer: Array.isArray(cItem.answer) ? cItem.answer : [cItem.answer]
}
}
} else {
params[item.question_item_id][cItem.id] = {
answer: Array.isArray(cItem.answer) ? cItem.answer : [cItem.answer] answer: Array.isArray(cItem.answer) ? cItem.answer : [cItem.answer]
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论