const buttonNext = document.querySelector("button.buttonNext"); const buttonPrev = document.querySelector("button.buttonPrev"); const buttonTryAgain = document.querySelector("button.tryAgain"); const questionText = document.querySelector(".question"); const listAnswer = document.querySelector(".listAnswer"); const questionProgress = document.querySelector(".questionProgress"); const listQuestion = [ { question: `When was Kuwait City recognized as a World Crafts City for AlSadu Weaving by the World Crafts Council?`, listAnswer: [ "2023", "2024", "2025", ], correctAnswer: "2025", numberQuestion:'1' }, { question: `When did UNESCO include the art of AlSadu in the world's intangible cultural heritage? `, listAnswer: [ "2020", "2021", "2022 ", ], correctAnswer: "2020", numberQuestion:'2' }, { question: `What is the traditional craft of AlSadu weaving in Kuwait? `, listAnswer: [ "Weaving camel wool", "Knitting sheep’s wool", "Spinning goat hair", ], correctAnswer: "Knitting sheep’s wool", numberQuestion:'3' }, { question: `Which season was traditionally used for shearing wool in the Bedioun desert of Kuwait?`, listAnswer: [ "Winter Season", "Autumn Season", "Spring Season", ], correctAnswer: "Spring Season", numberQuestion:'4' }, { question: `Which plant is used to dye the traditional wool threads in AlSadu weaving craft?`, listAnswer: [ "Nuwair (Senecio glaucus)", "Arjun (Podaxis)", "Jouri (Rose)", ], correctAnswer: "Arjun (Podaxis)", numberQuestion:'5' }, { question: `What name is given to a woman who excels in knitting in the Bedouin tradition?`, listAnswer: [ "Jayyida (Good) ", "Mahira (Skilled)", "Dhafra (Distinguished)", ], correctAnswer: "Dhafra (Distinguished)", numberQuestion:'6' }, ]; let currentQuestion = 1; let score = 0; let listWrongAnswers = []; document.addEventListener("DOMContentLoaded", () => { generateQuestion(); generatePagination(); checkActivePagination(); checkButtonVisibility(); }); buttonNext && buttonNext.addEventListener("click", () => { if (checkAnswer()) { if (currentQuestion + 1 <= listQuestion.length) { currentQuestion += 1; if (currentQuestion <= listQuestion.length) { generateQuestion(); } if (currentQuestion + 1 > listQuestion.length) { buttonNext.textContent = "Next"; } } else { buttonNext.disabled = true; showResult(); } checkActivePagination(); checkButtonVisibility(); } }); buttonPrev && buttonPrev.addEventListener("click", () => { if (currentQuestion > 1) { currentQuestion -= 1; generateQuestion(); checkActivePagination(); checkButtonVisibility(); } }); function checkButtonVisibility() { if (currentQuestion > 1) { buttonPrev.style.display = "inline-block"; } else { buttonPrev.style.display = "none"; } if (currentQuestion === listQuestion.length) { buttonNext.textContent = "Next"; } else { buttonNext.textContent = "Next"; } } buttonTryAgain && buttonTryAgain.addEventListener("click", () => { tryAgain(); generateQuestion(); checkActivePagination(); }); function generateQuestion() { questionText.textContent = listQuestion[currentQuestion - 1].question; document.querySelector('.numberQuestion').innerHTML = 'Question ' + listQuestion[currentQuestion - 1].numberQuestion; listAnswer.textContent = ""; listQuestion[currentQuestion - 1].listAnswer.forEach((value) => { listAnswer.innerHTML += `