From 69b3b282b6398b22d65601a4d9dc94bdde557f31 Mon Sep 17 00:00:00 2001 From: QYF-GitLab1 <1940665526@qq.com> Date: 星期五, 20 十二月 2024 11:10:40 +0800 Subject: [PATCH] ···· --- packageCourse/components/teaching/index.js | 43 ++++++++++++++++++++++++++++++------------- 1 files changed, 30 insertions(+), 13 deletions(-) diff --git a/packageCourse/components/teaching/index.js b/packageCourse/components/teaching/index.js index 876032f..af77c75 100644 --- a/packageCourse/components/teaching/index.js +++ b/packageCourse/components/teaching/index.js @@ -214,7 +214,6 @@ }, // 澶勭悊鏁版嵁缁撴瀯 chageData(arr, zrr) { - let newData = [] // 棰樺簱棰樼洰绫诲瀷 const questionTypeList = [{ name: '鍗曢�夐', @@ -259,22 +258,30 @@ ] for (let i = 0; i < arr.length; i++) { const item = arr[i] - item.questionTypeList = questionTypeList - for (let j = 0; j < zrr.length; j++) { - const ele = zrr[j] - const qusObj = item.question.find((citem) => citem.cmsItemId == ele.id) - if (qusObj?.cmsItemId) { - ele.userAnswer = qusObj.answer - const index = findIndexByValue(questionTypeList, ele.questionType) - if (index > -1) { - item.questionTypeList[index].data.push(ele) + item.questionTypeList = JSON.parse(JSON.stringify(questionTypeList)); + item.other = [] + for (let j = 0; j < item.question.length; j++) { + const ele = item.question[j] + const data = zrr.find((sitem) => sitem.id == ele.cmsItemId) + const index = findIndexById(zrr, ele.cmsItemId) + if (index > -1) { + item.other[index] = { + ...data, + userAnswer: ele.answer } } } - item.questionTypeList = item.questionTypeList.filter((item) => item.data.length > 0) - newData.push(item) + if (item.other.length > 0) { + item.other.forEach((aitem) => { + const index = findIndexByValue(item.questionTypeList, aitem.questionType) + if (index > -1) { + item.questionTypeList[index].data.push(aitem) + } + }) + } + item.questionTypeList = item.questionTypeList.filter((xitem) => xitem.data.length > 0) } - return newData.filter((item) => item.questionTypeList.length > 0) + return arr }, findIndexByValue(res, type) { for (let i = 0; i < res.length; i++) { @@ -284,6 +291,16 @@ } return -1 // 濡傛灉鏈壘鍒帮紝鍒欒繑鍥� -1 }, + + findIndexById(res, id) { + for (let i = 0; i < res.length; i++) { + if (res[i].id == id) { + return i + } + } + return -1 // 濡傛灉鏈壘鍒帮紝鍒欒繑鍥� -1 + }, + toDetail(e) { const { item -- Gitblit v1.9.1