From d4e87f72635ed523f96110db6983d5fa0fac9482 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Mon, 8 Aug 2022 21:06:38 -0400 Subject: [PATCH] CSR-108: minor refactoring --- src/layouts/part-questions/part-questions.vue | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue index b1e2a17b9..cfaa97fc8 100644 --- a/src/layouts/part-questions/part-questions.vue +++ b/src/layouts/part-questions/part-questions.vue @@ -285,12 +285,13 @@ export default { // suppress current question thisAnsweredPartQuestion.suppressQuestion = true; - if (this.foundDuplicateQuestions["glassPart" + i]) { - if (!this.foundDuplicateQuestions["glassPart" + i].includes(thisAnsweredPartQuestion.questionSequence)) { - this.foundDuplicateQuestions["glassPart" + i].push(thisAnsweredPartQuestion.questionSequence); + const thisGlassPart = "glassPart" + i; + if (this.foundDuplicateQuestions[thisGlassPart]) { + if (!this.foundDuplicateQuestions[thisGlassPart].includes(thisAnsweredPartQuestion.questionSequence)) { + this.foundDuplicateQuestions[thisGlassPart].push(thisAnsweredPartQuestion.questionSequence); } } else { - this.foundDuplicateQuestions["glassPart" + i] = [thisAnsweredPartQuestion.questionSequence]; + this.foundDuplicateQuestions[thisGlassPart] = [thisAnsweredPartQuestion.questionSequence]; } // are there any questions left that are not suppressed? @@ -338,7 +339,7 @@ export default { // "glassPart2": [7, 10] // }; - const thisPartsDupes = this.foundDuplicateQuestions['glassPart' + answer.partIndex]; + const thisPartsDupes = this.foundDuplicateQuestions["glassPart" + answer.partIndex]; thisPartsDupes?.forEach((dupe) => { // dupe is a single integer @@ -373,10 +374,10 @@ export default { }); // make sure there are no duplicated dupes... - const seen = new Set(); + const foundInCompleteAnsweredQuestions = new Set(); let filteredCompleteAnsweredQuestions = completeAnsweredQuestions.filter(el => { - const duplicate = seen.has(el.questionText); - seen.add(el.questionText); + const duplicate = foundInCompleteAnsweredQuestions.has(el.questionText); + foundInCompleteAnsweredQuestions.add(el.questionText); return !duplicate; }); filteredCompleteAnsweredQuestions = filteredCompleteAnsweredQuestions.sort((a,b) => a.questionNum - b.questionNum);