From fbfd196da140ff93a56413a1ebff8017ce317c99 Mon Sep 17 00:00:00 2001 From: Kirkland Brown Date: Wed, 10 Jul 2024 10:17:34 -0400 Subject: [PATCH] Reverted changes to question-chain and force matched the part questions before committing to mainStore --- src/digital-components/question-chain/question-chain.vue | 3 +-- src/layouts/part-questions/part-questions.vue | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/digital-components/question-chain/question-chain.vue b/src/digital-components/question-chain/question-chain.vue index 217c6dcb..5f72221f 100644 --- a/src/digital-components/question-chain/question-chain.vue +++ b/src/digital-components/question-chain/question-chain.vue @@ -123,7 +123,7 @@ export default { const answeredQuestions = []; // TODO: This forEach could probably be converted into something more reactive - this.questions.forEach((q, index) => { + this.questions.forEach((q) => { // find this question and mark it as "answered" by populating answerSelected if (q.questionSequence === questionNum) { q.answerSelected = returnedAnswer; @@ -134,7 +134,6 @@ export default { // (needed in case user is changing previously answered questions) if (q.questionSequence > questionNum) { delete q.answerSelected; - delete this.questionData[index].answerSelected; } if (q.answerSelected) { answeredQuestions.push({ diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue index 286008c8..d20d15c4 100644 --- a/src/layouts/part-questions/part-questions.vue +++ b/src/layouts/part-questions/part-questions.vue @@ -126,6 +126,11 @@ export default { ); }, async forwardButtonAction() { + // match partQuestionAnswers to answerData + const questionNums = new Set(this.questionsData[0].answerData.answeredQuestions.map(obj => obj.questionNum)); + this.questionsData.partQuestions = this.questionsData[0].partQuestions.map(obj => {if(!questionNums.has(obj.questionSequence)) delete obj.answerSelected}); + this.questionsData.partQuestions = this.questionsData[0].questions.map(obj => {if(!questionNums.has(obj.questionSequence)) delete obj.answerSelected}); + const questionAnswersArray = this.questionsData.map((glass) => ({ glassLocation: glass.glassLocation, glassName: glass.glassName,