
- Computer Security - Home
- Computer Security - Overview
- Computer Security - Elements
- Computer Security - Terminologies
- Computer Security - Layers
- Computer Security - Securing OS
- Computer Security - Antiviruses
- Computer Security - Malwares
- Computer Security - Encryption
- Computer Security - Data Backup
- Disaster Recovery
- Computer Security - Network
- Computer Security - Policies
- Computer Security - Checklist
- Legal Compliance
Quiz on Layers of Computer Security
${quizData[index].explanation}`; explanationDiv.style.display = "block"; if (buttonSpan) { buttonSpan.textContent = "Hide Answer"; } // Find the correct option and highlight it with yellow background const correctRadio = document.querySelector(`input[name="q${index}"][value="${correctAnswerIndex}"]`); if (correctRadio) { // Find the parent list item and highlight it const correctOption = correctRadio.closest('li'); if (correctOption) { correctOption.style.backgroundColor = "#fff9b7"; } } } } function submitQuiz() { let score = 0, attempted = 0; quizData.forEach((q, index) => { // Since we've hidden the radio buttons, we need to check their state const selectedOption = document.querySelector(`input[name="q${index}"]:checked`); if (selectedOption) { attempted++; if (parseInt(selectedOption.value) === q.answer) score++; } }); if (attempted < Math.ceil(quizData.length / 2)) { alert(`Please attempt at least ${Math.ceil(quizData.length / 2)} questions before submitting.`); return; } document.getElementById("result").innerText = `You scored ${score} out of ${quizData.length}!`; document.querySelector(".review-btn").disabled = false; document.querySelector(".review-btn").classList.add("enabled"); document.querySelector(".result-container").style.display = "block"; // Destroy any existing chart to prevent duplicate rendering if (window.quizResultChart) { window.quizResultChart.destroy(); } // Create new chart and store reference window.quizResultChart = new Chart(document.getElementById("resultChart"), { type: 'pie', data: { labels: ["Correct", "Incorrect"], datasets: [{ data: [score, quizData.length - score], backgroundColor: ["#28a745", "#dc3545"] }] } }); } function reviewQuiz() { quizData.forEach((q, index) => { showQuizAnswer(index); }); document.querySelector(".review-btn").disabled = true; } loadQuiz();
Advertisements