MCQ Quiz /* 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; } MCQs Quiz Questions 1/3 Time: 00:00 Loading question... Previous Submit Answer Next Quiz Completed /***** JavaScript Code *****/ // Quiz data (sample) const quizData = [ { "question": "अनुच्छेद (Article) 12 के अनुसार 'राज्य (State)' की परिभाषा में निम्न में से कौन शामिल नहीं है?", "options": [ "संसद (Parliament) और राज्य विधानसभाएँ (State Legislatures)", "भारत सरकार (Government of India) और राज्य सरकारें", "स्थानीय प्राधिकरण (Local Authorities) जैसे पंचायती राज (Panchayati Raj)", "निजी क्षेत्र की कंपनियाँ (Private Companies)" ], "correct": 3, "explanation": "अनुच्छेद 12 में 'राज्य' की परिभाषा के अंतर्गत केंद्र सरकार, राज्य सरकारें, संसद, राज्य विधानसभाएँ तथा स्थानीय प्राधिकरण आते हैं। निजी कंपनियों (Private Companies) को 'राज्य' की श्रेणी में शामिल नहीं किया गया है। " }, { "question": "मौलिक अधिकारों (Fundamental Rights) का प्रवर्तन करने के लिए अनुच्छेद 32 को किस नाम से जाना जाता है?", "options": [ "संविधान का प्रस्तावना (Preamble)", "संविधान की आत्मा (Soul of the Constitution)", "संसद की सर्वोच्चता (Parliamentary Supremacy)", "राज्य नीति के निदेशक तत्त्व (Directive Principles)" ], "correct": 1, "explanation": "अनुच्छेद 32 को डॉ. बी.आर. आंबेडकर ने 'संविधान की आत्मा (Heart and Soul of the Constitution)' कहा था, क्योंकि यह नागरिकों को अपने मौलिक अधिकारों की रक्षा के लिए सर्वोच्च न्यायालय (Supreme Court) जाने का अधिकार देता है। " }, { "question": "अनुच्छेद 14 (Article 14) में वर्णित समानता का अधिकार (Right to Equality) निम्न में से कौन-सा सिद्धांत स्थापित करता है?", "options": [ "कानून के समक्ष समानता (Equality before Law)", "राज्य द्वारा धार्मिक शिक्षा का प्रसार", "न्यायिक पुनरावलोकन (Judicial Review)", "संसद का कानून बनाने का विशेषाधिकार" ], "correct": 0, "explanation": "अनुच्छेद 14 दो प्रमुख अवधारणाओं पर आधारित है: (1) कानून के समक्ष समानता (Equality before Law), (2) विधि का समान संरक्षण (Equal Protection of Laws)। यह प्रावधान भेदभावरहित न्याय का आधार है। " }, { "question": "अनुच्छेद 19 (Article 19) में प्रदत्त कुछ स्वतंत्रताएँ (Freedoms) निम्नलिखित में से किसके लिए उपलब्ध हैं?", "options": [ "केवल नागरिकों (Citizens) के लिए", "सभी व्यक्तियों (All Persons) के लिए", "विदेशी नागरिकों के लिए", "राज्य सभा के सदस्यों के लिए विशेष रूप से" ], "correct": 0, "explanation": "अनुच्छेद 19 की छह स्वतंत्रताएँ केवल भारतीय नागरिकों (Citizens) को प्रदान की गई हैं; इनमें अभिव्यक्ति की स्वतंत्रता (Freedom of Speech), शांतिपूर्ण एकत्रीकरण (Peaceful Assembly), संगम (Association), स्थानांतरण (Movement), निवास (Residence), और व्यवसाय-व्यापार (Profession) शामिल हैं।" }, { "question": "अनुच्छेद 20 (Article 20) में दिए गए संरक्षण निम्न में से किससे संबंधित हैं?", "options": [ "धार्मिक स्वतंत्रता (Freedom of Religion)", "जीवन और व्यक्तिगत स्वतंत्रता का संरक्षण (Protection of Life and Personal Liberty)", "दोषसिद्धि (Conviction) से संबंधित संरक्षण (Protection in Respect of Conviction for Offences)", "शिक्षा का अधिकार (Right to Education)" ], "correct": 2, "explanation": "अनुच्छेद 20 आपराधिक मामलों में कुछ निश्चित सुरक्षा प्रदान करता है, जैसे दोहरे अभ्यारोपण से मुक्ति (Double Jeopardy), प्रतिकूल साक्ष्य न देने का अधिकार (Self-incrimination) इत्यादि।" }, { "question": "गोपनीयता का अधिकार (Right to Privacy) को किस ऐतिहासिक निर्णय के द्वारा मौलिक अधिकार का अंग माना गया?", "options": [ "केशवानंद भारती बनाम केरल राज्य (1973)", "गोलकनाथ बनाम पंजाब राज्य (1967)", "पुट्टास्वामी बनाम भारत संघ (2017)", "शंकरप्रसाद बनाम भारत संघ (1951)" ], "correct": 2, "explanation": "2017 में पुट्टास्वामी (Puttaswamy) केस में सर्वोच्च न्यायालय ने गोपनीयता (Privacy) को अनुच्छेद 21 के अंतर्गत 'जीवन और व्यक्तिगत स्वतंत्रता' का ही विस्तार मानते हुए मौलिक अधिकार घोषित किया।" }, { "question": "मौलिक अधिकारों को लागू कराने के लिए सर्वोच्च न्यायालय (Supreme Court) और उच्च न्यायालयों (High Courts) को रिट्स (Writs) जारी करने की शक्ति किस अनुच्छेद के तहत प्राप्त है?", "options": [ "अनुच्छेद 214", "अनुच्छेद 32 और 226", "अनुच्छेद 44", "अनुच्छेद 80" ], "correct": 1, "explanation": "सर्वोच्च न्यायालय अनुच्छेद 32 और उच्च न्यायालय अनुच्छेद 226 के तहत रिट जारी कर सकते हैं (Habeas Corpus, Mandamus, Prohibition, Certiorari, Quo Warranto) ताकि मौलिक अधिकारों का प्रवर्तन सुनिश्चित किया जा सके।" }, { "question": "मौलिक अधिकारों को निलंबित (Suspend) करने का प्रावधान किस अनुच्छेद में विशेष रूप से वर्णित है?", "options": [ "अनुच्छेद 359", "अनुच्छेद 368", "अनुच्छेद 312", "अनुच्छेद 351" ], "correct": 0, "explanation": "राष्ट्रपति को राष्ट्रीय आपातकाल (Article 352) घोषित करने पर अनुच्छेद 359 के तहत कुछ मौलिक अधिकारों के प्रवर्तन को निलंबित करने का अधिकार है। हालाँकि अनुच्छेद 20 और 21 के अधिकार निलंबित नहीं किए जा सकते। " }, { "question": "धार्मिक स्वतंत्रता (Freedom of Religion) से संबंधित मौलिक अधिकार किन अनुच्छेदों (Articles) में वर्णित हैं?", "options": [ "अनुच्छेद 25 से 28", "अनुच्छेद 19 से 22", "अनुच्छेद 14 से 18", "अनुच्छेद 29 से 30" ], "correct": 0, "explanation": "अनुच्छेद 25 से 28 तक विभिन्न धार्मिक स्वतंत्रताओं जैसे आस्था, पूजा, धार्मिक संस्थाओं के संचालन इत्यादि के अधिकारों की चर्चा है।" }, { "question": "दल-बदल (Defection) निरोधक कानून के तहत विधायक या सांसद का मौलिक अधिकारों पर कौन-सा प्रभाव पड़ता है?", "options": [ "उनके भाषण की स्वतंत्रता (Freedom of Speech) सीमित हो सकती है", "नागरिकता समाप्त हो जाती है", "उनके निर्वाचक मंडल (Electorate) को भंग कर दिया जाता है", "कोई प्रभाव नहीं पड़ता" ], "correct": 0, "explanation": "दल-बदल निरोधक कानून (10वीं अनुसूची) के तहत दलीय ह्विप (Whip) उल्लंघन आदि के कारण सदन से अयोग्य घोषित होने की स्थिति बन सकती है, जिससे उनकी ‘भाषण की स्वतंत्रता’ पर भी व्यावहारिक सीमाएं आ जाती हैं। हालाँकि यह प्रत्यक्षतः मौलिक अधिकारों को निलंबित नहीं करता, परंतु व्यवहार में दायरा सीमित करता है। " }, { "question": "अनुच्छेद 21A (Article 21A) जोड़ा गया था, जो किस मौलिक अधिकार से संबंधित है?", "options": [ "किसी धर्म का प्रचार-प्रसार (Propagation of Religion)", "मुफ़्त और अनिवार्य शिक्षा का अधिकार (Right to Free and Compulsory Education)", "अल्पसंख्यकों के सांस्कृतिक अधिकार (Minority Cultural Rights)", "संपत्ति का अधिकार (Right to Property)" ], "correct": 1, "explanation": "86वें संशोधन (2002) के द्वारा अनुच्छेद 21A सम्मिलित किया गया, जिसके तहत 6-14 वर्ष आयु के बच्चों को निःशुल्क व अनिवार्य शिक्षा का अधिकार मौलिक अधिकार बना। " }, { "question": "अनुच्छेद 23 (Article 23) और 24 (Article 24) किन शोषणों के विरुद्ध सुरक्षा प्रदान करते हैं?", "options": [ "जातिगत भेदभाव और छुआछूत", "धार्मिक भेदभाव और अल्पसंख्यक उत्पीड़न", "मानव तस्करी (Human Trafficking) और बाल श्रम (Child Labour)", "भ्रष्टाचार और घूसखोरी" ], "correct": 2, "explanation": "अनुच्छेद 23 मानव तस्करी, बेगारी (Begaar) आदि के विरुद्ध सुरक्षा देता है, जबकि अनुच्छेद 24 14 वर्ष से कम आयु के बच्चों को कारखानों या खतरनाक उद्योगों में काम कराने पर रोक लगाता है। " }, { "question": "सांस्कृतिक और शैक्षिक अधिकार (Cultural and Educational Rights) किन अनुच्छेदों में वर्णित हैं?", "options": [ "अनुच्छेद 19-22", "अनुच्छेद 29-30", "अनुच्छेद 25-28", "अनुच्छेद 31-32" ], "correct": 1, "explanation": "अनुच्छेद 29 (अल्पसंख्यक समूहों की संस्कृति की सुरक्षा) और अनुच्छेद 30 (अल्पसंख्यकों को शिक्षण संस्थाएँ स्थापित करने का अधिकार) सांस्कृतिक एवं शैक्षिक अधिकारों को परिभाषित करते हैं। " }, { "question": "मौलिक अधिकारों का 'नियंत्रित (Controlled)' स्वरूप किस तरह प्रदर्शित होता है?", "options": [ "क्योंकि इन्हें संशोधित नहीं किया जा सकता", "क्योंकि ये कभी भी रद्द किए जा सकते हैं", "क्योंकि उचित प्रतिबंध (Reasonable Restrictions) लगाए जा सकते हैं", "कोई प्रतिबंध नहीं है" ], "correct": 2, "explanation": "मौलिक अधिकार पूर्णतः निरंकुश नहीं हैं; संविधान में 'उचित प्रतिबंध (Reasonable Restrictions)' का प्रावधान है ताकि सामाजिक व्यवस्था व अन्य हितों को सुरक्षित रखा जा सके। " }, { "question": "अनुच्छेद 15 (Article 15) के अंतर्गत राज्य निम्नलिखित आधारों पर भेदभाव नहीं कर सकता। इन आधारों में से कौन-सा विकल्प सही नहीं है?", "options": [ "धर्म (Religion)", "जाति (Caste)", "लिंग (Sex)", "आर्थिक स्थिति (Economic Status)" ], "correct": 3, "explanation": "अनुच्छेद 15 में धर्म, मूलवंश, जाति, लिंग या जन्मस्थान के आधार पर विभेद वर्जित है। यद्यपि 'आर्थिक स्थिति' (Economic Status) को अनुच्छेद 15 में प्रत्यक्षतः उल्लिखित नहीं किया गया है।" }, { "question": "यदि किसी व्यक्ति का मौलिक अधिकार (Fundamental Right) राज्य द्वारा उल्लंघित (Violated) होता है, तो वह किस न्यायालय में सीधे रिट याचिका (Writ Petition) दायर कर सकता है?", "options": [ "केवल जिला न्यायालय (District Court)", "केवल सत्र न्यायालय (Sessions Court)", "उच्च न्यायालय (High Court) या सर्वोच्च न्यायालय (Supreme Court)", "लोक अदालत (Lok Adalat)" ], "correct": 2, "explanation": "मौलिक अधिकारों के उल्लंघन पर व्यक्ति सीधे उच्च न्यायालय (अनुच्छेद 226) या सर्वोच्च न्यायालय (अनुच्छेद 32) में रिट याचिका दायर कर सकता है। " }, { "question": "मौलिक अधिकारों का संरक्षण करने के लिए जारी होने वाली ‘Habeas Corpus’ रिट का क्या उद्देश्य है?", "options": [ "ग़ैर-कानूनी हिरासत (Illegal Detention) से मुक्ति दिलाना", "शासकीय अधिकारियों को आदेश देना (Mandamus)", "अधिकरणों (Tribunals) की शक्तियों को निरस्त करना (Quo Warranto)", "सरकारी आदेशों को रोकना (Prohibition)" ], "correct": 0, "explanation": "Habeas Corpus का शाब्दिक अर्थ है “तुम्हारे शरीर को प्रस्तुत करो (Produce the body)”; यदि कोई व्यक्ति अवैध रूप से हिरासत में है, तो इस रिट के माध्यम से उसकी रिहाई सुनिश्चित की जाती है।" }, { "question": "अनुच्छेद 21 (Article 21) में ‘जीवन (Life)’ शब्द का अर्थ सुप्रीम कोर्ट ने किस रूप में परिभाषित किया है?", "options": [ "केवल भौतिक अस्तित्व (Physical Existence)", "केवल जन्म से मृत्यु तक श्वसन (Breathing) की क्रिया", "गरिमापूर्ण जीवन (Dignified Life) और उसकी तमाम आवश्यकताएँ", "इसका कोई स्पष्ट अर्थ नहीं है" ], "correct": 2, "explanation": "सर्वोच्च न्यायालय ने अनेक फैसलों (जैसे मनिका गांधी केस, पुट्टास्वामी केस) में स्पष्ट किया कि अनुच्छेद 21 के तहत ‘जीवन’ का अर्थ महज़ भौतिक अस्तित्व नहीं, बल्कि गरिमापूर्ण (Dignified) जीवन की शर्तों को भी समेटता है।" }, { "question": "भारतीय संविधान का कौन-सा अनुच्छेद कहता है कि ‘मौलिक अधिकारों का कोई भी प्रवर्तन (Enforcement) अध्यादेश (Ordinance) द्वारा निलंबित नहीं किया जा सकता, यदि वह अनुच्छेद 20 या 21 से संबंधित है’?", "options": [ "अनुच्छेद 358", "अनुच्छेद 359 ख", "अनुच्छेद 368 ख", "अनुच्छेद 32 (4)" ], "correct": 1, "explanation": "अनुच्छेद 359(1) के उपबंधों में 44वें संशोधन (1978) के बाद यह प्रावधान किया गया कि अनुच्छेद 20 या 21 के अधिकार आपातकाल के दौरान भी निलंबित नहीं किए जा सकते। इसे कभी-कभी 359 ख या क्लॉज़ (1-A) भी कहा जाता है। " }, { "question": "सर्वोच्च न्यायालय ने किस केस में कहा था कि ‘मौलिक अधिकारों और नीति-निर्देशक तत्त्वों को एक-दूसरे के विरोध में नहीं देखा जाना चाहिए, बल्कि इन्हें सामंजस्यपूर्ण तरीके से लागू करना चाहिए’?", "options": [ "मिनर्वा मिल्स केस (1980)", "गोलकनाथ केस (1967)", "केशवानंद भारती केस (1973)", "पुट्टास्वामी केस (2017)" ], "correct": 0, "explanation": "मिनर्वा मिल्स मामले (1980) में सर्वोच्च न्यायालय ने कहा कि मौलिक अधिकार और नीति-निर्देशक तत्त्व संविधान के अंतर्गत एक-दूसरे के पूरक हैं, न कि प्रतिद्वंदी।" }, { "question": "निम्न में से कौन-सा प्रावधान ‘समानता का अधिकार (Right to Equality)’ के अंतर्गत नहीं आता?", "options": [ "अनुच्छेद 14: कानून के समक्ष समानता", "अनुच्छेद 15: धर्म, मूलवंश, जाति, लिंग आदि के आधार पर भेदभाव निषेध", "अनुच्छेद 16: सार्वजनिक रोजगार में अवसर की समानता", "अनुच्छेद 19: भाषण और अभिव्यक्ति की स्वतंत्रता" ], "correct": 3, "explanation": "अनुच्छेद 19, भाषण एवं अभिव्यक्ति की स्वतंत्रता से संबंधित है, जो मूलतः ‘स्वतंत्रता के अधिकार (Right to Freedom)’ के दायरे में आता है, न कि समानता के अधिकार के अंतर्गत।" } // 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 };