<!-- 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": "प्राकृतिक आपदा प्रबंधन (Natural Disaster Management) का मुख्य उद्देश्य क्या होता है?", "options": [ "केवल आपदा के बाद राहत कार्य", "आपदा को स्वीकार कर कोई कदम न उठाना", "आपदाओं से जान-माल की हानि कम करना, प्रभावित क्षेत्रों का त्वरित पुनर्वास एवं दीर्घकालीन रोकथाम के उपाय", "केवल डेटा संग्रह करना" ], "correct": 2, "explanation": "प्राकृतिक आपदा प्रबंधन का मकसद आपदा-पूर्व तैयारी, पूर्वचेतावनी, आपदा के दौरान त्वरित बचाव/राहत, और आपदा-उपरांत पुनर्वास के साथ-साथ अगले आपदा जोखिम को कम करना है।" }, { "question": "आपदा पूर्वानुमान (Disaster Prediction) का क्या महत्त्व है?", "options": [ "आपदा को बढ़ावा देना", "लोगों को अनावश्यक डराना", "सटीक पूर्वानुमान से समय रहते चेतावनी दी जा सकती है, जिससे निकासी (Evacuation) व बचाव की तैयारी कर क्षति कम हो", "केवल वैज्ञानिक उत्सुकता" ], "correct": 2, "explanation": "आपदा पूर्वानुमान से प्रशासन व आम जनता अलर्ट हो जाती है और समय पर सुरक्षित स्थानों पर पहुँचकर जान-माल की हानि कम की जा सकती है।" }, { "question": "‘आपदा राहत (Disaster Relief)’ के अंतर्गत कौन-सी गतिविधि शामिल नहीं होगी?", "options": [ "प्राथमिक चिकित्सा, भोजन-पानी उपलब्ध कराना", "बचाव दल का त्वरित संचालन", "आवश्यकतानुसार अस्थायी आश्रय (Shelter) व्यवस्था", "बुनियादी ढाँचा विकास हेतु दीर्घकालीन योजना" ], "correct": 3, "explanation": "आपदा राहत में तत्काल मदद (भोजन, दवाई, आवास) व बचाव कार्य प्रमुख हैं; दीर्घकालीन इन्फ्रास्ट्रक्चर विकास ‘पुनर्वास/पुनर्निर्माण’ के तहत आता है, जो राहत की तुलना में अगला चरण है।" }, { "question": "पुनर्वास (Rehabilitation) से क्या तात्पर्य है?", "options": [ "आपदा के पहले की स्थिति से बदतर हालात बनाए रखना", "लोगों को हमेशा अस्थायी शिविर में छोड़ देना", "आपदा-प्रभावित लोगों को स्थायी या अर्ध-स्थायी आवास, बुनियादी सेवाएँ, आजीविका साधन आदि उपलब्ध कराकर उन्हें पुनः सशक्त करना", "केवल आर्थिक सहायता" ], "correct": 2, "explanation": "पुनर्वास का अर्थ आपदा से विस्थापित व प्रभावित लोगों को स्थायी आवास, रोजगार के साधन, स्वास्थ्य सुविधाएँ, शिक्षा आदि मुहैया कराना है, ताकि वे आत्मनिर्भर बन सकें।" }, { "question": "सामुदायिक सहभागिता (Community Participation) क्यों आवश्यक है?", "options": [ "समुदाय हमेशा बाधा पैदा करता है", "आपदा प्रबंधन सिर्फ सरकारी जिम्मेदारी है", "स्थानीय लोग सबसे पहले प्रभावित होते हैं, वे क्षेत्र और संसाधनों से परिचित होते हैं; उनकी भागीदारी से राहत व पुनर्वास अधिक प्रभावी होता है", "सिर्फ औपचारिकता के लिए" ], "correct": 2, "explanation": "स्थानीय लोग भौगोलिक व सामाजिक परिस्थितियों को बेहतर समझते हैं, वे आपदा के समय प्रथम प्रतिवादी (First Responder) की भूमिका में भी होते हैं; उनकी सहभागिता से योजनाएँ ज्यादा सफल होती हैं।" }, { "question": "आपदा पूर्वानुमान में ‘रिमोट सेंसिंग उपग्रह’ का उपयोग किसलिए किया जाता है?", "options": [ "केवल संचार सेवा", "भूकंप की तीव्रता बढ़ाने", "बाढ़, चक्रवात, वनाग्नि जैसे खतरों पर नजर रखना, तस्वीरों/डेटा के जरिए आने वाली आपदा की चेतावनी", "आर्थिक सर्वेक्षण" ], "correct": 2, "explanation": "रिमोट सेंसिंग सैटेलाइट धरती की सतह, बादल, समुद्री-तापमान आदि की जानकारी देता है, जिससे बाढ़, चक्रवात, सूखा, वनाग्नि आदि का पूर्व संकेत मिल सकता है।" }, { "question": "भूकंप का पूर्वानुमान सटीक तरीके से क्यों कठिन माना जाता है?", "options": [ "भूकंप कभी आते ही नहीं", "भूकंप ज्यादातर भूगर्भीय प्लेटों की गतियों पर निर्भर हैं, जिनकी समय-स्थान पूर्वगामी गणना बेहद जटिल है", "सब कुछ आसान है", "भूकंप का जलवायु से संबंध" ], "correct": 1, "explanation": "भूकंप पृथ्वी के आंतरिक प्लेट विवर्तनिकी से जुड़े हैं, उनके सटीक समय व स्थान की भविष्यवाणी अभी भी वैज्ञानिक दृष्टि से बहुत चुनौतीपूर्ण है।" }, { "question": "चक्रवात पूर्वानुमान में मौसम विज्ञान विभाग (Meteorological Department) कौन-सा उपकरण मुख्यतः प्रयोग करता है?", "options": [ "टैप रिकॉर्डर", "भूकंपमापी", "डॉपलर रडार, उपग्रहों से प्राप्त डेटा, मौसम मॉडल", "ज्वालामुखी सेंसर" ], "correct": 2, "explanation": "चक्रवातों पर निगरानी हेतु डॉपलर रडार, उपग्रह इमेज, मरीन बुए, मौसम मॉडलिंग आदि का उपयोग किया जाता है।" }, { "question": "आपदा राहत में ‘खाद्य वितरण’ क्यों आवश्यक होता है?", "options": [ "लोग भूखे न रहें, कुपोषण व रोगों से बचा जा सके", "भोजन की जगह केवल नकद देना", "लोगों को बेघर रखना", "प्रशासन को कोई लाभ नहीं" ], "correct": 0, "explanation": "आपदा के बाद बुनियादी ढाँचा क्षतिग्रस्त होने से भोजन की आपूर्ति बाधित हो सकती है। प्रभावितों को तत्काल भोजन न मिले तो स्वास्थ्य और जान का खतरा रहता है।" }, { "question": "पुनर्वास प्रक्रिया में ‘सॉफ्ट लोन (Soft Loan)’ का उद्देश्य क्या होता है?", "options": [ "ब्याज दर बढ़ाना", "साहूकारी प्रथा का पालन", "व्यापारियों को मुनाफा पहुंचाना", "आजीविका पुनः स्थापित करने, घर बनाने, छोटे व्यवसाय के लिए पीड़ितों को रियायती दर पर ऋण" ], "correct": 3, "explanation": "आपदा पीड़ितों को दोबारा रोजगार और आवास के लिए पूँजी की जरूरत होती है; कम ब्याज दर पर कर्ज़ (Soft Loan) उनकी मदद करता है।" }, { "question": "सामुदायिक सहभागिता में ‘स्वयंसेवी संगठन (NGOs)’ की क्या भूमिका है?", "options": [ "वे कोई मदद नहीं करते", "सिर्फ आर्थिक लाभ लेना", "राहत सामग्री वितरण, लोगों को ट्रेनिंग, पुनर्वास कार्यक्रम, प्रशासन के साथ समन्वय आदि", "गाँवों को छोड़कर शहरों में काम" ], "correct": 2, "explanation": "NGOs लोकल लेवल पर सक्रिय होकर प्रभावितों को तत्काल मदद, प्रशिक्षण, सामग्री वितरण, जागरूकता और प्रशासनिक समन्वय में महत्त्वपूर्ण भूमिका निभाते हैं।" }, { "question": "आपदाओं से पहले ‘प्रशिक्षण एवं क्षमता निर्माण (Training and Capacity Building)’ क्यों किया जाता है?", "options": [ "बेकार अभ्यास", "लोग जान नहीं पाते", "आपदा आने पर लोग घबराहट में गलत फैसले लें, इससे बचने के लिए पूर्वतः ड्रिल, प्राथमिक चिकित्सा, उपकरणों का संचालन सीखना", "केवल मीडिया प्रचार" ], "correct": 2, "explanation": "यदि लोगों को प्राथमिक चिकित्सा, निकासी मार्ग, आग बुझाना, बचाव उपकरण चलाना इत्यादि आता हो, तो आपदा के समय अफ़रातफ़री कम होती है और जान-माल की हानि भी घटती है।" }, { "question": "आपदा पूर्वानुमान (Prediction) को सार्थक बनाने के लिए आवश्यक शर्त क्या है?", "options": [ "पूर्वानुमान जानकर भी कोई कार्रवाई न करना", "मीडिया को रोकना", "पूर्वचेतावनी तंत्र का विकास, चेतावनी संदेशों का प्रसार, प्रशासन व जनता द्वारा त्वरित प्रतिक्रिया", "पूर्वानुमान को गुप्त रखना" ], "correct": 2, "explanation": "केवल वैज्ञानिक पूर्वानुमान कर देना काफी नहीं, उसे लोगों तक पहुँचाना और तुरंत एहतियाती कदम उठाना भी जरूरी है, तभी पूर्वानुमान का वास्तविक लाभ मिलता है।" }, { "question": "आपदा राहत शिविरों (Relief Camps) में स्वास्थ्य एवं स्वच्छता की व्यवस्था क्यों अहम है?", "options": [ "लोग अस्वस्थ रह सकते हैं", "बीमारियाँ तेजी से फैल सकती हैं, गंदगी से महामारी का खतरा, इसलिए साफ पानी, शौचालय, स्वच्छ भोजन अनिवार्य", "केवल नाममात्र सुविधा", "स्वच्छता से कोई असर नहीं" ], "correct": 1, "explanation": "बड़े पैमाने पर विस्थापित लोगों के शिविरों में यदि सफाई व स्वास्थ्य सुविधाएँ नहीं होंगी, तो संक्रमण व बीमारियाँ फैल सकती हैं, जिससे नुकसान और बढ़ सकता है।" }, { "question": "आपदा पुनर्वास में ‘नकद सहायता (Cash Assistance)’ का लाभ क्या हो सकता है?", "options": [ "केवल भ्रष्टाचार", "लोग अपनी प्राथमिकताओं के अनुरूप खरीद सकते हैं, स्थानीय अर्थव्यवस्था में भी धन का प्रवाह होता है", "शोषण बढ़ना", "किसी भी रूप में बेकार" ], "correct": 1, "explanation": "नकद सहायता से जरूरतमंद तत्काल अपनी आवश्यकतानुसार वस्तुएँ खरीद सकते हैं; इससे आर्थिक गतिविधियाँ फिर से पटरी पर आती हैं।" }, { "question": "सामुदायिक सहभागिता में ‘गाँव स्तर पर आपदा प्रबंधन समिति (Village Disaster Management Committee)’ का कार्य क्या होगा?", "options": [ "पंचायती राज रोकना", "फसल उत्पादन", "आपदा पूर्व तैयारी, जोखिम आँकलन, बचाव योजना बनाना, आपदा के समय नेतृत्व व समन्वय", "सिर्फ चंदा इकट्ठा करना" ], "correct": 2, "explanation": "गाँव स्तर पर बनी आपदा प्रबंधन समिति स्थानीय लोगों को जागरूक करती है, निकासी योजना बनाती है, आपदा आने पर बचाव व राहत कार्य को संगठित करती है।" }, { "question": "भूकंप संभावित क्षेत्रों में कौन-सा संरचनात्मक उपाय आपदा जोखिम कम करता है?", "options": [ "मजबूत, लचीली नींव, भूकंपरोधी बिल्डिंग कोड का पालन", "कोई भवन कोड न रखना", "बहुत ऊँची इमारतें बनाना", "निर्माण में घटिया सामग्री" ], "correct": 0, "explanation": "भूकंपरोधी डिजाइन, बेहतर निर्माण सामग्री व गुणवत्ता, बिल्डिंग कोड का पालन करने से इमारतें झटके झेलने में सक्षम होती हैं, और जानमाल की हानि घटती है।" }, { "question": "बाढ़ संभावित क्षेत्रों में रहने वाले समुदायों के लिए क्या सलाह उपयुक्त है?", "options": [ "कभी भी ऊँची जगह न चुनना", "नदियों में कचरा फेंकना", "भंडारण के लिए ऊँचे स्थान पर खाद्य-पानी, महत्त्वपूर्ण दस्तावेज सील पैक करना, संचार साधन तैयार रखना", "बाँधों को तोड़ देना" ], "correct": 2, "explanation": "बाढ़ से बचाव हेतु उचित तैयारी—भोजन, पानी, दस्तावेज़, दवाएँ, बैटरी, रेडियो आदि ऊँची जगह पर रखना, आपात संपर्क सूची तैयार रखना, सरकारी चेतावनी का पालन करना—उपयोगी होता है।" }, { "question": "आपदा पश्चात पुनर्निर्माण (Reconstruction) में सतत विकास कैसे संभव है?", "options": [ "अनियंत्रित निर्माण दोबारा", "पुरानी कमियों को ज्यों का त्यों रखना", "इन्फ्रास्ट्रक्चर को आपदा-रोधी मानकों के साथ पुनर्स्थापित करना, पर्यावरणीय चिंताओं को शामिल करना", "सिर्फ अस्थायी शेल्टर बनाना" ], "correct": 2, "explanation": "आपदा के बाद पुनर्निर्माण को मौका मानकर अगर बेहतर योजनाबद्ध, आपदा-रोधी, पर्यावरणसम्मत संरचनाएँ बनाई जाएँ, तो भविष्य के जोखिम व नुकसान को काफी कम किया जा सकता है।" }, { "question": "आपदा प्रबंधन में ‘बीमा (Insurance)’ का क्या महत्त्व है?", "options": [ "केवल अमीरों के लिए", "प्राकृतिक आपदाओं से होने वाला नुकसान कुछ हद तक आर्थिक रूप से कवर हो सके, लोग पुनर्निर्माण जल्दी कर सकें", "मुनाफ़ा कमाना", "बीमा से आपदा रुक जाती है" ], "correct": 1, "explanation": "बीमा योजना से यदि घर, फसल, व्यवसाय आपदा में क्षतिग्रस्त हो जाए तो मालिक को क्लेम मिल सकता है, जिससे वह पुनर्निर्माण में सक्षम होता है।" } // 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 -->