<!-- 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": "साइबर खतरों का परिचय में, निम्नलिखित में से कौन सा साइबर हमले का प्रकार नहीं है?", "options": [ "फिशिंग (Phishing)", "डीडीओएस हमले (DDoS Attacks)", "मैलवेयर (Malware)", "भौतिक चोरी (Physical Theft)" ], "correct": 3, "explanation": "भौतिक चोरी साइबर हमलों का हिस्सा नहीं है। फिशिंग, डीडीओएस हमले और मालवेयर सभी साइबर हमलों के प्रकार हैं जो डिजिटल माध्यमों से होते हैं।" }, { "question": "एन्क्रिप्शन में 'Symmetric Key Encryption' का मुख्य गुण क्या है?", "options": [ "दोनों पक्षों के लिए अलग-अलग कुंजी का उपयोग", "एक ही कुंजी का उपयोग डेटा को एन्क्रिप्ट और डिक्रिप्ट करने के लिए", "पब्लिक और प्राइवेट कुंजी का उपयोग", "डेटा को बिना कुंजी के एन्क्रिप्ट करना" ], "correct": 1, "explanation": "Symmetric Key Encryption में एक ही कुंजी का उपयोग डेटा को एन्क्रिप्ट और डिक्रिप्ट करने के लिए किया जाता है। इसके विपरीत, asymmetric encryption में पब्लिक और प्राइवेट कुंजी का उपयोग होता है।" }, { "question": "नेटवर्क सुरक्षा में, 'Firewall' का मुख्य कार्य क्या है?", "options": [ "डेटा को स्टोर करना", "अनधिकृत एक्सेस को रोकना और नेटवर्क ट्रैफिक को नियंत्रित करना", "यूज़र इंटरफेस को स्टाइल करना", "डेटाबेस कनेक्शन को मजबूत करना" ], "correct": 1, "explanation": "Firewall का मुख्य कार्य अनधिकृत एक्सेस को रोकना और नेटवर्क ट्रैफिक को नियंत्रित करना है। यह नेटवर्क के अंदर और बाहर जाने वाले डेटा पैकेट्स की निगरानी करता है और सुरक्षा नियमों के आधार पर उन्हें अनुमति या ब्लॉक करता है।" }, { "question": "एप्लिकेशन सुरक्षा में, 'SQL Injection' हमले से बचने का सबसे प्रभावी तरीका क्या है?", "options": [ "डेटा को एन्कोड करना", "इनपुट वैलिडेशन और प्रिपेयर्ड स्टेटमेंट्स का उपयोग करना", "डेटाबेस को ऑफलाइन रखना", "यूज़र इंटरफेस को स्टाइल करना" ], "correct": 1, "explanation": "SQL Injection हमलों से बचने के लिए इनपुट वैलिडेशन और प्रिपेयर्ड स्टेटमेंट्स का उपयोग करना सबसे प्रभावी तरीका है। यह सुनिश्चित करता है कि यूज़र द्वारा प्रदान किया गया डेटा सुरक्षित रूप से हैंडल किया जाए और किसी भी हानिकारक SQL कोड को निष्क्रिय किया जाए।" }, { "question": "साइबर अपराध और कानून में, निम्नलिखित में से कौन सा भारतीय कानून साइबर अपराधों को नियंत्रित करता है?", "options": [ "भारतीय दंड संहिता (IPC)", "साइबर अपराध अधिनियम, 2000", "भारतीय ट्रेड मार्क अधिनियम", "भारतीय कॉपीराइट अधिनियम" ], "correct": 1, "explanation": "साइबर अपराध अधिनियम, 2000 (Information Technology Act, 2000) साइबर अपराधों को नियंत्रित करने के लिए बनाया गया है। यह विभिन्न प्रकार के साइबर अपराधों के लिए कानूनी प्रावधान प्रदान करता है।" }, { "question": "सुरक्षा नीतियाँ और प्रथाएँ में, 'Least Privilege' का क्या अर्थ है?", "options": [ "उपयोगकर्ताओं को अधिकतम अधिकार प्रदान करना", "उपयोगकर्ताओं को न्यूनतम आवश्यक अधिकार प्रदान करना", "सभी उपयोगकर्ताओं को समान अधिकार देना", "सिस्टम के सभी हिस्सों को खुला रखना" ], "correct": 1, "explanation": "'Least Privilege' सिद्धांत के अनुसार, उपयोगकर्ताओं को उनके कार्यों को पूरा करने के लिए केवल न्यूनतम आवश्यक अधिकार प्रदान किए जाते हैं। इससे अनधिकृत एक्सेस और संभावित सुरक्षा जोखिम कम होते हैं।" }, { "question": "एन्क्रिप्शन में, 'Public Key Infrastructure (PKI)' किसके लिए उपयोग किया जाता है?", "options": [ "डेटा को स्टोर करने के लिए", "स्ट्रॉंग पासवर्ड बनाने के लिए", "डिजिटल सिग्नेचर और एन्क्रिप्शन के लिए पब्लिक और प्राइवेट कुंजियों का प्रबंधन", "यूज़र इंटरफेस को स्टाइल करने के लिए" ], "correct": 2, "explanation": "Public Key Infrastructure (PKI) का उपयोग डिजिटल सिग्नेचर और एन्क्रिप्शन के लिए पब्लिक और प्राइवेट कुंजियों का प्रबंधन करने के लिए किया जाता है। यह सुरक्षित संचार और प्रमाणीकरण को सक्षम बनाता है।" }, { "question": "नेटवर्क सुरक्षा में, 'VPN' का मुख्य उद्देश्य क्या है?", "options": [ "डेटा को स्टोर करना", "सार्वजनिक नेटवर्क पर सुरक्षित और निजी कनेक्शन प्रदान करना", "यूज़र इंटरफेस को स्टाइल करना", "डेटाबेस कनेक्शन को मजबूत करना" ], "correct": 1, "explanation": "VPN (Virtual Private Network) का मुख्य उद्देश्य सार्वजनिक नेटवर्क पर सुरक्षित और निजी कनेक्शन प्रदान करना है। यह डेटा को एन्क्रिप्ट करता है और यूज़र के इंटरनेट ट्रैफिक को सुरक्षित बनाता है।" }, { "question": "एप्लिकेशन सुरक्षा में, 'Cross-Site Request Forgery (CSRF)' हमले से बचने का तरीका क्या है?", "options": [ "डेटा को एन्कोड करना", "CSRF टोकन का उपयोग करना", "पैकेज मैनेजर का उपयोग करना", "यूज़र इंटरफेस को स्टाइल करना" ], "correct": 1, "explanation": "Cross-Site Request Forgery (CSRF) हमले से बचने के लिए CSRF टोकन का उपयोग किया जाता है। यह टोकन प्रत्येक सुरक्षित अनुरोध के साथ भेजा जाता है और सर्वर पर सत्यापित किया जाता है, जिससे अवांछित अनुरोधों को रोका जा सकता है।" }, { "question": "साइबर अपराध और कानून में, 'Hacker' का कौन सा प्रकार नैतिक है?", "options": [ "Black Hat Hackers", "White Hat Hackers", "Grey Hat Hackers", "Script Kiddies" ], "correct": 1, "explanation": "White Hat Hackers नैतिक होते हैं और सुरक्षा जांच, कमजोरियों की पहचान करने, और सिस्टम की सुरक्षा को मजबूत करने के लिए काम करते हैं। वे कानूनी और नैतिक मानदंडों का पालन करते हैं।" }, { "question": "सुरक्षा नीतियाँ और प्रथाएँ में, 'Incident Response Plan' का क्या उद्देश्य है?", "options": [ "सिस्टम की गति बढ़ाना", "साइबर हमलों के दौरान त्वरित और प्रभावी प्रतिक्रिया सुनिश्चित करना", "यूज़र इंटरफेस को स्टाइल करना", "डेटाबेस कनेक्शन को मजबूत करना" ], "correct": 1, "explanation": "'Incident Response Plan' का उद्देश्य साइबर हमलों या सुरक्षा घटनाओं के दौरान त्वरित और प्रभावी प्रतिक्रिया सुनिश्चित करना है। यह घटनाओं की पहचान, प्रतिक्रिया, पुनर्प्राप्ति, और रिपोर्टिंग के लिए प्रक्रियाएँ निर्धारित करता है।" }, { "question": "एन्क्रिप्शन में, 'AES' किसका संक्षेप है और यह किस प्रकार का एन्क्रिप्शन प्रदान करता है?", "options": [ "Advanced Encryption Standard, Symmetric Key Encryption", "Asymmetric Encryption Standard, Asymmetric Key Encryption", "Advanced Encryption System, Hashing", "Asymmetric Encryption System, Symmetric Key Encryption" ], "correct": 0, "explanation": "AES का पूरा नाम Advanced Encryption Standard है और यह Symmetric Key Encryption प्रदान करता है। यह डेटा को एन्क्रिप्ट और डिक्रिप्ट करने के लिए एक ही कुंजी का उपयोग करता है।" }, { "question": "नेटवर्क सुरक्षा में, 'IDS' का पूरा नाम क्या है और इसका कार्य क्या है?", "options": [ "Internet Data Service, डेटा ट्रांसफर करना", "Intrusion Detection System, नेटवर्क में अनधिकृत गतिविधियों की पहचान करना", "Internal Data Storage, डेटा स्टोर करना", "Internet Download Service, डेटा डाउनलोड करना" ], "correct": 1, "explanation": "IDS का पूरा नाम Intrusion Detection System है और इसका मुख्य कार्य नेटवर्क में अनधिकृत गतिविधियों या हमलों की पहचान करना है। यह संभावित सुरक्षा खतरों का पता लगाने में मदद करता है।" }, { "question": "एप्लिकेशन सुरक्षा में, 'Input Validation' का क्या महत्व है?", "options": [ "डेटा को एन्कोड करना", "सही और सुरक्षित डेटा सुनिश्चित करना ताकि हमले की संभावना कम हो", "यूज़र इंटरफेस को स्टाइल करना", "डेटाबेस कनेक्शन को मजबूत करना" ], "correct": 1, "explanation": "Input Validation का महत्व यह है कि यह सुनिश्चित करता है कि उपयोगकर्ता द्वारा प्रदान किया गया डेटा सही और सुरक्षित हो। यह संभावित हानिकारक डेटा को फ़िल्टर करने में मदद करता है, जिससे हमलों की संभावना कम हो जाती है।" }, { "question": "साइबर अपराध और कानून में, निम्नलिखित में से कौन सा अपराध साइबर स्पेस में किया जाता है?", "options": [ "फिजिकल चोरी", "डेटा ब्रीच", "हॉर्स ट्रेडिंग", "सड़क दुर्घटना" ], "correct": 1, "explanation": "डेटा ब्रीच साइबर स्पेस में किया जाने वाला अपराध है, जिसमें संवेदनशील डेटा को अवैध रूप से एक्सेस या चोरी किया जाता है। फिजिकल चोरी, हॉर्स ट्रेडिंग, और सड़क दुर्घटना पारंपरिक अपराध हैं।" }, { "question": "सुरक्षा नीतियाँ और प्रथाएँ में, 'Defense in Depth' का क्या मतलब है?", "options": [ "सिर्फ एक सुरक्षा परत का उपयोग करना", "कई सुरक्षा परतों का उपयोग करके सुरक्षा को मजबूत करना", "सिस्टम को धीमा करना", "यूज़र इंटरफेस को स्टाइल करना" ], "correct": 1, "explanation": "'Defense in Depth' का मतलब है कई सुरक्षा परतों का उपयोग करके सुरक्षा को मजबूत करना। इससे किसी एक परत में विफलता होने पर भी अन्य परतें सुरक्षा प्रदान करती हैं।" }, { "question": "एन्क्रिप्शन में, 'RSA' किसका संक्षेप है और यह किस प्रकार का एन्क्रिप्शन प्रदान करता है?", "options": [ "Rivest–Shamir–Adleman, Asymmetric Key Encryption", "Random Secure Algorithm, Symmetric Key Encryption", "Reverse Secure Algorithm, Hashing", "Rivest–Shamir–Adleman, Symmetric Key Encryption" ], "correct": 0, "explanation": "RSA का पूरा नाम Rivest–Shamir–Adleman है और यह Asymmetric Key Encryption प्रदान करता है। इसमें पब्लिक और प्राइवेट कुंजी का उपयोग होता है, जिससे सुरक्षित संचार संभव होता है।" }, { "question": "नेटवर्क सुरक्षा में, 'SSL/TLS' का मुख्य कार्य क्या है?", "options": [ "डेटा को स्टोर करना", "सुरक्षित और एन्क्रिप्टेड कनेक्शन प्रदान करना", "यूज़र इंटरफेस को स्टाइल करना", "डेटाबेस कनेक्शन को मजबूत करना" ], "correct": 1, "explanation": "SSL (Secure Sockets Layer) और TLS (Transport Layer Security) का मुख्य कार्य सुरक्षित और एन्क्रिप्टेड कनेक्शन प्रदान करना है। यह डेटा ट्रांसमिशन को सुरक्षित बनाता है और डेटा की गोपनीयता सुनिश्चित करता है।" }, { "question": "एप्लिकेशन सुरक्षा में, 'OWASP Top Ten' किसका संदर्भ देता है?", "options": [ "डेटा स्टोरेज के सर्वोत्तम प्रथाएँ", "सबसे आम दस वेब एप्लिकेशन सुरक्षा जोखिम", "यूज़र इंटरफेस डिज़ाइन के सर्वोत्तम प्रथाएँ", "डेटाबेस प्रबंधन के सर्वोत्तम प्रथाएँ" ], "correct": 1, "explanation": "'OWASP Top Ten' सबसे आम दस वेब एप्लिकेशन सुरक्षा जोखिमों की सूची है, जिसे OWASP (Open Web Application Security Project) द्वारा प्रकाशित किया जाता है। यह डेवलपर्स और सुरक्षा पेशेवरों को इन जोखिमों को पहचानने और उन्हें संबोधित करने में मदद करता है।" }, { "question": "साइबर सुरक्षा में, 'Zero Trust Model' का क्या मतलब है?", "options": [ "सभी नेटवर्क ट्रैफिक को विश्वसनीय मानना", "किसी भी नेटवर्क के अंदर के उपयोगकर्ताओं और उपकरणों पर भरोसा न करना बिना सत्यापन के", "सिर्फ बाहरी खतरों से सुरक्षा करना", "नेटवर्क पर सभी उपयोगकर्ताओं को पूर्ण अधिकार देना" ], "correct": 1, "explanation": "'Zero Trust Model' का मतलब है किसी भी नेटवर्क के अंदर के उपयोगकर्ताओं और उपकरणों पर बिना सत्यापन के भरोसा न करना। इसमें हर अनुरोध को सत्यापित किया जाता है, चाहे वह नेटवर्क के अंदर हो या बाहर।" }, { "question": "एन्क्रिप्शन में, 'Hashing' का मुख्य उपयोग क्या है?", "options": [ "डेटा को एन्क्रिप्ट करना", "डेटा की एक यूनिक और फिक्स्ड-लेंथ रिप्रेजेंटेशन बनाना", "यूज़र इंटरफेस को स्टाइल करना", "डेटाबेस कनेक्शन को मजबूत करना" ], "correct": 1, "explanation": "Hashing का मुख्य उपयोग डेटा की एक यूनिक और फिक्स्ड-लेंथ रिप्रेजेंटेशन बनाना है। यह आमतौर पर पासवर्ड स्टोरेज और डेटा की सत्यता जांचने के लिए किया जाता है।" }, { "question": "नेटवर्क सुरक्षा में, 'DMZ' का पूरा नाम क्या है और इसका क्या कार्य है?", "options": [ "Demilitarized Zone, बाहरी और आंतरिक नेटवर्क के बीच एक सुरक्षित क्षेत्र बनाना", "Data Management Zone, डेटा को स्टोर करना", "Digital Marketing Zone, मार्केटिंग गतिविधियाँ करना", "Dynamic Memory Zone, मेमोरी को मैनेज करना" ], "correct": 0, "explanation": "DMZ का पूरा नाम Demilitarized Zone है और इसका कार्य बाहरी और आंतरिक नेटवर्क के बीच एक सुरक्षित क्षेत्र बनाना है। यह सार्वजनिक सेवाओं (जैसे वेब सर्वर) को आंतरिक नेटवर्क से अलग रखता है, जिससे सुरक्षा बढ़ती है।" }, { "question": "सुरक्षा नीतियाँ और प्रथाएँ में, 'Password Policy' का क्या महत्व है?", "options": [ "यूज़र इंटरफेस को स्टाइल करना", "यूज़र्स को मजबूत और सुरक्षित पासवर्ड चुनने के नियम प्रदान करना", "डेटा को स्टोर करना", "डेटाबेस कनेक्शन को मजबूत करना" ], "correct": 1, "explanation": "'Password Policy' का महत्व यह है कि यह यूज़र्स को मजबूत और सुरक्षित पासवर्ड चुनने के नियम प्रदान करता है, जिससे अकाउंट्स की सुरक्षा बढ़ती है और असुरक्षित पासवर्ड के कारण होने वाले हमलों को रोका जा सकता है।" } // 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 -->