修改缺少题型增加角标为数组

master
xialiang 3 years ago
parent 1c9b8f147f
commit ff8e5bf719

@ -132,8 +132,8 @@ const CardList = () => {
// 试题列表
const paperList = result.question_list;
let arr=[[],[],[]];
let question_type_count=[
const arr = [[], [], []];
const question_type_count = [
{ count: 0, question_type: 0, type_name: '单选' },
{ count: 0, question_type: 1, type_name: '多选' },
{ count: 0, question_type: 2, type_name: '填空' },
@ -179,7 +179,9 @@ const CardList = () => {
const questionInfo = []
for (let i = 0; i < questionList.length; i++) {
questionList[i].children.map((e, index) => {
questionInfo.push({ ...e, index: index })
questionInfo.push({ ...e, index: [i, index] })
questionList[i].children[index].index = [i, index]
})
}
@ -324,7 +326,7 @@ const CardList = () => {
paperInfo.map((e) => {
if (e.id === item.id) {
// 重写单选的label、valueindex保存当前试题的index。
setQuestionNow({ ...item, index: e.index })
setQuestionNow({ ...item })
}
})
@ -384,10 +386,10 @@ const CardList = () => {
// 修改答题卡状态 写入答案以及修改答题状态
const qX = questionNow?.question_type;
const qI = questionNow?.index;
questionList[qX].children[qI].answerSelect = questionAnswer;
questionList[questionNow.index[0]].children[questionNow.index[1]].answerSelect = questionAnswer;
// 答题状态
questionList[qX].children[qI].state = 1
questionList[qX].children[qI].answerId = item.id
questionList[questionNow.index[0]].children[questionNow.index[1]].state = 1
questionList[questionNow.index[0]].children[questionNow.index[1]].answerId = item.id
// 提交答题卡
setQuestionTypeList(questionList)
@ -413,10 +415,10 @@ const CardList = () => {
// 修改答题卡状态 写入答案以及修改答题状态
const qX = questionNow?.question_type;
const qI = questionNow?.index;
questionList[qX].children[qI].answerSelect = questionAnswer;
questionList[questionNow.index[0]].children[questionNow.index[1]].answerSelect = questionAnswer;
// 答题状态
questionList[qX].children[qI].state = 1
questionList[qX].children[qI].answerId = e
questionList[questionNow.index[0]].children[questionNow.index[1]].state = 1
questionList[questionNow.index[0]].children[questionNow.index[1]].answerId = e
// 提交答题卡
setQuestionTypeList(questionList)
@ -451,10 +453,10 @@ const CardList = () => {
// 修改答题卡状态 写入答案以及修改答题状态
const qX = questionNow?.question_type;
const qI = questionNow?.index;
questionList[qX].children[qI].answerSelect = questionAnswer;
questionList[questionNow.index[0]].children[questionNow.index[1]].answerSelect = questionAnswer;
// 答题状态
questionList[qX].children[qI].state = 1
questionList[qX].children[qI].answerId = item.id
questionList[questionNow.index[0]].children[questionNow.index[1]].state = 1
questionList[questionNow.index[0]].children[questionNow.index[1]].answerId = item.id
// 提交答题卡
setQuestionTypeList(questionList)
@ -503,9 +505,9 @@ const CardList = () => {
const nextTemp = paperInfo[i - 1]
const questionList = questionTypeList
let nextData = {}
questionList[nextTemp.question_type].children.map((item, index) => {
questionList[nextTemp.index[0]].children.map((item, index) => {
if (item.id === nextTemp.id) {
nextData = { ...item, index: index }
nextData = item
}
})
setQuestionNow(nextData)
@ -528,9 +530,9 @@ const CardList = () => {
const nextTemp = paperInfo[i + 1]
const questionList = questionTypeList
let nextData = {}
questionList[nextTemp.question_type].children.map((item, index) => {
questionList[nextTemp.index[0]].children.map((item, index) => {
if (item.id === nextTemp.id) {
nextData = { ...item, index: index }
nextData = item
}
})
setQuestionNow(nextData)

Loading…
Cancel
Save