function gradeQuiz() { let score = 0; let total = 5; let output = ""; // Q1 let q1 = document.getElementById("q1").value.trim().toLowerCase(); if (q1 === "hypertext") { score++; output += "
Q1 Correct
"; } else { output += "Q1 Incorrect (Answer: HyperText)
"; } // Q2 let q2 = document.querySelector('input[name="q2"]:checked'); if (q2 && q2.value === "css") { score++; output += "Q2 Correct
"; } else { output += "Q2 Incorrect (Answer: CSS)
"; } // Q3 let q3 = document.querySelector('input[name="q3"]:checked'); if (q3 && q3.value === "interaction") { score++; output += "Q3 Correct
"; } else { output += "Q3 Incorrect (Answer: Interactivity)
"; } // Q4 let q4 = document.querySelector('input[name="q4"]:checked'); if (q4 && q4.value === "a") { score++; output += "Q4 Correct
"; } else { output += "Q4 Incorrect (Answer: <a>)
"; } // Q5 multi-select let q5 = document.querySelectorAll('input[name="q5"]:checked'); let answers = Array.from(q5).map(el => el.value); let correct = answers.includes("html") && answers.includes("css") && answers.includes("js") && answers.length === 3; if (correct) { score++; output += "Q5 Correct
"; } else { output += "Q5 Incorrect (Answer: HTML, CSS, JavaScript)
"; } // PASS / FAIL let resultColor = score >= 3 ? "green" : "red"; let resultText = score >= 3 ? "PASS" : "FAIL"; document.getElementById("results").innerHTML = `Score: ${score} / ${total}
${output} `; } function resetQuiz() { document.getElementById("results").innerHTML = ""; }