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EAAAA,OAAOpD,KAAkB,QAGnE,QAEJqD,EAAAA,EAAAA,cAAcC,EAAAA,EAAAA,oBAAoB,MAAOrE,EAAY,EACpDsE,EAAAA,EAAAA,oBAAoB,MAAO,KAAM,EAC/BA,EAAAA,EAAAA,oBAAoB,QAAS,CAC3BxE,MAAO,gBACP0E,KAAMlD,EACNiB,GAAIf,EACJiD,KAAM,QACNlD,OAAO4C,EAAAA,EAAAA,OAAOtD,GACd6D,QAASxB,GACR,KAAM,EAAGjD,IACZqE,EAAAA,EAAAA,oBAAoB,QAAS,CAAEK,IAAKnD,GAAmB,EACrD8C,EAAAA,EAAAA,oBAAoB,OAAQ,KAAM,EAChCA,EAAAA,EAAAA,oBAAoB,OAAQ,MAAMO,EAAAA,EAAAA,kBAAiBV,EAAAA,EAAAA,OAAOrD,IAAS,MAErEiE,EAAAA,EAAAA,YAAYd,EAAKe,OAAQ,iBAKrC,ICtLA,MAAMC,EAAc,EAEpB,O","sources":["webpack://beliefnet-frontend/./src/stores/TriviaQuiz.ts","webpack://beliefnet-frontend/./src/components/quiz/trivia/Answer.vue?f3ae","webpack://beliefnet-frontend/./src/components/quiz/trivia/Answer.vue"],"sourcesContent":["import { defineStore } from 'pinia';\n\nexport const useTriviaQuizStore = defineStore('TriviaQuiz', {\n state: () => {\n return {\n correctAnswer: [] as number[],\n userAnswer: [] as number[]\n };\n },\n getters: {\n getNumberOfCorrectAnswers(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 (answer == state.correctAnswer[index]) {\n count++;\n }\n }\n });\n\n return count;\n },\n getUserAnswer(state) {\n return (question: number) => state.userAnswer[question];\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 state.userAnswer.filter((val) => val === -1).length === 0;\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 },\n actions: {\n reset(numberOfQuestions: number) {\n this.correctAnswer = Array(numberOfQuestions).fill(-1);\n this.userAnswer = Array(numberOfQuestions).fill(-1);\n },\n setCorrectAnswer(question: number, answer: number) {\n this.correctAnswer[question] = answer;\n },\n setUserAnswer(question: number, answer: number) {\n this.userAnswer[question] = answer;\n }\n }\n});\n","import { defineComponent as _defineComponent } from 'vue'\nimport { unref as _unref, createElementVNode as _createElementVNode, toDisplayString as _toDisplayString, normalizeClass as _normalizeClass, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot } from \"vue\"\n\nconst _hoisted_1 = { key: 0 }\nconst _hoisted_2 = [\"value\"]\nconst _hoisted_3 = { class: \"explaination\" }\nconst _hoisted_4 = { class: \"result-icon\" }\nconst _hoisted_5 = { key: 1 }\nconst _hoisted_6 = [\"value\"]\n\nimport { toRefs } from 'vue';\nimport { useLogger } from 'vue-logger-plugin';\nimport { useTriviaQuizStore } from '../../../stores/TriviaQuiz';\n\n// Incoming props\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'Answer',\n props: {\n totalAnswers: Number,\n questionNumber: Number,\n answerNumber: Number,\n quizType: String,\n isCorrect: Boolean,\n weight: Number,\n title: String,\n answerMessage: String\n},\n setup(__props) {\n\nconst props = __props;\n\n\n\n// get back prop values\nconst { totalAnswers, questionNumber, answerNumber, quizType, isCorrect, weight, title, answerMessage } = toRefs(props);\n\n// user logger\nconst logger = useLogger();\n\n// get the trivia quiz store\nconst triviaStore = useTriviaQuizStore();\n\nconst questionName = 'question' + questionNumber?.value;\nconst answerDivIdName = 'question' + questionNumber?.value + 'answer' + answerNumber?.value;\nconst explanationIdName = 'question' + questionNumber?.value + 'answer' + answerNumber?.value + 'explanation';\nconst correctDivName = isCorrect?.value == true ? 'correct' : 'incorrect';\nconst correctText = isCorrect?.value == true ? 'correct!' : 'incorrect';\nconst iconClass = isCorrect?.value == true ? 'glyphicon-ok-sign' : 'glyphicon-remove-sign';\n\nconst getOffset = (el) => {\n const rect = el.getBoundingClientRect();\n return {\n left: rect.left + window.scrollX,\n top: rect.top + window.scrollY\n };\n};\n\nconst scroll = (id: string, removeHide: boolean, offset: number) => {\n var element = document.getElementById(id);\n if (element == null) {\n return;\n }\n\n if (removeHide) {\n element.classList.remove('hide');\n }\n\n var elementPosition = getOffset(element).top - offset;\n window.scrollTo({ top: elementPosition, behavior: 'smooth' });\n};\n\n// user clicked an answer so determine if correct or show the right answer\nconst userClickAnswer = () => {\n if (questionNumber?.value >= 0 && answerNumber?.value >= 0) {\n logger.debug('Clicked answer for question', questionNumber.value, answerNumber.value);\n // keep track of what answer the user selected\n triviaStore.setUserAnswer(questionNumber.value, answerNumber.value);\n\n // if this is the correct answer show any explanation text that may be included\n if (isCorrect.value == true) {\n const explanationItem = document.getElementById('question' + questionNumber.value + 'answer' + answerNumber.value + 'explanation') as HTMLElement;\n if (explanationItem.classList.contains('hide')) {\n explanationItem.classList.remove('hide');\n }\n }\n\n // disable each of the question's radio group\n for (let answer = 0; answer < totalAnswers?.value; answer++) {\n logger.debug('Disable answers for question', questionNumber.value, answer);\n const elementItem = document.getElementById('question' + questionNumber.value + 'answer' + answer);\n elementItem?.setAttribute('disabled', 'disabled');\n\n // show the correct answer\n if (isCorrect.value == false && elementItem?.getAttribute('value') == '1') {\n logger.debug('Showing correct answer for question', questionNumber.value, answer);\n elementItem?.parentElement?.classList.add('class', 'show-correct');\n\n // this means we didn't click the correct answer but we want to show any explanation that comes with this answer's correct answer\n const explanationItem = document.getElementById('question' + questionNumber.value + 'answer' + answer + 'explanation') as HTMLElement;\n if (explanationItem.classList.contains('hide')) {\n explanationItem.classList.remove('hide');\n }\n }\n }\n }\n\n // determine how we could scroll to the next question or the next result\n var timeToScroll = 2e3;\n if (triviaStore.canShowUserResult) {\n const toTimer = setTimeout(() => {\n scroll('results', true, 50);\n }, timeToScroll);\n\n //detect if user scrolled and remove setTimeout\n window.onscroll = () => {\n clearTimeout(toTimer);\n };\n } else {\n const nextQuestion = 'question' + triviaStore.nextQuestion(questionNumber?.value);\n logger.debug('going to next question from current question', nextQuestion, questionNumber?.value);\n const toTimer = setTimeout(() => {\n scroll(nextQuestion, true, 50);\n }, timeToScroll);\n\n //detect if user scrolled and remove setTimeout\n window.onscroll = () => {\n clearTimeout(toTimer);\n };\n }\n};\n\nreturn (_ctx: any,_cache: any) => {\n return (_unref(quizType) == 'Default')\n ? (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n _createElementVNode(\"div\", {\n class: _normalizeClass(_unref(correctDivName))\n }, [\n _createElementVNode(\"input\", {\n class: \"questionClass\",\n name: questionName,\n id: answerDivIdName,\n type: \"radio\",\n value: _unref(isCorrect) == true ? '1' : '0',\n onClick: userClickAnswer\n }, null, 8, _hoisted_2),\n _createElementVNode(\"label\", { for: answerDivIdName }, [\n _createElementVNode(\"span\", null, [\n _createElementVNode(\"div\", _hoisted_3, [\n _createElementVNode(\"div\", _hoisted_4, [\n _createTextVNode(_toDisplayString(_unref(correctText)) + \"Â \", 1),\n _createElementVNode(\"span\", {\n class: _normalizeClass([\"glyphicon\", _unref(iconClass)]),\n \"aria-hidden\": \"true\"\n }, null, 2)\n ])\n ]),\n _createElementVNode(\"span\", null, _toDisplayString(_unref(title)), 1),\n _createElementVNode(\"div\", {\n class: \"explaination explaination-text hide\",\n id: explanationIdName\n }, _toDisplayString(decodeURIComponent(_unref(answerMessage))), 1)\n ])\n ])\n ], 2)\n ]))\n : (_openBlock(), _createElementBlock(\"div\", _hoisted_5, [\n _createElementVNode(\"div\", null, [\n _createElementVNode(\"input\", {\n class: \"questionClass\",\n name: questionName,\n id: answerDivIdName,\n type: \"radio\",\n value: _unref(weight),\n onClick: userClickAnswer\n }, null, 8, _hoisted_6),\n _createElementVNode(\"label\", { for: answerDivIdName }, [\n _createElementVNode(\"span\", null, [\n _createElementVNode(\"span\", null, _toDisplayString(_unref(title)), 1)\n ]),\n _renderSlot(_ctx.$slots, \"default\")\n ])\n ])\n ]))\n}\n}\n\n})","import script from \"./Answer.vue?vue&type=script&setup=true&lang=ts\"\nexport * from \"./Answer.vue?vue&type=script&setup=true&lang=ts\"\n\nconst __exports__ = script;\n\nexport default __exports__"],"names":["useTriviaQuizStore","defineStore","state","correctAnswer","userAnswer","getters","getNumberOfCorrectAnswers","count","forEach","answer","index","length","getUserAnswer","question","numberOfQuestions","canShowUserResult","filter","val","nextQuestion","currentQuestion","this","actions","reset","Array","fill","setCorrectAnswer","setUserAnswer","_hoisted_1","key","_hoisted_2","_hoisted_3","class","_hoisted_4","_hoisted_5","_hoisted_6","_defineComponent","__name","props","totalAnswers","Number","questionNumber","answerNumber","quizType","String","isCorrect","Boolean","weight","title","answerMessage","setup","__props","toRefs","logger","useLogger","triviaStore","questionName","value","answerDivIdName","explanationIdName","correctDivName","correctText","iconClass","getOffset","el","rect","getBoundingClientRect","left","window","scrollX","top","scrollY","scroll","id","removeHide","offset","element","document","getElementById","classList","remove","elementPosition","scrollTo","behavior","userClickAnswer","debug","explanationItem","contains","elementItem","setAttribute","getAttribute","_a","parentElement","add","timeToScroll","toTimer","setTimeout","onscroll","clearTimeout","_ctx","_cache","_unref","_openBlock","_createElementBlock","_createElementVNode","_normalizeClass","name","type","onClick","for","_createTextVNode","_toDisplayString","decodeURIComponent","_renderSlot","$slots","__exports__"],"sourceRoot":""}