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/./src/stores/OnePageQuiz.ts","webpack://beliefnet-frontend/./src/components/quiz/onepage/Question.vue?e531","webpack://beliefnet-frontend/./src/components/quiz/onepage/Question.vue"],"sourcesContent":["import { defineStore } from 'pinia';\n\nexport const useOnePageQuizStore = defineStore('OnePageQuiz', {\n state: () => {\n return {\n finalResults: [] as any[],\n answeredQuestions: [] as boolean[],\n correctAnswer: [] as number[],\n userAnswer: [] as number[],\n userWeight: [] as number[]\n };\n },\n getters: {\n getAnswerTotalWeightOrCorrect(state) {\n let count = 0;\n\n // count the number of correct answers\n state.userAnswer.forEach((answer, index) => {\n if (index + 1 <= state.correctAnswer.length) {\n if (state.correctAnswer[index] >= 0 && answer == state.correctAnswer[index]) {\n count++;\n }\n }\n });\n\n // count the weight if we have it\n state.userWeight.forEach((weight, index) => {\n if (index + 1 <= state.correctAnswer.length) {\n if (weight >= 0) {\n count += weight;\n }\n }\n });\n\n return count;\n },\n numberOfQuestions: (state) => state.correctAnswer.length,\n canShowUserResult(state) {\n // only show if there aren't any -1s in the user answer array\n return (\n state.userAnswer.filter((val) => val === -1).length === 0 ||\n state.userWeight.filter((val) => val === -1).length === 0 ||\n state.answeredQuestions.filter((val) => val === false).length === 0\n );\n },\n nextQuestion() {\n return (currentQuestion: number) => {\n const nextQuestion = ++currentQuestion;\n if (nextQuestion < this.numberOfQuestions) {\n return nextQuestion;\n }\n\n return -1;\n };\n },\n getFinalResult(state) {\n let finalResult = null;\n\n if (state.finalResults.length > 0) {\n state.finalResults.sort(function (a, b) {\n return b.score - a.score;\n });\n finalResult = state.finalResults[0].result;\n }\n\n return finalResult;\n }\n },\n actions: {\n reset(numberOfQuestions: number) {\n this.correctAnswer = Array(numberOfQuestions).fill(-1);\n this.userAnswer = Array(numberOfQuestions).fill(-1);\n this.userWeight = Array(numberOfQuestions).fill(-1);\n this.answeredQuestions = Array(numberOfQuestions).fill(false);\n },\n setCorrectAnswer(question: number, answer: number) {\n this.correctAnswer[question] = answer;\n },\n setUserAnswer(question: number, answer: number, weight: number) {\n if (this.correctAnswer[question] < 0) {\n this.userWeight[question] = weight;\n } else {\n this.userAnswer[question] = answer;\n }\n },\n setFinalAnswer(result: string, score: number) {\n const existingKeyIndex = this.searchFinalResultsIndex(result);\n\n if (existingKeyIndex >= 0) {\n this.finalResults[existingKeyIndex].score += score;\n } else {\n this.finalResults.push({ result: result, score: score });\n }\n },\n searchFinalResultsIndex(key: string) {\n for (let idx = 0; idx < this.finalResults.length; idx++) {\n if (this.finalResults[idx].result === key) {\n return idx;\n }\n }\n\n return -1;\n },\n setQuestionAsAnswered(question: number) {\n this.answeredQuestions[question] = true;\n }\n }\n});\n","import { defineComponent as _defineComponent } from 'vue'\nimport { renderSlot as _renderSlot } from \"vue\"\n\nimport { toRefs } from 'vue';\nimport { useLogger } from 'vue-logger-plugin';\nimport { useOnePageQuizStore } from '../../../stores/OnePageQuiz';\n\n// Incoming props\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'Question',\n props: { questionNumber: Number, correctAnswer: Number },\n setup(__props) {\n\nconst props = __props;\n\n\n\n// get back prop values\nconst { questionNumber, correctAnswer } = toRefs(props);\n\n// use logger\nconst logger = useLogger();\n\n// get the trivia quiz store\nconst onePageStore = useOnePageQuizStore();\n// check if we have correct answer\nif (questionNumber?.value >= 0 && correctAnswer?.value >= 0) {\n logger.debug('Setting question with correct answer', questionNumber.value, correctAnswer.value);\n onePageStore.setCorrectAnswer(questionNumber.value, correctAnswer.value);\n}\n\nreturn (_ctx: any,_cache: any) => {\n return _renderSlot(_ctx.$slots, \"default\")\n}\n}\n\n})","import script from \"./Question.vue?vue&type=script&setup=true&lang=ts\"\nexport * from \"./Question.vue?vue&type=script&setup=true&lang=ts\"\n\nconst __exports__ = script;\n\nexport default __exports__"],"names":["useOnePageQuizStore","defineStore","state","finalResults","answeredQuestions","correctAnswer","userAnswer","userWeight","getters","getAnswerTotalWeightOrCorrect","count","forEach","answer","index","length","weight","numberOfQuestions","canShowUserResult","filter","val","nextQuestion","currentQuestion","this","getFinalResult","finalResult","sort","a","b","score","result","actions","reset","Array","fill","setCorrectAnswer","question","setUserAnswer","setFinalAnswer","existingKeyIndex","searchFinalResultsIndex","push","key","idx","setQuestionAsAnswered","_defineComponent","__name","props","questionNumber","Number","setup","__props","toRefs","logger","useLogger","onePageStore","value","debug","_ctx","_cache","_renderSlot","$slots","__exports__"],"sourceRoot":""}