From a2c85faa872531c1ed292a7b46f02b4595f3f835 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Wed, 14 Sep 2022 16:44:24 -0400 Subject: [PATCH] CSR-803: Move foundDuplicateQuestions to be local var --- .../capability-questions.vue | 16 ++++++++-------- .../molding-questions/molding-questions.vue | 16 ++++++++-------- src/layouts/part-questions/part-questions.vue | 16 ++++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/layouts/capability-questions/capability-questions.vue b/src/layouts/capability-questions/capability-questions.vue index cdb38c58e..00200c31a 100644 --- a/src/layouts/capability-questions/capability-questions.vue +++ b/src/layouts/capability-questions/capability-questions.vue @@ -76,7 +76,6 @@ export default { capabilityQuestionsData: store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS).partsOrQuestions, selectedAnswers: {}, currentQuestionChainIndex: 0, - foundDuplicateQuestions: [], }; }, computed: { @@ -147,7 +146,7 @@ export default { // only runs when all questions in a question-chain have been answered // when selectedAnswers updates, user has completed this part's question chain and has a final answer // (does not get run for each invididual question's answer, only when - // all relevent questions for the current part have been answered) + // all relevant questions for the current part have been answered) /* answer example format: @@ -166,6 +165,7 @@ export default { // collect a list of the answered questions' numbers, needed later below const answeredQuestionIndexes = []; + const foundDuplicateQuestions = []; // if user has answered a question differently than anything that was preloaded, // we need to clear out any preloaded answers @@ -280,12 +280,12 @@ export default { thisAnsweredCapabilityQuestion.suppressQuestion = true; const thisGlassPart = "glass" + gpIndex; - if (this.foundDuplicateQuestions[thisGlassPart]) { - if (!this.foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredCapabilityQuestion.questionSequence)) { - this.foundDuplicateQuestions[thisGlassPart].push(thisAnsweredCapabilityQuestion.questionSequence); + if (foundDuplicateQuestions[thisGlassPart]) { + if (!foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredCapabilityQuestion.questionSequence)) { + foundDuplicateQuestions[thisGlassPart].push(thisAnsweredCapabilityQuestion.questionSequence); } } else { - this.foundDuplicateQuestions[thisGlassPart] = [thisAnsweredCapabilityQuestion.questionSequence]; + foundDuplicateQuestions[thisGlassPart] = [thisAnsweredCapabilityQuestion.questionSequence]; } // are there any questions left that are not suppressed? @@ -332,12 +332,12 @@ export default { // EX answeredQuestionIndexes: [1,5,11,13] - // EX this.foundDuplicateQuestions = { + // EX foundDuplicateQuestions = { // "glassPart1": [1], // "glassPart2": [7, 10] // }; - const thisPartsDupes = this.foundDuplicateQuestions["glass" + answer.glassIndex]; + const thisPartsDupes = foundDuplicateQuestions["glass" + answer.glassIndex]; const completeAnsweredQuestions = answer.answeredQuestions ? [...answer.answeredQuestions] : []; const glassPartAnswered = this.capabilityQuestionsData[answer.glassIndex]; diff --git a/src/layouts/molding-questions/molding-questions.vue b/src/layouts/molding-questions/molding-questions.vue index 00e71c917..333e02e61 100644 --- a/src/layouts/molding-questions/molding-questions.vue +++ b/src/layouts/molding-questions/molding-questions.vue @@ -94,7 +94,6 @@ export default { moldingQuestionsData: store.getters.pageData(fmgPageValues.MOLDING_QUESTIONS).partsOrQuestions, selectedAnswers: {}, currentGlassIndex: 0, - foundDuplicateQuestions: [], }; }, computed: { @@ -157,7 +156,7 @@ export default { // only runs when all questions in a question-chain have been answered // when selectedAnswers updates, user has completed this part's question chain and has a final answer // (does not get run for each invididual question's answer, only when - // all relevent questions for the current part have been answered) + // all relevant questions for the current part have been answered) /* answer example format: @@ -176,6 +175,7 @@ export default { // collect a list of the answered questions' numbers, needed later below const answeredQuestionIndexes = []; + const foundDuplicateQuestions = []; // if user has answered a question differently than anything that was preloaded, // we need to clear out any preloaded answers @@ -288,12 +288,12 @@ export default { thisAnsweredPartQuestion.suppressQuestion = true; const thisGlassPart = "glass" + gpIndex; - if (this.foundDuplicateQuestions[thisGlassPart]) { - if (!this.foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredPartQuestion.questionSequence)) { - this.foundDuplicateQuestions[thisGlassPart].push(thisAnsweredPartQuestion.questionSequence); + if (foundDuplicateQuestions[thisGlassPart]) { + if (!foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredPartQuestion.questionSequence)) { + foundDuplicateQuestions[thisGlassPart].push(thisAnsweredPartQuestion.questionSequence); } } else { - this.foundDuplicateQuestions[thisGlassPart] = [thisAnsweredPartQuestion.questionSequence]; + foundDuplicateQuestions[thisGlassPart] = [thisAnsweredPartQuestion.questionSequence]; } // are there any questions left that are not suppressed? @@ -341,12 +341,12 @@ export default { // EX answeredQuestionIndexes: [1,5,11,13] - // EX this.foundDuplicateQuestions = { + // EX foundDuplicateQuestions = { // "glassPart1": [1], // "glassPart2": [7, 10] // }; - const thisPartsDupes = this.foundDuplicateQuestions["glass" + answer.glassIndex]; + const thisPartsDupes = foundDuplicateQuestions["glass" + answer.glassIndex]; const completeAnsweredQuestions = answer.answeredQuestions ? [...answer.answeredQuestions] : []; const glassPartAnswered = this.moldingQuestionsData[answer.glassIndex]; diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue index 4906d9526..2cd4a99db 100644 --- a/src/layouts/part-questions/part-questions.vue +++ b/src/layouts/part-questions/part-questions.vue @@ -93,7 +93,6 @@ export default { partsQuestionsData: store.getters.pageData(fmgPageValues.PART_QUESTIONS).partsOrQuestions, selectedAnswers: {}, currentGlassIndex: 0, - foundDuplicateQuestions: [], }; }, computed: { @@ -153,7 +152,7 @@ export default { // only runs when all questions in a question-chain have been answered // when selectedAnswers updates, user has completed this part's question chain and has a final answer // (does not get run for each invididual question's answer, only when - // all relevent questions for the current part have been answered) + // all relevant questions for the current part have been answered) /* answer example format: @@ -172,6 +171,7 @@ export default { // collect a list of the answered questions' numbers, needed later below const answeredQuestionIndexes = []; + const foundDuplicateQuestions = []; // if user has answered a question differently than anything that was preloaded, // we need to clear out any preloaded answers @@ -284,12 +284,12 @@ export default { thisAnsweredQuestion.suppressQuestion = true; const thisGlassPart = "glass" + gpIndex; - if (this.foundDuplicateQuestions[thisGlassPart]) { - if (!this.foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredQuestion.questionSequence)) { - this.foundDuplicateQuestions[thisGlassPart].push(thisAnsweredQuestion.questionSequence); + if (foundDuplicateQuestions[thisGlassPart]) { + if (!foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredQuestion.questionSequence)) { + foundDuplicateQuestions[thisGlassPart].push(thisAnsweredQuestion.questionSequence); } } else { - this.foundDuplicateQuestions[thisGlassPart] = [thisAnsweredQuestion.questionSequence]; + foundDuplicateQuestions[thisGlassPart] = [thisAnsweredQuestion.questionSequence]; } // are there any questions left that are not suppressed? @@ -337,12 +337,12 @@ export default { // EX answeredQuestionIndexes: [1,5,11,13] - // EX this.foundDuplicateQuestions = { + // EX foundDuplicateQuestions = { // "glassPart1": [1], // "glassPart2": [7, 10] // }; - const thisPartsDupes = this.foundDuplicateQuestions["glass" + answer.glassIndex]; + const thisPartsDupes = foundDuplicateQuestions["glass" + answer.glassIndex]; const completeAnsweredQuestions = answer.answeredQuestions ? [...answer.answeredQuestions] : []; const glassPartAnswered = this.partsQuestionsData[answer.glassIndex];