diff --git a/src/common-components/question-chain/question-chain.vue b/src/common-components/question-chain/question-chain.vue index fb61608d5..0be09fabf 100644 --- a/src/common-components/question-chain/question-chain.vue +++ b/src/common-components/question-chain/question-chain.vue @@ -55,15 +55,6 @@ export default { questions.unshift({}); return questions; }, - questionText() { - return this.questions[this.currentQuestion]?.questionText; - }, - questionAnswers() { - return this.questions[this.currentQuestion]?.answers; - }, - questionGroupname() { - return `${this.questionData.glassName}-${this.questionData.glassLocation}-${this.currentQuestion}`; - }, selectedValue: { get: function() { return this.modelValue; @@ -78,50 +69,50 @@ export default { } }, methods: { - getNewModelValue(returnedAnswer) { - if (!returnedAnswer || !Array.isArray(returnedAnswer)) { return false } - const lastAnswer = returnedAnswer[returnedAnswer.length - 1]; - const currentQuestion = this.questions[this.currentQuestion]; - console.log('currentQuestion: ', currentQuestion) - console.log('currentQuestion.answers: ', currentQuestion.answers) + getNewModelValue(returnedAnswer) { + if (!returnedAnswer || !Array.isArray(returnedAnswer)) { return false } + const lastAnswer = returnedAnswer[returnedAnswer.length - 1]; + const currentQuestion = this.questions[this.currentQuestion]; + console.log('currentQuestion: ', currentQuestion) + console.log('currentQuestion.answers: ', currentQuestion.answers) - if (lastAnswer.indexOf("answer-") === 0) { - // if it is an answerResult - const finalAnswer = lastAnswer.slice(7); + if (lastAnswer.indexOf("answer-") === 0) { + // if it is an answerResult + const finalAnswer = lastAnswer.slice(7); - const currentQuestionSelectedAnswer = currentQuestion.answers.find( - ({ answerResult }) => answerResult === finalAnswer - ); + const currentQuestionSelectedAnswer = currentQuestion.answers.find( + ({ answerResult }) => answerResult === finalAnswer + ); - // add current item to list of answered questions - this.answeredQuestions.push( - { - questionText: currentQuestion.questionText, - selectedAnswerText: currentQuestionSelectedAnswer.Text, - } - ); + // add current item to list of answered questions + this.answeredQuestions.push( + { + questionText: currentQuestion.questionText, + selectedAnswerText: currentQuestionSelectedAnswer.Text, + } + ); - return { - answerResult: finalAnswer, - answeredQuestions: this.answeredQuestions, - }; - } else { - const currentQuestionSelectedAnswer = currentQuestion.answers.find( - ({ nextQuestionSequence }) => nextQuestionSequence === parseInt(lastAnswer) - ); + return { + answerResult: finalAnswer, + answeredQuestions: this.answeredQuestions, + }; + } else { + const currentQuestionSelectedAnswer = currentQuestion.answers.find( + ({ nextQuestionSequence }) => nextQuestionSequence === parseInt(lastAnswer) + ); - // add current item to list of answered questions - this.answeredQuestions.push( - { - questionText: currentQuestion.questionText, - selectedAnswerText: currentQuestionSelectedAnswer.Text, - } - ); + // add current item to list of answered questions + this.answeredQuestions.push( + { + questionText: currentQuestion.questionText, + selectedAnswerText: currentQuestionSelectedAnswer.Text, + } + ); - this.currentQuestion = parseInt(lastAnswer); // update count to display next question - return false; - } + this.currentQuestion = parseInt(lastAnswer); // update count to display next question + return false; } + } }, components: { buttonQuestion,