feat: Selection de la première réponse automatiquement

This commit is contained in:
Simon 2022-04-06 12:32:04 +02:00
parent 5fc23225d0
commit ba8443dca6
1 changed files with 7 additions and 2 deletions

View File

@ -12,7 +12,11 @@ const props = defineProps({
defineEmits(["answerSelected"]); defineEmits(["answerSelected"]);
const slides = ref(); const slides = ref();
const answerWeight = ref(props.question.answers[0].weight);
if (props.question.weight == null) {
props.question.weight = props.question.answers[0].weight
}
const answerWeight = ref(props.question.weight);
function selectAnswer(answer) { function selectAnswer(answer) {
const answerIndex = props.question.answers.findIndex( const answerIndex = props.question.answers.findIndex(
@ -20,8 +24,9 @@ function selectAnswer(answer) {
); );
slides.value.splide.go(answerIndex); slides.value.splide.go(answerIndex);
} }
function slideMove(splide, newIndex) { function slideMove(splide, newIndex) {
answerWeight.value = props.question.answers[newIndex].weight; props.question.weight = props.question.answers[newIndex].weight;
} }
</script> </script>