Skip to content

Instantly share code, notes, and snippets.

@lovemycodesnippets
Created February 7, 2025 17:30
Show Gist options
  • Save lovemycodesnippets/46ea1bb42819088d69e3da83dfb0f453 to your computer and use it in GitHub Desktop.
Save lovemycodesnippets/46ea1bb42819088d69e3da83dfb0f453 to your computer and use it in GitHub Desktop.
From the article "Building a Quiz App with Nuxt and Xata"
<script setup>
const selectAnswer = (is_correct) => {
emit("question-answered", is_correct);
};
</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, qi) in questions"
:key="question.id"
v-show="questionsAnswered === qi">
<div class="question">{{ question.question_text }}</div>
<div class="answers">
<div
class="answer"
v-for="answer in getAnswersForQuestion(question.id)"
:key="answer.answer_text"
@click.prevent="selectAnswer(answer.is_correct)">
{{ 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