<!-- wp:html --> <!DOCTYPE html> <html lang="hi"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>MCQ Quiz</title> <style> /* Basic CSS resets */ * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: Arial, sans-serif; background-color: #f1f8e9; color: #33691e; } .content-container { background-color: #dcedc8; padding: 5px; border-radius: 5px; max-width: auto; margin: 20px auto; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1); position: relative; } .header { background-color: #7cb342; color: #ffffff; text-align: center; padding: 20px; border-radius: 10px; margin-bottom: 20px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); position: relative; } .header h1 { margin: 0; font-size: 28px; } /* Hamburger Menu Icon */ .hamburger { position: absolute; top: 8px; left: 8px; z-index: 1000; width: 20px; height: 15px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; } .hamburger-line { height: 3px; background-color: #fff; border-radius: 2px; } /* Sidebar (Question Nav) */ #questionNavOverlay { position: fixed; top: 0; left: -250px; /* hidden by default */ width: 250px; height: 100%; background-color: #fff; transition: left 0.3s ease-in-out; z-index: 2000; box-shadow: 2px 0 6px rgba(0,0,0,0.3); padding: 20px; overflow-y: auto; } #questionNavOverlay.show { left: 0; /* slide in */ } #questionNavTitle { margin-bottom: 10px; font-weight: bold; font-size: 1.1rem; } .question-nav { display: flex; flex-wrap: wrap; gap: 5px; } .circle-number { width: 30px; height: 30px; border-radius: 50%; background-color: #ccc; color: #000; display: flex; justify-content: center; align-items: center; cursor: pointer; user-select: none; /* Prevent text selection */ transition: background-color 0.2s; } .circle-number:hover { background-color: #aaa; } .circle-number.active { background-color: #4CAF50; color: #fff; } /* Quiz Container */ .quiz-container { background-color: #fff; border-radius: 10px; padding: 5px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); max-width: auto; width: 100%; margin: 0 auto; text-align: center; position: relative; } .question-counter { font-weight: bold; padding: 5px 10px; border-radius: 5px; background-color: #d9edf7; position: absolute; top: 10px; left: 10px; } /* Timer display */ .timer { font-weight: bold; padding: 5px 10px; border-radius: 5px; background-color: #ffcccb; position: absolute; top: 10px; right: 10px; } .question { font-size: 1.2rem; margin-top: 40px; margin-bottom: 20px; text-align: left; } .choices { display: flex; flex-direction: column; gap: 10px; } .choice { padding: 10px; background-color: #f0f0f0; border: 1px solid #ddd; border-radius: 5px; cursor: pointer; transition: background-color 0.3s, box-shadow 0.3s; } .choice:hover { background-color: #e0e0e0; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); } .choice.selected { background-color: #28a745; /* More vivid green */ color: #fff; } .choice.correct { background-color: #28a745; /* More vivid green */ border-color: #28a745; color: #fff; } .choice.incorrect { background-color: #dc3545; /* More vivid red */ border-color: #dc3545; color: #fff; } .choice.disabled { cursor: not-allowed; pointer-events: none; opacity: 0.6; } .explanation { margin-top: 20px; text-align: left; background-color: #e7f3fe; padding: 15px; border-left: 5px solid #2196F3; border-radius: 5px; } .buttons { display: flex; justify-content: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; } .btn { flex: 1 1 auto; padding: 8px 12px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 0.9rem; text-align: center; min-width: 100px; max-width: 150px; transition: none; } .btn.disabled { background-color: #cccccc; cursor: not-allowed; } .hidden { display: none; } /* Result Section */ #resultContent { text-align: center; margin-top: 20px; } .congrats { font-size: 1.5rem; color: #4CAF50; } .sad { font-size: 1.5rem; color: #d32f2f; } /* Popup Message (Optional) */ #popupMessage { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); color: white; padding: 10px 20px; border-radius: 5px; font-size: 1rem; z-index: 5000; display: none; } #popupMessage.show { display: block; } #popupMessage.correct { background-color: #28a745; } #popupMessage.incorrect { background-color: #dc3545; } </style> </head> <body> <div class="content-container"> <div class="header"> <!-- Hamburger menu button --> <div class="hamburger" id="hamburgerBtn"> <div class="hamburger-line"></div> <div class="hamburger-line"></div> <div class="hamburger-line"></div> </div> <h1 style="color: #ffffff;">MCQs Quiz</h1> </div> <!-- Sidebar (Question Nav) --> <div id="questionNavOverlay"> <div id="questionNavTitle">Questions</div> <div class="question-nav" id="questionNav"></div> </div> <!-- Quiz Container --> <div class="quiz-container" id="quizContent"> <div class="question-counter" id="questionCounter">1/3</div> <!-- Timer display here --> <div class="timer" id="timer">Time: 00:00</div> <div class="question" id="question">Loading question...</div> <div class="choices" id="choices"></div> <!-- Explanation and feedback --> <div class="explanation hidden" id="explanation"></div> <!-- Buttons for navigation and submission --> <div class="buttons"> <button class="btn" id="prevButton">Previous</button> <button class="btn" id="submitAnswerButton">Submit Answer</button> <button class="btn hidden" id="nextButton">Next</button> </div> </div> <!-- Result Section --> <div id="resultContent" class="hidden"> <h2>Quiz Completed</h2> <div id="resultMessage"></div> <p id="scoreMessage"></p> </div> </div> <!-- Optional Popup Message --> <div id="popupMessage" class="hidden"></div> <script> /***** JavaScript Code *****/ // Quiz data (sample) const quizData = [ { "question": "भारतीय संविधान में नीति-निर्देशक तत्त्व (Directive Principles of State Policy - DPSPs) किस भाग (Part) में वर्णित हैं?", "options": [ "भाग III", "भाग IV", "भाग IV-A", "भाग V" ], "correct": 1, "explanation": "संविधान के भाग IV (Article 36-51) में नीति-निर्देशक तत्त्व शामिल हैं, जो राज्य को सामाजिक, आर्थिक एवं राजनीतिक न्याय के लक्ष्य प्राप्त करने की दिशा में मार्गदर्शन देते हैं।" }, { "question": "नीति-निर्देशक तत्त्व (DPSPs) किस देश के संविधान से प्रेरित होकर भारतीय संविधान में सम्मिलित किए गए?", "options": [ "अमेरिका (USA)", "आयरलैंड (Ireland)", "ब्रिटेन (Britain)", "ऑस्ट्रेलिया (Australia)" ], "correct": 1, "explanation": "DPSPs की अवधारणा आयरलैंड के संविधान से प्रेरित है, जहाँ सामाजिक नीति से जुड़ी कई दिशात्मक बातें उल्लिखित हैं। " }, { "question": "नीति-निर्देशक तत्त्वों के पालन में राज्य की क्या बाध्यता (Obligation) होती है?", "options": [ "कानूनी रूप से बाध्यकारी (Legally Enforceable)", "न्यायालय में प्रवर्तनीय (Justiciable)", "अनुपालन न करने पर राज्य को भंग किया जाता है", "सांविधानिक नैतिक जिम्मेदारी (Moral Responsibility), पर गैर-न्यायिक (Non-Justiciable)" ], "correct": 3, "explanation": "DPSPs न्यायिक रूप से बाध्यकारी नहीं हैं, परंतु संविधान राज्य को इन्हें लागू करने के लिए नैतिक रूप से बाध्य करता है, जिससे एक कल्याणकारी राज्य (Welfare State) की कल्पना पूरी हो सके।" }, { "question": "आर्थिक समानता (Economic Equality) और सामाजिक न्याय (Social Justice) को प्रेरित करने के लिए मुख्य रूप से किस अनुच्छेद-समूह में प्रावधान दिए गए हैं?", "options": [ "अनुच्छेद 38 से 43", "अनुच्छेद 19 से 22", "अनुच्छेद 14 से 18", "अनुच्छेद 25 से 28" ], "correct": 0, "explanation": "अनुच्छेद 38, 39, 39A, 41, 42, 43 इत्यादि में सामाजिक, आर्थिक न्याय और समानता के सिद्धांतों को बढ़ावा देने के निर्देश राज्य को दिए गए हैं। " }, { "question": "अनुच्छेद 39A (Article 39A) राज्य को किस विषय में निर्देश देता है?", "options": [ "न्याय तक समान पहुँच (Equal Justice) और मुफ़्त कानूनी सहायता (Free Legal Aid)", "महिलाओं को आरक्षण देने", "अल्पसंख्यक संस्थानों को अनुदान", "प्राकृतिक पर्यावरण की रक्षा" ], "correct": 0, "explanation": "अनुच्छेद 39A कहता है कि राज्य उचित विधान (Legislation) या योजनाओं के माध्यम से यह सुनिश्चित करेगा कि न्याय तक समान पहुँच हो और आर्थिक अथवा अन्य कारणों से कोई न्याय से वंचित न रहे।" }, { "question": "अनुच्छेद 44 (Article 44) किस समान नागरिक संहिता (Uniform Civil Code) की बात करता है?", "options": [ "केवल हिंदुओं के लिए एक सिविल कोड", "केवल मुसलमानों के लिए विशेष विधि", "सभी के लिए एकसमान व्यक्तिगत कानून (Personal Laws)", "धार्मिक स्वतंत्रता का निषेध" ], "correct": 2, "explanation": "अनुच्छेद 44 ‘समान नागरिक संहिता (Uniform Civil Code)’ की स्थापना का निर्देश देता है, ताकि सभी नागरिकों के लिए विवाह, उत्तराधिकार आदि विषयों में एकसमान कानून हो। यह अभी तक पूर्णतः लागू नहीं हुआ है। " }, { "question": "अनुच्छेद 40 (Article 40) किस संस्थागत संरचना के गठन का निर्देश देता है?", "options": [ "पंचायती राज संस्थाएँ (Panchayats)", "ऊर्जा नियामक प्राधिकरण (Energy Regulatory Authority)", "संसद और राज्य विधानसभाएँ", "संघीय न्यायालय (Federal Court)" ], "correct": 0, "explanation": "अनुच्छेद 40 में ग्राम पंचायतों (Panchayats) के गठन को प्रोत्साहित करने का निर्देश है, जिससे स्थानीय स्वशासन (Local Self-Government) मजबूत किया जा सके।" }, { "question": "अनुच्छेद 48A (Article 48A), जो 42वें संशोधन से जोड़ा गया, किससे संबंधित है?", "options": [ "बच्चों की शिक्षा", "पशुधन और कृषि सुधार", "पर्यावरण संरक्षण (Protection of Environment)", "महिलाओं के विरुद्ध हिंसा रोकना" ], "correct": 2, "explanation": "42वें संशोधन (1976) में अनुच्छेद 48A जोड़ा गया, जिसमें पर्यावरण की रक्षा और वनों (Forests) तथा वन्यजीवों (Wildlife) के संरक्षण का निर्देश राज्य को दिया गया है।" }, { "question": "‘मद्य-निषेध (Prohibition of Intoxicating Drinks)’ का निर्देशन किस अनुच्छेद में वर्णित है?", "options": [ "अनुच्छेद 47", "अनुच्छेद 39", "अनुच्छेद 48", "अनुच्छेद 45" ], "correct": 0, "explanation": "अनुच्छेद 47 राज्य को निर्देश देता है कि पोषाहार के स्तर को ऊँचा करने के साथ-साथ मादक पेयों (Intoxicating Drinks) के उपभोग का निषेध करना चाहिए।" }, { "question": "‘मुक्त और अनिवार्य शिक्षा (Free and Compulsory Education)’ मूलतः किस अनुच्छेद में नीति-निर्देशक तत्त्व के रूप में पहले शामिल था, जिसे बाद में मौलिक अधिकार (Article 21A) बना दिया गया?", "options": [ "अनुच्छेद 45", "अनुच्छेद 39A", "अनुच्छेद 46", "अनुच्छेद 42" ], "correct": 0, "explanation": "अनुच्छेद 45 मूल रूप से 14 वर्ष तक के बच्चों को निःशुल्क व अनिवार्य शिक्षा का नीति-निर्देशक तत्त्व था। बाद में 86वें संशोधन (2002) द्वारा इसे आंशिक रूप से ‘मौलिक अधिकार’ (Article 21A) बनाया गया। " }, { "question": "किस मामले में सर्वोच्च न्यायालय ने कहा कि ‘मौलिक अधिकार (Fundamental Rights) और नीति-निर्देशक तत्त्व (DPSPs) संविधान के मूल तत्व हैं, और दोनों का सामंजस्य ज़रूरी है’?", "options": [ "केशवानंद भारती केस (1973)", "मिनर्वा मिल्स केस (1980)", "गोलकनाथ केस (1967)", "बंसीलाल केस (1972)" ], "correct": 1, "explanation": "मिनर्वा मिल्स केस (1980) में सुप्रीम कोर्ट ने कहा कि भाग III (Fundamental Rights) और भाग IV (DPSPs) संविधान के मूल तत्त्व हैं। इन दोनों में संतुलन रखा जाना चाहिए।" }, { "question": "नीति-निर्देशक तत्त्वों (DPSPs) के किस वर्ग में गाँधीवादी सिद्धांत (Gandhian Principles) शामिल हैं?", "options": [ "अनुच्छेद 36-37", "अनुच्छेद 40, 43, 46, 47, 48", "अनुच्छेद 14-18", "अनुच्छेद 25-28" ], "correct": 1, "explanation": "गाँधीवादी सिद्धांतों में पंचायती राज (Article 40), कुटीर उद्योग (Article 43), पिछड़े वर्गों का विकास (Article 46), मद्य-निषेध (Article 47), पशु संरक्षण (Article 48) आदि सम्मिलित हैं। " }, { "question": "नीति-निर्देशक तत्त्व (Directive Principles) को लागू न करने पर क्या नागरिक सर्वोच्च न्यायालय (Supreme Court) या उच्च न्यायालय (High Court) में याचिका दायर कर सकते हैं?", "options": [ "हाँ, क्योंकि DPSPs न्यायिक रूप से प्रवर्तनीय हैं", "नहीं, ये गैर-न्यायिक (Non-Justiciable) हैं", "केवल राष्ट्रपति के माध्यम से संभव है", "संघीय न्यायालय में याचिका संभव है" ], "correct": 1, "explanation": "DPSPs गैर-न्यायिक (Non-Justiciable) हैं, अतः इन्हें लागू न करने पर अदालत में याचिका नहीं की जा सकती। ये राज्य को नैतिक व संवैधानिक दिशानिर्देश देते हैं।" }, { "question": "Article 43B, जो सहकारी संस्थाओं (Cooperative Societies) के संवर्धन की बात करता है, किस संशोधन (Amendment) से जोड़ा गया?", "options": [ "42वाँ संशोधन", "44वाँ संशोधन", "97वाँ संशोधन", "86वाँ संशोधन" ], "correct": 2, "explanation": "97वें संवैधानिक संशोधन (2011) द्वारा भाग IX-B जोड़ा गया, जिसमें सहकारी संस्थाओं से संबंधित प्रावधान हैं, और इसी संदर्भ में अनुच्छेद 43B भी जोड़ा गया। " }, { "question": "नीति-निर्देशक तत्त्वों का मुख्य उद्देश्य क्या है?", "options": [ "राज्य को पूर्ण स्वतंत्रता देना कि वो कुछ भी करे", "राज्य को नागरिकों का शोषण करने की छूट", "कल्याणकारी राज्य (Welfare State) की स्थापना के लिए मार्गदर्शन", "धार्मिक संस्थाओं को निष्क्रिय बनाना" ], "correct": 2, "explanation": "DPSPs का ध्येय समाजवाद, सामाजिक-आर्थिक न्याय, समानता और कल्याणकारी राज्य की स्थापना में सहायता करना है।" }, { "question": "कौन-सा अनुच्छेद (Article) कहता है कि राज्य अपने अंतर्राष्ट्रीय दायित्वों (International Obligations) के अनुसार नियम बना सकता है, विशेषकर समझौतों (Treaties) का सम्मान करना?", "options": [ "अनुच्छेद 48", "अनुच्छेद 51", "अनुच्छेद 46", "अनुच्छेद 49" ], "correct": 1, "explanation": "अनुच्छेद 51 राज्य को अंतर्राष्ट्रीय शांति और सुरक्षा को बढ़ावा देने के लिए प्रोत्साहित करता है, तथा अंतर्राष्ट्रीय कानूनों व संधियों (Treaties) का सम्मान करने की सलाह देता है।" }, { "question": "अनुच्छेद 46 (Article 46) किस वर्ग के कल्याण पर विशेष बल देता है?", "options": [ "महिलाओं और बच्चों", "अल्पसंख्यक समुदायों", "अनुसूचित जातियों (SC) और अनुसूचित जनजातियों (ST)", "विकलांग व्यक्तियों (Persons with Disabilities)" ], "correct": 2, "explanation": "अनुच्छेद 46 राज्य से अपेक्षा करता है कि वह अनुसूचित जातियों और अनुसूचित जनजातियों के शैक्षणिक व आर्थिक हितों की रक्षा करे, तथा उनका शोषण न होने दे। " }, { "question": "कौन-सा कथन सही है: ‘अनुच्छेद 38(2) ...’", "options": [ "समाज के सभी क्षेत्रों में असमानताओं (Inequalities) को कम करने के लिए राज्य को निर्देश देता है", "न्यायिक पुनरावलोकन (Judicial Review) का अधिकार देता है", "मौलिक अधिकारों को निलंबित करने की शक्ति देता है", "अल्पसंख्यकों को शिक्षण संस्थाएँ स्थापित करने का अधिकार" ], "correct": 0, "explanation": "अनुच्छेद 38(2) (44वें संशोधन के बाद) स्पष्ट करता है कि राज्य समाज के सभी संस्थागत, समूहिक, क्षेत्रीय व अन्य असमानताओं को कम करने का प्रयास करेगा।" }, { "question": "नीति-निर्देशक तत्त्वों को लागू करने के संबंध में निम्न में से कौन-सा महत्त्वपूर्ण उदाहरण भारत में देखा जा सकता है?", "options": [ "मनरेगा (MGNREGA), शिक्षा का अधिकार (RTE) इत्यादि कल्याणकारी कानूनों का निर्माण", "केवल आपातकालीन प्रावधानों का प्रयोग", "विधिक सेवा प्राधिकरणों का उन्मूलन", "भ्रष्टाचार को वैधता देना" ], "correct": 0, "explanation": "MGNREGA, RTE (मुफ़्त अनिवार्य शिक्षा), खाद्य सुरक्षा अधिनियम इत्यादि कई कानून नीति-निर्देशक तत्त्वों के उद्देश्यों को साकार करने हेतु पारित हुए हैं। " } // More questions as needed... ]; let currentQuestionIndex = 0; // Track current question let userAnswers = Array(quizData.length).fill(null); // Track user's answers // Timer variables let totalQuizTime = quizData.length * 30; // total seconds = 30 seconds * no. of questions let timeLeft = totalQuizTime; let timerInterval; // On page load, initialize quiz window.onload = function() { generateQuestionNav(); // Generate the question navigation circles loadQuestion(); startTimer(); // Start the countdown }; // Start the countdown timer function startTimer() { updateTimerDisplay(timeLeft); timerInterval = setInterval(() => { timeLeft--; updateTimerDisplay(timeLeft); if (timeLeft <= 0) { clearInterval(timerInterval); showResults(); // Force show results if time is up } }, 1000); } // Update timer on the screen in mm:ss format function updateTimerDisplay(seconds) { const timerEl = document.getElementById("timer"); const mins = Math.floor(seconds / 60).toString().padStart(2, '0'); const secs = (seconds % 60).toString().padStart(2, '0'); timerEl.innerText = `Time: ${mins}:${secs}`; } // Toggle the question nav when hamburger is pressed const hamburgerBtn = document.getElementById('hamburgerBtn'); hamburgerBtn.addEventListener('click', () => { document.getElementById('questionNavOverlay').classList.toggle('show'); }); // Close hamburger menu if user clicks outside the nav and menu document.addEventListener('click', (e) => { const navOverlay = document.getElementById('questionNavOverlay'); const hamburger = document.getElementById('hamburgerBtn'); // If the menu is open, and the click is outside both the overlay and the hamburger, close it if ( navOverlay.classList.contains('show') && !navOverlay.contains(e.target) && !hamburger.contains(e.target) ) { navOverlay.classList.remove('show'); } }); // Create small clickable circles for each question function generateQuestionNav() { const navContainer = document.getElementById("questionNav"); navContainer.innerHTML = ""; // clear old items if any quizData.forEach((_, index) => { const circle = document.createElement("div"); circle.classList.add("circle-number"); circle.innerText = index + 1; // Show question number (1-based) circle.onclick = () => jumpToQuestion(index); navContainer.appendChild(circle); }); } // Jump to a specific question function jumpToQuestion(qIndex) { currentQuestionIndex = qIndex; // Hide the nav on mobile after selection document.getElementById('questionNavOverlay').classList.remove('show'); // Reset submission/next button state document.getElementById("submitAnswerButton").classList.remove("hidden"); document.getElementById("nextButton").classList.add("hidden"); loadQuestion(); } // Load current question function loadQuestion() { highlightCurrentCircle(); // Hide explanation area and Next button initially document.getElementById("explanation").classList.add("hidden"); document.getElementById("nextButton").classList.add("hidden"); const questionData = quizData[currentQuestionIndex]; document.getElementById("question").innerText = questionData.question; document.getElementById("questionCounter").innerText = `${currentQuestionIndex + 1}/${quizData.length}`; // Clear old choices const choicesContainer = document.getElementById("choices"); choicesContainer.innerHTML = ""; // Populate choices questionData.options.forEach((option, index) => { const choiceElement = document.createElement("div"); choiceElement.className = "choice"; choiceElement.innerText = option; // If previously selected, mark it if (userAnswers[currentQuestionIndex] === index) { choiceElement.classList.add("selected"); } // On clicking a choice choiceElement.onclick = () => { // Clear all selections first document.querySelectorAll(".choice").forEach(c => c.classList.remove("selected")); // Mark this one as selected choiceElement.classList.add("selected"); userAnswers[currentQuestionIndex] = index; }; choicesContainer.appendChild(choiceElement); }); // Handle Previous button visibility document.getElementById("prevButton").style.display = currentQuestionIndex === 0 ? "none" : "inline-block"; } // Highlight the current question circle function highlightCurrentCircle() { const circles = document.querySelectorAll(".circle-number"); circles.forEach((circle, idx) => { circle.classList.remove("active"); if (idx === currentQuestionIndex) { circle.classList.add("active"); } }); } // Submit the current question's answer function submitAnswer() { const questionData = quizData[currentQuestionIndex]; const userAnswer = userAnswers[currentQuestionIndex]; // Show the explanation div const explanationDiv = document.getElementById("explanation"); explanationDiv.classList.remove("hidden"); // Clear previous correctness classes and disable further selection document.querySelectorAll(".choice").forEach((c) => { c.classList.add("disabled"); c.onclick = null; }); // Determine correctness or skipping if (userAnswer === null) { explanationDiv.innerHTML = "You Skipped the question.<br/><br/>व्याख्या: " + questionData.explanation; showPopupMessage("You Skipped the question", false); } else if (userAnswer === questionData.correct) { explanationDiv.innerHTML = "You got it right!<br/><br/>व्याख्या: " + questionData.explanation; showPopupMessage("You got it right", true); // Highlight correct choice document.querySelectorAll(".choice")[userAnswer].classList.add("correct"); } else { explanationDiv.innerHTML = "You got it wrong.<br/><br/>व्याख्या: " + questionData.explanation; showPopupMessage("You got it wrong", false); // Highlight correct choice document.querySelectorAll(".choice")[questionData.correct].classList.add("correct"); // Mark the chosen one as incorrect document.querySelectorAll(".choice")[userAnswer].classList.add("incorrect"); } // Hide the submit button, show the next button document.getElementById("submitAnswerButton").classList.add("hidden"); document.getElementById("nextButton").classList.remove("hidden"); } // Go to the next question or show final results function nextQuestion() { currentQuestionIndex++; if (currentQuestionIndex >= quizData.length) { // Show results if no more questions showResults(); } else { // Reset buttons document.getElementById("submitAnswerButton").classList.remove("hidden"); document.getElementById("nextButton").classList.add("hidden"); loadQuestion(); } } // Go to the previous question function previousQuestion() { if (currentQuestionIndex > 0) { currentQuestionIndex--; document.getElementById("submitAnswerButton").classList.remove("hidden"); document.getElementById("nextButton").classList.add("hidden"); loadQuestion(); } } // Show final quiz results function showResults() { // Stop the timer if it's still running clearInterval(timerInterval); // Calculate correct answers const correctAnswersCount = userAnswers.filter( (ans, i) => ans === quizData[i].correct ).length; // Hide quiz content document.getElementById("quizContent").classList.add("hidden"); // Show results document.getElementById("resultContent").classList.remove("hidden"); const percentage = (correctAnswersCount / quizData.length) * 100; let resultHTML = ""; if (percentage >= 60) { resultHTML = `<div class="congrats">🎉 बधाई हो! आपने ${percentage.toFixed( 2 )}% स्कोर किया है!</div>`; } else { resultHTML = `<div class="sad">😢 आपने ${percentage.toFixed( 2 )}% स्कोर किया है। अगली बार के लिए शुभकामनाएं!</div>`; } document.getElementById("resultMessage").innerHTML = resultHTML; document.getElementById("scoreMessage").innerText = `आपने कुल ${quizData.length} में से ${correctAnswersCount} प्रश्न सही उत्तर दिए हैं।`; } // Optional popup message function showPopupMessage(message, isCorrect) { const popup = document.getElementById('popupMessage'); popup.innerText = message; popup.className = ''; popup.classList.add('show'); popup.classList.add(isCorrect ? 'correct' : 'incorrect'); setTimeout(() => { popup.classList.remove('show'); popup.classList.add('hidden'); }, 2000); } // Button event listeners document.getElementById('prevButton').addEventListener('click', previousQuestion); document.getElementById('submitAnswerButton').addEventListener('click', submitAnswer); document.getElementById('nextButton').addEventListener('click', nextQuestion); // Predefined Darker Color Themes const themes = [ { header: '#a31645', headerText: '#ffffff', container: '#e8c4d6', containerText: '#6e0c36', headings: '#6e0c36' }, // Berry Delight { header: '#00574b', headerText: '#ffffff', container: '#b3dfd7', containerText: '#00382e', headings: '#00382e' }, // Ocean Breeze { header: '#c95a00', headerText: '#ffffff', container: '#dca865', containerText: '#7a3400', headings: '#7a3400' }, // Sunset Glow { header: '#4a0f6f', headerText: '#ffffff', container: '#cdb5e3', containerText: '#320b4a', headings: '#320b4a' }, // Calming Lavender { header: '#1e4d2b', headerText: '#ffffff', container: '#98c1a3', containerText: '#122417', headings: '#122417' }, // Forest Retreat { header: '#c99800', headerText: '#ffffff', container: '#e8d18a', containerText: '#6c4f00', headings: '#6c4f00' }, // Golden Elegance { header: '#01477e', headerText: '#ffffff', container: '#86b9e4', containerText: '#00223d', headings: '#00223d' }, // Sky Calm { header: '#5a3b2e', headerText: '#ffffff', container: '#b8a89c', containerText: '#32211a', headings: '#32211a' }, // Retro Rust { header: '#b34727', headerText: '#ffffff', container: '#f2c29d', containerText: '#6a2915', headings: '#6a2915' }, // Warm Peach { header: '#0f4c43', headerText: '#ffffff', container: '#92c3b8', containerText: '#072822', headings: '#072822' }, // Cool Mint ]; // Apply Random Darker Theme function applyRandomTheme() { const header = document.querySelector('.header'); const container = document.querySelector('.content-container'); const headings = document.querySelectorAll('.content-container h2'); // Select a random theme const randomTheme = themes[Math.floor(Math.random() * themes.length)]; // Apply Header Colors header.style.backgroundColor = randomTheme.header; header.style.color = randomTheme.headerText; // Apply Container Colors container.style.backgroundColor = randomTheme.container; container.style.color = randomTheme.containerText; // Apply Heading Colors headings.forEach((heading) => { heading.style.color = randomTheme.headings; heading.style.borderBottom = `2px solid ${randomTheme.headings}`; }); } // Apply the theme on page load window.onload = function () { applyRandomTheme(); // Set random theme generateQuestionNav(); // Generate question navigation loadQuestion(); // Load the first question startTimer(); // Start the countdown timer }; </script> </body> </html> <!-- /wp:html -->