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EAAAA,KAOzB,OALkB,OAAdsC,QAAc,IAAdA,OAAc,EAAdA,EAAgBQ,SAChBH,EAAOI,MAAM,kCAAmCT,EAAeQ,OAC/DD,EAAiBnB,MAAMY,EAAeQ,QAGnC,CAACE,EAAUC,MACRC,EAAAA,EAAAA,cAAcC,EAAAA,EAAAA,oBAAoB,MAAOlB,EAAY,EAC3DmB,EAAAA,EAAAA,YAAYJ,EAAKK,OAAQ,aAG7B,ICpCA,MAAMC,EAAc,EAEpB,O","sources":["webpack://beliefnet-frontend/./src/stores/PersonalityQuiz.ts","webpack://beliefnet-frontend/./src/components/quiz/Personality.vue?6fc1","webpack://beliefnet-frontend/./src/components/quiz/Personality.vue"],"sourcesContent":["import { defineStore } from 'pinia';\n\nexport const usePersonalityQuizStore = defineStore('PersonalityQuiz', {\n    state: () => {\n        return {\n            correctAnswer: [] as number[],\n            weight: [] as number[],\n            answerTypeQuiz: false\n        };\n    },\n    getters: {\n        total: (state) => state.weight.reduce((a, b) => a + b),\n        getNumberOfCorrectAnswers(state) {\n            let count = 0;\n\n            // count the number of correct answers\n            state.weight.forEach((answer, index) => {\n                if (index + 1 <= state.correctAnswer.length) {\n                    if (answer == state.correctAnswer[index]) {\n                        count++;\n                    }\n                }\n            });\n\n            return count;\n        },\n        isAnswerTypeQuiz: (state) => state.answerTypeQuiz,\n        canShowUserResult(state) {\n            // only show if there aren't any -1s in the user answer array\n            return state.weight.filter((val) => val === -1).length === 0;\n        },\n        numberOfQuestions: (state) => state.weight.length,\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    },\n    actions: {\n        reset(numberOfQuestions: number) {\n            this.weight = Array(numberOfQuestions).fill(-1);\n            this.correctAnswer = Array(numberOfQuestions).fill(-1);\n            this.answerTypeQuiz = false;\n        },\n        setAnswerTypeQuiz() {\n            this.answerTypeQuiz = true;\n        },\n        setCorrectAnswer(question: number, answer: number) {\n            this.correctAnswer[question] = answer;\n        },\n        setUserAnswer(question: number, answer: number) {\n            this.weight[question] = answer;\n        }\n    }\n});\n","import { defineComponent as _defineComponent } from 'vue'\nimport { renderSlot as _renderSlot, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nconst _hoisted_1 = { class: \"quiz-wrapper trivia-quiz\" }\n\nimport { toRefs } from 'vue';\nimport { usePersonalityQuizStore } from '../../stores/PersonalityQuiz';\nimport { useLogger } from 'vue-logger-plugin';\n\n// Incoming props\n\nexport default /*#__PURE__*/_defineComponent({\n  __name: 'Personality',\n  props: { questionsCount: Number },\n  setup(__props) {\n\nconst props = __props;\n\n\n\n// get back prop values\nconst { questionsCount } = toRefs(props);\n\n// use the logger\nconst logger = useLogger();\n\n// get the trivia quiz store\nconst personalityStore = usePersonalityQuizStore();\n// we want to reset the number of questions being shown on this page\nif (questionsCount?.value) {\n    logger.debug('Resetting quiz question counter', questionsCount.value);\n    personalityStore.reset(questionsCount.value);\n}\n\nreturn (_ctx: any,_cache: any) => {\n  return (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n    _renderSlot(_ctx.$slots, \"default\")\n  ]))\n}\n}\n\n})","import script from \"./Personality.vue?vue&type=script&setup=true&lang=ts\"\nexport * from \"./Personality.vue?vue&type=script&setup=true&lang=ts\"\n\nconst __exports__ = script;\n\nexport default __exports__"],"names":["usePersonalityQuizStore","defineStore","state","correctAnswer","weight","answerTypeQuiz","getters","total","reduce","a","b","getNumberOfCorrectAnswers","count","forEach","answer","index","length","isAnswerTypeQuiz","canShowUserResult","filter","val","numberOfQuestions","nextQuestion","currentQuestion","this","actions","reset","Array","fill","setAnswerTypeQuiz","setCorrectAnswer","question","setUserAnswer","_hoisted_1","class","_defineComponent","__name","props","questionsCount","Number","setup","__props","toRefs","logger","useLogger","personalityStore","value","debug","_ctx","_cache","_openBlock","_createElementBlock","_renderSlot","$slots","__exports__"],"sourceRoot":""}