diff --git a/src/components/Question.vue b/src/components/Question.vue new file mode 100644 index 0000000..4749353 --- /dev/null +++ b/src/components/Question.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/src/components/Score.vue b/src/components/Score.vue index c7768c3..bd722ae 100644 --- a/src/components/Score.vue +++ b/src/components/Score.vue @@ -6,6 +6,7 @@ import { ref, computed } from "vue"; import { useStore } from "@/stores"; import { Splide, SplideSlide } from "@splidejs/vue-splide"; +import Question from "./Question.vue"; import "@splidejs/splide/dist/css/splide.min.css"; import ScoreHeader from "./ScoreHeader.vue"; @@ -60,9 +61,6 @@ function formatScore(score) { const title = score ? score.title : ""; const questions = ref(formatScore(score)); -function nextQuestion() { - setTimeout(() => slides.value.go(">"), 100); -} const scoreSum = computed(() => { return questions.value .map((question) => question.weight) @@ -97,21 +95,16 @@ const result = computed(() => .filter((r) => !r.max || r.max >= scoreSum.value)[0] : null ); -function selectImage(event, question, answer) { - const input = document.querySelector( - `input[name='question_${question.id}'][value='${answer.weight}']` - ); - if (input) { - input.checked = true; - input.dispatchEvent(new Event("change")); - } - nextQuestion(); -} -function geQuestionSlide(question) { +function goQuestionSlide(question) { + console.log(slides.value); slides.value.go( questions.value.findIndex((element) => element.id === question.id) ); } +function answerSelected(question, answerWeight) { + questions.value.find((q) => q.id === question.id).weight = answerWeight; + setTimeout(() => slides.value.go(">"), 100); +}