Last active
February 7, 2025 17:27
-
-
Save lovemycodesnippets/8ffd5d0f60971c476eb57809f00f4c75 to your computer and use it in GitHub Desktop.
From the article "Building a Quiz App with Nuxt and Xata"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup> | |
const props = defineProps({ | |
questions: Array, | |
answers: Array, | |
}); | |
const getAnswersForQuestion = (questionId) => { | |
return props.answers.filter((answer) => answer.question.id === questionId); | |
}; | |
</script> | |
<template> | |
<div class="questions-ctr"> | |
<div class="progress"> | |
<div class="bar"></div> | |
<div class="status">1 out of 3 questions answered</div> | |
</div> | |
<div | |
class="single-question" | |
v-for="question in questions" | |
:key="question.id"> | |
<div class="question">{{ question.question_text }}</div> | |
<div class="answers"> | |
<div | |
class="answer" | |
v-for="answer in getAnswersForQuestion(question.id)" | |
:key="answer.answer_text"> | |
{{ answer.answer_text }} | |
</div> | |
</div> | |
</div> | |
</div> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment