diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue index bbd71fbd5..8082e42f7 100644 --- a/src/layouts/part-questions/part-questions.vue +++ b/src/layouts/part-questions/part-questions.vue @@ -207,9 +207,7 @@ export default { const thisAnsweredPartQuestion = glassPart.partQuestions[pqIndex]; // remove answerData from this glass part - // delete glassPart.answerData; glassPart.answerData = null; - // delete glassPart.isSuppressedPart; glassPart.isSuppressedPart = null; // Update the key to re-render this part's question-chain component @@ -440,55 +438,6 @@ export default { return part; }); - // this block is purely for handling duplicate questions - alreadyAnsweredQuestions?.forEach((savedPart, partIndex) => { - savedPart.answeredQuestions.forEach((aq) => { - if (aq.isDuplicateQuestion) { - // find this one in partsQuestionData - const dupedPartsQuestion = this.partsQuestionsData[partIndex].partQuestions[aq.questionNum - 1]; - dupedPartsQuestion.suppressDuplicateQuestion = true; - - const dupedPartsQuestionAnswer = dupedPartsQuestion.answers.filter((ans) => { - return ans.answerText.toUpperCase() === aq.selectedAnswerText.toUpperCase(); - })[0]; - - let isDupedPartsQuestionFirst; - if (aq.questionNum === 1) { isDupedPartsQuestionFirst = true } - - this.partsQuestionsData.forEach((glassPart, i) => { - - // loop through this glass part's part questions, looking for a questionText match - glassPart.partQuestions.forEach((pq, pqIndex) => { - // if this dupedQ is the first in the array then - // suppress all questions for this part up until the answer's nextQuestionSequence - if (isDupedPartsQuestionFirst && - dupedPartsQuestionAnswer.nextQuestionSequence && - pq.questionSequence < dupedPartsQuestionAnswer.nextQuestionSequence) { - pq.suppressDuplicateQuestion = true; - } - pq.answers.forEach((thisAns) => { - if (thisAns.nextQuestionSequence === aq.questionNum) { - // update either the nextQuestionSequence or the answerResult - if (dupedPartsQuestionAnswer.nextQuestionSequence) { - thisAns.originalNextQuestionSequence = thisAns.nextQuestionSequence; - thisAns.nextQuestionSequence = dupedPartsQuestionAnswer.nextQuestionSequence; - // update this change to answerSelected - pq.answerSelected = `${pq.questionSequence}|nextQuestion|${thisAns.nextQuestionSequence}|${thisAns.answerText}`; - } else { - thisAns.originalNextQuestionSequence = thisAns.nextQuestionSequence; - thisAns.nextQuestionSequence = null; - thisAns.originalAnswerResult = thisAns.originalAnswerResult || thisAns.answerResult; - thisAns.answerResult = dupedPartsQuestionAnswer.answerResult; - } - } - }) - }); - - }); - - } - }) - }); }, }, components: { diff --git a/src/store/index.js b/src/store/index.js index b8b5ffe16..359d9cb3b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -997,7 +997,7 @@ export const actions = { savePartQuestionAnswers(context, partQuestionAnswersArray) { // if part question answers have changed, reset subsequent question answers const previousResultsArray = context.getters.damage.partQuestionAnswers; - const havePartQuestionAnswersChanged = previousResultsArray.length !== partQuestionAnswersArray.length || + const havePartQuestionAnswersChanged = previousResultsArray?.length !== partQuestionAnswersArray.length || !previousResultsArray.every((x, i) => x.result === partQuestionAnswersArray[i].result); if (havePartQuestionAnswersChanged) {