From f9bd10b6400eb77c897170eb6af82fc2e7d8b2f7 Mon Sep 17 00:00:00 2001 From: Simon C Date: Wed, 6 Apr 2022 11:01:37 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20S=C3=A9paration=20du=20code=20sp=C3=A9c?= =?UTF-8?q?ifique=20aux=20questions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Question.vue | 99 +++++++++++++++++++++++++++++++++++ src/components/Score.vue | 101 ++++-------------------------------- 2 files changed, 108 insertions(+), 92 deletions(-) create mode 100644 src/components/Question.vue 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); +}