आचार्य आशीष मिश्र Reply जून 27, 2024
Quiz Generator

Quiz Editor
























Quiz Output


  
`; // Style the quiz based on chosen colors quizHTML += ``; // Questions let score = 0; let selectedOptions = []; for (let i = 0; i < questions.length; i++) { quizHTML += `

${questions[i].text}

`; for (let j = 0; j < questions[i].options.length; j++) { quizHTML += `
${questions[i].options[j].text}
`; } quizHTML += `
`; } // Submit button quizHTML += ``; // Score display quizHTML += `
Score: 0
`; // Answer Sheet quizHTML += ` `; document.getElementById("quizHTML").textContent = quizHTML; } function checkAnswer(questionIndex, optionIndex) { let option = document.querySelectorAll(".option")[questionIndex * 4 + optionIndex]; // Highlight correct or wrong answer if (questions[questionIndex].options[optionIndex].correct) { option.classList.add("correct"); } else { option.classList.add("wrong"); } // Store selected answer for scoring selectedOptions[questionIndex] = optionIndex; } function submitQuiz() { let score = 0; for (let i = 0; i < questions.length; i++) { if (selectedOptions[i] !== undefined && questions[i].options[selectedOptions[i]].correct) { score++; } } document.getElementById("score").textContent = "Score: " + score; } function showAnswerSheet() { document.getElementById("answerSheet").style.display = "block"; } // Copy HTML code to clipboard document.getElementById("quizHTML").onclick = function() { this.select(); document.execCommand("copy"); alert("Quiz HTML code copied to clipboard!"); };

एक टिप्पणी भेजें

Search

चरक

स्क्रॉल करें

The Power Of Subscription Economy.

Follow us

Popular Posts

- Navigation - Archive Status