Quiz Editor
Quiz Output
${questions[i].text}
`; for (let j = 0; j < questions[i].options.length; j++) { quizHTML += `${questions[i].options[j].text}
`;
}
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!");
};

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