fix: support variable quiz question counts

This commit is contained in:
NgoQuocViet2001 2026-08-09 00:37:31 +07:00
parent 33e781bf7b
commit 7c767a5ba9
1 changed files with 3 additions and 4 deletions

View File

@ -21,7 +21,7 @@
:key="index"
v-for="(option, index) in quiz.quiz[currentQuestion]
.answerOptions"
@click="handleAnswerClick(option.isCorrect)"
@click="handleAnswerClick(option.isCorrect, quiz.quiz.length)"
class="btn ans-btn"
>
{{ option.answerText }}
@ -62,12 +62,11 @@ export default {
},
methods: {
handleAnswerClick(isCorrect) {
handleAnswerClick(isCorrect, questionCount) {
this.error = false;
let nextQuestion = this.currentQuestion + 1;
if (isCorrect) {
//always 3 questions per quiz
if (nextQuestion < 3) {
if (nextQuestion < questionCount) {
this.currentQuestion = nextQuestion;
} else {
this.complete = true;