Created
February 7, 2025 17:30
-
-
Save lovemycodesnippets/46ea1bb42819088d69e3da83dfb0f453 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 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