
- Django - Home
- Django - Basics
- Django - Overview
- Django - Environment
- Django - Creating a Project
- Django - Apps Life Cycle
- Django - Creating Views
- Django - URL Mapping
- Django - Index Page
- Django - Templates System
- Django - MVT
- Django - Add Master Template
- Django Admin
- Django Admin - Interface
- Django Admin - Create User
- Django Admin - Include Models
- Django Admin - Set Fields to Display
- Django Admin - Update Objects
- Django Models
- Django - Models
- Django - Insert Data
- Django - Update Data
- Django - Delete Data
- Django - Update Model
- Django Static Files
- Django - Add Static Files
- Django - Add CSS Files
- Django Advanced
- Django - Page not Found (404)
- Django - Page Redirection
- Django - Sending E-mails
- Django - Generic Views
- Django - Form Processing
- Django - File Uploading
- Django - Apache Setup
- Django - Cookies Handling
- Django - Sessions
- Django - Caching
- Django - Comments
- Django - RSS
- Django - AJAX
Quiz on Django Overview
${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