MCQ quiz /* Basic CSS resets */ * { margin: 0; padding: 0; box-sizing: border-box; } :root { /* Default Fallback Theme Variables (light green theme) */ --theme-body-bg: #f1f8e9; --theme-main-text: #33691e; --theme-header-bg: #7cb342; --theme-header-text: #ffffff; --theme-content-container-bg: #dcedc8; --theme-quiz-container-bg: #ffffff; --theme-question-text: #33691e; /* Original theme variable */ --theme-choice-bg: #dcedc8; /* Light variant for choice bg */ --theme-choice-text: #33691e; /* Original theme variable */ --theme-choice-border: #7cb342; /* Accent border for choice */ --theme-explanation-bg: #f1f8e9; --theme-explanation-border: #7cb342; --theme-explanation-text: #33691e; --theme-headings-text: #33691e; --theme-counter-text: #7cb342; --theme-timer-text: #c62828; /* Default red for timer */ --theme-button-primary-bg: #5cb85c; --theme-button-primary-hover-bg: #4cae4c; --theme-button-warning-bg: #f0ad4e; --theme-button-warning-hover-bg: #ec971f; --theme-button-info-bg: #5bc0de; --theme-button-info-hover-bg: #46b8da; --theme-button-danger-bg: #d9534f; --theme-button-danger-hover-bg: #d43f3a; } body { font-family: Arial, sans-serif; background-color: var(--theme-body-bg); color: var(--theme-main-text); transition: background-color 0.5s, color 0.5s; } .content-container { background-color: var(--theme-content-container-bg); padding: 20px; border-radius: 10px; max-width: 800px; margin: 30px auto; box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15); position: relative; transition: background-color 0.5s; } .header { background-color: var(--theme-header-bg); color: var(--theme-header-text); text-align: center; padding: 15px 20px; border-radius: 8px; margin-bottom: 25px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); position: relative; transition: background-color 0.5s, color 0.5s; } .header h2 { margin: 0; font-size: 1.8em; } .hamburger { position: absolute; top: 50%; transform: translateY(-50%); left: 15px; z-index: 1000; width: 25px; height: 20px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; } .hamburger-line { height: 3px; background-color: var(--theme-header-text); border-radius: 2px; transition: transform 0.3s ease, opacity 0.3s ease; } .hamburger.active .hamburger-line:nth-child(1) { transform: translateY(8.5px) rotate(45deg); } .hamburger.active .hamburger-line:nth-child(2) { opacity: 0; } .hamburger.active .hamburger-line:nth-child(3) { transform: translateY(-8.5px) rotate(-45deg); } #questionNavOverlay { position: fixed; top: 0; left: -300px; width: 300px; height: 100%; background-color: #ffffff; color: var(--theme-main-text); transition: left 0.3s ease-in-out; z-index: 2000; box-shadow: 3px 0 8px rgba(0,0,0,0.2); padding: 25px; overflow-y: auto; border-right: 1px solid #e0e0e0; } #questionNavOverlay.show { left: 0; } #questionNavTitle { margin-bottom: 15px; font-weight: bold; font-size: 1.2rem; color: var(--theme-headings-text); border-bottom: 1px solid #eee; padding-bottom: 10px; } .question-nav { display: flex; flex-wrap: wrap; gap: 8px; } .circle-number { width: 35px; height: 35px; border-radius: 50%; background-color: #e0e0e0; color: #333; display: flex; justify-content: center; align-items: center; cursor: pointer; user-select: none; transition: background-color 0.2s, color 0.2s, transform 0.2s; font-weight: 500; } .circle-number:hover { background-color: #bdbdbd; transform: scale(1.1); } .circle-number.active { background-color: var(--theme-header-bg); color: var(--theme-header-text); font-weight: bold; } .circle-number.answered { background-color: var(--theme-button-primary-bg); color: white; } .circle-number.current-review { background-color: var(--theme-button-warning-bg); color: white; border: 2px solid var(--theme-button-warning-hover-bg); } .circle-number.reviewed-correct { background-color: var(--theme-button-primary-bg); color: white; } .circle-number.reviewed-incorrect { background-color: var(--theme-button-danger-bg); color: white; } .circle-number.reviewed-skipped { background-color: #BDBDBD; color: #424242; } .quiz-container { background-color: var(--theme-quiz-container-bg); border-radius: 8px; padding: 25px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12); width: 100%; margin: 0 auto; text-align: center; position: relative; } .quiz-header-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding: 10px; /* background-color: var(--theme-body-bg); Changed below */ border-radius: 6px; } .question-counter, .timer { /* Combined for shared new styles */ font-weight: bold; padding: 8px 12px; border-radius: 5px; background-color: var(--theme-choice-bg); /* Match choice background */ font-size: 0.9em; } .question-counter { color: var(--theme-counter-text); /* Original text color variable */ } .timer { color: var(--theme-timer-text); /* Original text color variable */ } .question { font-size: 1.3rem; margin-top: 10px; margin-bottom: 15px; /* Reduced margin slightly */ text-align: left; color: #1A1A1A; /* Darker question text */ line-height: 1.6; } /* New Review Status Message Styles */ .review-status-message { padding: 10px; margin-top: 0px; /* Adjusted margin */ margin-bottom: 15px; border-radius: 5px; font-weight: bold; text-align: center; font-size: 0.95em; color: var(--theme-header-text); /* Default light text, background will provide contrast */ } .review-status-message.status-correct { background-color: var(--theme-button-primary-bg); } .review-status-message.status-incorrect { background-color: var(--theme-button-danger-bg); } .review-status-message.status-skipped { background-color: #BDBDBD; color: #222222; /* Darker text for grey background */ } .choices { display: flex; flex-direction: column; gap: 12px; } .choice { padding: 15px; background-color: var(--theme-choice-bg); border: 1px solid var(--theme-choice-border); border-radius: 6px; cursor: pointer; transition: background-color 0.3s, box-shadow 0.3s, border-color 0.3s; text-align: left; color: #1A1A1A; /* Darker choice text */ } .choice:hover:not(.disabled) { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08); } .choice.selected { background-color: var(--theme-button-primary-bg) !important; color: var(--theme-header-text) !important; border-color: var(--theme-button-primary-hover-bg) !important; } .choice.correct { background-color: var(--theme-button-primary-bg) !important; border-color: var(--theme-button-primary-hover-bg) !important; color: var(--theme-header-text) !important; } .choice.incorrect { background-color: var(--theme-button-danger-bg) !important; border-color: var(--theme-button-danger-hover-bg) !important; color: var(--theme-header-text) !important; } .choice.user-selected-incorrect { background-color: var(--theme-button-danger-bg) !important; color: var(--theme-header-text) !important; border: 1px dashed var(--theme-button-danger-hover-bg) !important; } .choice.disabled { cursor: not-allowed; opacity: 0.7; } .explanation { margin-top: 25px; text-align: left; background-color: var(--theme-explanation-bg); padding: 15px; border-left: 5px solid var(--theme-explanation-border); border-radius: 5px; color: var(--theme-explanation-text); line-height: 1.6; } .buttons { display: flex; justify-content: space-between; gap: 10px; margin-top: 30px; flex-wrap: wrap; } .btn { flex-grow: 1; padding: 12px 18px; background-color: var(--theme-button-primary-bg); color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 0.9rem; text-align: center; min-width: 120px; transition: background-color 0.2s, transform 0.1s; box-shadow: 0 2px 4px rgba(0,0,0,0.1); } .btn:hover:not(.disabled) { background-color: var(--theme-button-primary-hover-bg); transform: translateY(-1px); } .btn.btn-warning { background-color: var(--theme-button-warning-bg); } .btn.btn-warning:hover:not(.disabled) { background-color: var(--theme-button-warning-hover-bg); } .btn.btn-info { background-color: var(--theme-button-info-bg); } .btn.btn-info:hover:not(.disabled) { background-color: var(--theme-button-info-hover-bg); } .btn.btn-danger { background-color: var(--theme-button-danger-bg); } .btn.btn-danger:hover:not(.disabled) { background-color: var(--theme-button-danger-hover-bg); } .btn.disabled { background-color: #cccccc; cursor: not-allowed; transform: none; box-shadow: none; } .hidden { display: none !important; } #resultContent { text-align: center; margin-top: 20px; padding: 30px; background-color: var(--theme-quiz-container-bg); border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.12); } #resultContent h3 { font-size: 1.8em; margin-bottom: 15px; color: var(--theme-headings-text); } .congrats { font-size: 1.6rem; color: var(--theme-button-primary-bg); margin-bottom: 10px; } .sad { font-size: 1.6rem; color: var(--theme-button-danger-bg); margin-bottom: 10px; } #scoreMessage { font-size: 1.1em; margin-bottom: 20px; color: var(--theme-main-text); } #popupMessage { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); color: white; padding: 12px 25px; border-radius: 6px; font-size: 1rem; z-index: 5000; display: none; box-shadow: 0 4px 10px rgba(0,0,0,0.2); opacity: 0; transition: opacity 0.3s ease, bottom 0.3s ease; } #popupMessage.show { display: block; opacity: 1; bottom: 30px; } #popupMessage.correct { background-color: var(--theme-button-primary-bg); } #popupMessage.incorrect { background-color: var(--theme-button-danger-bg); } #popupMessage.skipped { background-color: #757575; } .modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 6000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; } .modal-overlay.show { opacity: 1; visibility: visible; } .modal-content { background-color: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); text-align: center; max-width: 400px; width: 90%; transform: scale(0.9); transition: transform 0.3s ease; color: #333; } .modal-overlay.show .modal-content { transform: scale(1); } .modal-content h4 { font-size: 1.4em; margin-bottom: 15px; } .modal-content p { font-size: 1em; margin-bottom: 25px; } .modal-buttons { display: flex; justify-content: flex-end; gap: 10px; } .modal-buttons .btn { min-width: 100px; } .btn-secondary { background-color: #aaa; } .btn-secondary:hover { background-color: #999; } @media (max-width: 600px) { .content-container { margin: 10px; padding: 10px; } .header h2 { font-size: 1.4em; } .hamburger { left: 10px; width: 22px; height: 18px; } .question { font-size: 1rem; margin-bottom: 15px; } /* Adjusted margin */ .choice { padding: 10px; } .quiz-container { padding: 15px; } .review-status-message { font-size: 0.9em; padding: 8px; margin-bottom:10px;} .quiz-header-info { flex-direction: row !important; justify-content: space-between !important; align-items: center !important; gap: 8px !important; padding: 8px !important; margin-bottom: 15px !important; } .timer, .question-counter { width: auto !important; text-align: left !important; font-size: 0.8em !important; padding: 6px 8px !important; } .buttons { flex-direction: row !important; justify-content: space-between !important; flex-wrap: nowrap !important; gap: 5px !important; margin-top: 20px !important; } .btn { width: auto !important; flex-grow: 1 !important; flex-basis: 0 !important; margin-bottom: 0 !important; padding: 8px 5px !important; font-size: 0.75rem !important; min-width: 0 !important; text-align: center !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .buttons .btn:last-child { margin-bottom: 0 !important; } } Quiz Questions Overview 1/3 Time: 00:00 Loading question... Previous Next Submit Quiz Completed! Review Quiz Restart Quiz Confirm Submission Are you sure you want to submit the quiz? Cancel Submit const quizData = [ { "question": "सिंधु घाटी सभ्यता में समाज में किन विभिन्न वर्गों के मौजूद होने का संकेत मिलता है?", "options": ["केवल शासक वर्ग और श्रमिक", "शासक वर्ग, योद्धा, शिल्पकार, किसान और श्रमिक", "केवल किसान और व्यापारी", "केवल पुजारी और सैनिक"], "correct": 1, "explanation": "समाज में शासक वर्ग (पुरोहित या व्यापारी), योद्धा, शिल्पकार, किसान और श्रमिक जैसे विभिन्न वर्ग मौजूद थे।" }, { "question": "मातृदेवी की बड़ी संख्या में मूर्तियों के मिलने के आधार पर परिवार की संरचना मुख्यतः कैसी मानी जाती है?", "options": ["पितृसत्तात्मक", "मातृसत्तात्मक", "उभयसत्तात्मक", "साम्यवादी"], "correct": 1, "explanation": "मातृदेवी की बड़ी संख्या में मूर्तियों के मिलने के कारण परिवार की संरचना मुख्यतः मातृसत्तात्मक मानी जाती है।" }, { "question": "सिंधु सभ्यता के लोग मुख्यतः किस प्रकार के वस्त्र पहनते थे?", "options": ["रेशमी और चमड़े के", "सूती और ऊनी", "लिनन और जूट के", "केवल ऊनी"], "correct": 1, "explanation": "लोग सूती और ऊनी वस्त्र पहनते थे।" }, { "question": "मोहनजोदड़ो से मिली 'नर्तकी की मूर्ति' और 'दाढ़ी वाले पुरोहित' की मूर्ति किस पहलू की जानकारी देती है?", "options": ["धार्मिक विश्वास", "नगर नियोजन", "वस्त्र और आभूषण", "कृषि पद्धतियाँ"], "correct": 2, "explanation": "मोहनजोदड़ो से मिली 'नर्तकी की मूर्ति' और 'दाढ़ी वाले पुरोहित' की मूर्ति उनके वस्त्र और आभूषणों की जानकारी देती है।" }, { "question": "सिंधु सभ्यता के लोगों के मनोरंजन के साधनों में क्या शामिल नहीं था?", "options": ["शिकार", "मछली पकड़ना", "रथ दौड़", "पासे का खेल (डाइस)"], "correct": 2, "explanation": "रथ दौड़ के कोई स्पष्ट साक्ष्य नहीं मिलते हैं, जबकि शिकार, मछली पकड़ना, नृत्य, संगीत और पासे का खेल मनोरंजन के साधन थे।" }, { "question": "मृतकों को आमतौर पर कैसे दफनाया जाता था?", "options": ["जलाकर", "पानी में बहाकर", "घरों के फर्श के नीचे", "खुले मैदान में"], "correct": 2, "explanation": "मृतकों को आमतौर पर घरों के फर्श के नीचे दफनाया जाता था, अक्सर उत्तर-दक्षिण दिशा में।" }, { "question": "सिंधु सभ्यता की अर्थव्यवस्था का आधार क्या था?", "options": ["व्यापार", "पशुपालन", "कृषि", "शिल्प"], "correct": 2, "explanation": "सिंधु सभ्यता की अर्थव्यवस्था का आधार कृषि था।" }, { "question": "सिंधु सभ्यता के लोग किस फसल की खेती करने वाले पहले लोग थे?", "options": ["गेहूँ", "जौ", "चावल", "कपास"], "correct": 3, "explanation": "सिंधु सभ्यता के लोग कपास की खेती करने वाले पहले लोग थे।" }, { "question": "कालीबंगा से किस कृषि संबंधी साक्ष्य के प्रमाण मिले हैं?", "options": ["नहर सिंचाई", "जुते हुए खेत", "धान की खेती", "फलों के बागान"], "correct": 1, "explanation": "कालीबंगा से जुते हुए खेत के साक्ष्य मिले हैं।" }, { "question": "चन्हुदड़ो और लोथल किस शिल्प उद्योग के प्रमुख केंद्र थे?", "options": ["धातु कर्म", "मुहरें बनाना", "मनके बनाना", "मृदभांड"], "correct": 2, "explanation": "चन्हुदड़ो और लोथल मनके बनाने के प्रमुख केंद्र थे।" }, { "question": "मेसोपोटामिया के अभिलेखों में 'मेलुहा' का उल्लेख मिलता है, जिसे क्या माना जाता है?", "options": ["फारस क्षेत्र", "मिस्र क्षेत्र", "सिंधु क्षेत्र", "अफ्रीकी क्षेत्र"], "correct": 2, "explanation": "मेसोपोटामिया के अभिलेखों में 'मेलुहा' का उल्लेख मिलता है, जिसे सिंधु क्षेत्र माना जाता है।" }, { "question": "सिंधु सभ्यता में प्रचलित माप-तौल प्रणाली किस गुणक पर आधारित थी?", "options": ["10 के गुणक पर", "12 के गुणक पर", "16 के गुणक पर", "20 के गुणक पर"], "correct": 2, "explanation": "एक मानकीकृत माप-तौल प्रणाली प्रचलित थी, जो 16 के गुणक पर आधारित थी (जैसे 16, 32, 64, 160 आदि)।" }, { "question": "बड़ी संख्या में मिली नारी मृण्मूर्तियाँ किस धार्मिक विश्वास का संकेत देती हैं?", "options": ["सूर्य पूजा", "मातृदेवी की पूजा", "पुरुष देवता की पूजा", "अग्नि पूजा"], "correct": 1, "explanation": "बड़ी संख्या में मिली नारी मृण्मूर्तियाँ मातृदेवी की पूजा का संकेत देती हैं।" }, { "question": "मोहनजोदड़ो से मिली मुहर पर चित्रित योगी की मुद्रा में बैठे पुरुष देवता को क्या माना जाता है?", "options": ["इंद्र", "विष्णु", "पशुपति महादेव (प्रोटो-शिवा)", "ब्रह्मा"], "correct": 2, "explanation": "मोहनजोदड़ो से मिली मुहर पर एक योगी की मुद्रा में बैठे पुरुष देवता का चित्रण है, जिसे पशुपति महादेव (प्रोटो-शिवा) माना जाता है।" }, { "question": "सिंधु सभ्यता में किस पेड़ को पवित्र माना जाता था और इसकी पूजा की जाती थी?", "options": ["बरगद का पेड़", "नीम का पेड़", "पीपल का पेड़", "आम का पेड़"], "correct": 2, "explanation": "पीपल का पेड़ पवित्र माना जाता था और इसकी पूजा की जाती थी, जिसके साक्ष्य मुहरों पर मिलते हैं।" }, { "question": "किस जानवर को सिंधु सभ्यता में एक महत्वपूर्ण धार्मिक प्रतीक माना जाता था?", "options": ["घोड़ा", "हाथी", "कूबड़ वाला बैल", "शेर"], "correct": 2, "explanation": "कूबड़ वाला बैल (Humped Bull) एक महत्वपूर्ण धार्मिक प्रतीक था।" }, { "question": "कालीबंगा और लोथल जैसे स्थलों पर क्या मिली हैं, जो संभवतः अनुष्ठानों या यज्ञों से संबंधित थीं?", "options": ["मंदिर", "महल", "अग्नि वेदियाँ", "मूर्तियाँ"], "correct": 2, "explanation": "कालीबंगा और लोथल जैसे स्थलों पर अग्नि वेदियाँ मिली हैं, जो संभवतः अनुष्ठानों या यज्ञों से संबंधित थीं।" }, { "question": "सिंधु सभ्यता में किस प्रकार के धार्मिक भवनों के स्पष्ट साक्ष्य नहीं मिले हैं?", "options": ["छोटे मंदिर", "गुफा मंदिर", "बड़े मंदिर या धार्मिक भवन", "अग्नि वेदियाँ"], "correct": 2, "explanation": "सिंधु सभ्यता में किसी भी बड़े मंदिर या धार्मिक भवन के स्पष्ट साक्ष्य नहीं मिले हैं।" }, { "question": "हड़प्पा में 'R-37' कब्रिस्तान और लोथल में युग्म दफन (Couple Burial) के साक्ष्य किस प्रथा से संबंधित हैं?", "options": ["सामूहिक भोज", "धार्मिक सभा", "अंत्येष्टि प्रथाएँ", "व्यापारिक बैठकें"], "correct": 2, "explanation": "हड़प्पा में 'R-37' कब्रिस्तान और लोथल में युग्म दफन (Couple Burial) के साक्ष्य अंत्येष्टि प्रथाओं से संबंधित हैं।" }, { "question": "सिंधु सभ्यता के लोगों के आहार में कौन सा अनाज मुख्य नहीं था?", "options": ["गेहूँ", "जौ", "मक्का", "चावल"], "correct": 2, "explanation": "मक्का सिंधु सभ्यता के लोगों के आहार का मुख्य हिस्सा नहीं था, जबकि गेहूँ, जौ और चावल प्रमुख अनाज थे।" } ] ; let currentQuestionIndex = 0; let userAnswers = Array(quizData.length).fill(null); let totalQuizTime = quizData.length * 30; let timeLeft = totalQuizTime; let timerInterval; let quizSubmitted = false; let reviewMode = false; let popupTimeout; // DOM Elements const questionEl = document.getElementById("question"); const choicesEl = document.getElementById("choices"); const explanationEl = document.getElementById("explanation"); const questionCounterEl = document.getElementById("questionCounter"); const timerEl = document.getElementById("timer"); const prevButton = document.getElementById("prevButton"); const nextButton = document.getElementById("nextButton"); const submitQuizButton = document.getElementById("submitQuizButton"); const reviewQuizButton = document.getElementById("reviewQuizButton"); const restartQuizButton = document.getElementById("restartQuizButton"); const quizContentEl = document.getElementById("quizContent"); const resultContentEl = document.getElementById("resultContent"); const resultMessageEl = document.getElementById("resultMessage"); const scoreMessageEl = document.getElementById("scoreMessage"); const questionNavEl = document.getElementById("questionNav"); const questionNavOverlayEl = document.getElementById('questionNavOverlay'); const hamburgerBtn = document.getElementById('hamburgerBtn'); const popupMessageEl = document.getElementById('popupMessage'); const submitConfirmationModalEl = document.getElementById('submitConfirmationModal'); const confirmSubmitBtn = document.getElementById('confirmSubmitBtn'); const cancelSubmitBtn = document.getElementById('cancelSubmitBtn'); const reviewStatusMessageEl = document.getElementById('reviewStatusMessage'); // New element function startTimer() { timeLeft = totalQuizTime; updateTimerDisplay(timeLeft); clearInterval(timerInterval); timerInterval = setInterval(() => { timeLeft--; updateTimerDisplay(timeLeft); if (timeLeft <= 0) { clearInterval(timerInterval); if (!quizSubmitted) { submitQuizActions(); } } }, 1000); } function updateTimerDisplay(seconds) { const mins = Math.floor(seconds / 60).toString().padStart(2, '0'); const secs = (seconds % 60).toString().padStart(2, '0'); timerEl.innerText = `Time: ${mins}:${secs}`; } function generateQuestionNav() { questionNavEl.innerHTML = ""; quizData.forEach((_, index) => { const circle = document.createElement("div"); circle.classList.add("circle-number"); circle.innerText = index + 1; circle.onclick = () => jumpToQuestion(index); if (reviewMode) { if (userAnswers[index] === null) { circle.classList.add("reviewed-skipped"); } else if (userAnswers[index] === quizData[index].correct) { circle.classList.add("reviewed-correct"); } else { circle.classList.add("reviewed-incorrect"); } } else { if (userAnswers[index] !== null) { circle.classList.add("answered"); } } questionNavEl.appendChild(circle); }); highlightCurrentCircle(); } function highlightCurrentCircle() { const circles = questionNavEl.querySelectorAll(".circle-number"); circles.forEach((circle, idx) => { circle.classList.remove("active", "current-review"); if (idx === currentQuestionIndex) { circle.classList.add(reviewMode ? "current-review" : "active"); } }); } function jumpToQuestion(qIndex) { currentQuestionIndex = qIndex; questionNavOverlayEl.classList.remove('show'); hamburgerBtn.classList.remove('active'); loadQuestion(); } function loadQuestion() { if (currentQuestionIndex < 0 || currentQuestionIndex >= quizData.length) return; const questionData = quizData[currentQuestionIndex]; questionEl.innerText = questionData.question; questionCounterEl.innerText = `${currentQuestionIndex + 1}/${quizData.length}`; choicesEl.innerHTML = ""; explanationEl.classList.add("hidden"); reviewStatusMessageEl.classList.add('hidden'); // Hide review status by default questionData.options.forEach((option, index) => { const choiceElement = document.createElement("div"); choiceElement.className = "choice"; choiceElement.innerText = option; if (reviewMode) { choiceElement.classList.add("disabled"); if (index === questionData.correct) { choiceElement.classList.add("correct"); } if (userAnswers[currentQuestionIndex] === index && index !== questionData.correct) { choiceElement.classList.add("user-selected-incorrect"); } } else { if (userAnswers[currentQuestionIndex] === index) { choiceElement.classList.add("selected"); } choiceElement.onclick = () => { if (!reviewMode) { userAnswers[currentQuestionIndex] = index; document.querySelectorAll("#choices .choice").forEach(c => c.classList.remove("selected")); choiceElement.classList.add("selected"); generateQuestionNav(); } }; } choicesEl.appendChild(choiceElement); }); if (reviewMode) { explanationEl.innerHTML = "<b>व्याख्या (Explanation):</b> " + questionData.explanation; explanationEl.classList.remove("hidden"); // Update and show review status message reviewStatusMessageEl.classList.remove('hidden', 'status-correct', 'status-incorrect', 'status-skipped'); if (userAnswers[currentQuestionIndex] === null) { reviewStatusMessageEl.textContent = "आपने यह प्रश्न छोड़ दिया। (You skipped this question.)"; reviewStatusMessageEl.classList.add('status-skipped'); showPopupMessage("You skipped this question.", "skipped"); } else if (userAnswers[currentQuestionIndex] === questionData.correct) { reviewStatusMessageEl.textContent = "आपका उत्तर सही है! (Your answer is correct!)"; reviewStatusMessageEl.classList.add('status-correct'); showPopupMessage("You got it right!", "correct"); } else { reviewStatusMessageEl.textContent = "आपका उत्तर गलत है। (Your answer is incorrect.)"; reviewStatusMessageEl.classList.add('status-incorrect'); showPopupMessage("You got it wrong.", "incorrect"); } } else { popupMessageEl.classList.remove('show'); popupMessageEl.classList.add('hidden'); reviewStatusMessageEl.classList.add('hidden'); // Ensure it's hidden if not in review mode } updateButtonVisibility(); highlightCurrentCircle(); } function updateButtonVisibility() { prevButton.classList.toggle("disabled", currentQuestionIndex === 0); prevButton.disabled = currentQuestionIndex === 0; const isLastQuestion = currentQuestionIndex === quizData.length - 1; nextButton.classList.toggle("disabled", isLastQuestion); nextButton.disabled = isLastQuestion; if (quizSubmitted && !reviewMode) { prevButton.classList.add("hidden"); nextButton.classList.add("hidden"); submitQuizButton.classList.add("hidden"); } else if (reviewMode) { submitQuizButton.classList.add("hidden"); prevButton.classList.remove("hidden"); nextButton.classList.remove("hidden"); } else { submitQuizButton.classList.remove("hidden"); prevButton.classList.remove("hidden"); nextButton.classList.remove("hidden"); } } function previousQuestion() { if (currentQuestionIndex > 0) { currentQuestionIndex--; loadQuestion(); } } function nextQuestion() { if (currentQuestionIndex < quizData.length - 1) { currentQuestionIndex++; loadQuestion(); } } function showSubmitConfirmationModal() { submitConfirmationModalEl.classList.remove('hidden'); submitConfirmationModalEl.classList.add('show'); } function hideSubmitConfirmationModal() { submitConfirmationModalEl.classList.remove('show'); submitConfirmationModalEl.classList.add('hidden'); } function submitQuizActions() { quizSubmitted = true; reviewMode = false; clearInterval(timerInterval); const correctAnswersCount = userAnswers.filter( (ans, i) => ans !== null && ans === quizData[i].correct ).length; quizContentEl.classList.add("hidden"); resultContentEl.classList.remove("hidden"); const percentage = (correctAnswersCount / quizData.length) * 100; let resultMsgText = ""; if (percentage >= 60) { resultMsgText = `<div class="congrats">🎉 बधाई हो! आपने ${percentage.toFixed(2)}% स्कोर किया है!</div>`; } else { resultMsgText = `<div class="sad">😢 आपने ${percentage.toFixed(2)}% स्कोर किया है। अगली बार के लिए शुभकामनाएं!</div>`; } resultMessageEl.innerHTML = resultMsgText; scoreMessageEl.innerText = `आपने कुल ${quizData.length} में से ${correctAnswersCount} प्रश्न सही उत्तर दिए हैं।`; reviewQuizButton.classList.remove("hidden"); restartQuizButton.classList.remove("hidden"); updateButtonVisibility(); hideSubmitConfirmationModal(); } function startReview() { reviewMode = true; quizSubmitted = true; currentQuestionIndex = 0; resultContentEl.classList.add("hidden"); quizContentEl.classList.remove("hidden"); generateQuestionNav(); loadQuestion(); } function restartQuiz() { currentQuestionIndex = 0; userAnswers = Array(quizData.length).fill(null); quizSubmitted = false; reviewMode = false; resultContentEl.classList.add("hidden"); quizContentEl.classList.remove("hidden"); explanationEl.classList.add("hidden"); popupMessageEl.classList.remove('show'); popupMessageEl.classList.add('hidden'); reviewStatusMessageEl.classList.add('hidden'); // Hide review status on restart generateQuestionNav(); loadQuestion(); startTimer(); updateButtonVisibility(); } hamburgerBtn.addEventListener('click', () => { questionNavOverlayEl.classList.toggle('show'); hamburgerBtn.classList.toggle('active'); }); document.addEventListener('click', (e) => { if ( questionNavOverlayEl.classList.contains('show') && !questionNavOverlayEl.contains(e.target) && !hamburgerBtn.contains(e.target) ) { questionNavOverlayEl.classList.remove('show'); hamburgerBtn.classList.remove('active'); } }); const themes = [ { name: "Berry Delight", header: '#a31645', headerText: '#ffffff', container: '#e8c4d6', containerText: '#6e0c36', bodyBg: '#fdecf2', headings: '#6e0c36' }, { name: "Ocean Breeze", header: '#00574b', headerText: '#ffffff', container: '#b3dfd7', containerText: '#00382e', bodyBg: '#e0f2f1', headings: '#00382e' }, { name: "Sunset Glow", header: '#c95a00', headerText: '#ffffff', container: '#ffcc80', containerText: '#7a3400', bodyBg: '#fff3e0', headings: '#7a3400' }, { name: "Calm Lavender", header: '#4a0f6f', headerText: '#ffffff', container: '#d1c4e9', containerText: '#320b4a', bodyBg: '#f3e5f5', headings: '#320b4a' }, { name: "Forest Retreat", header: '#1e4d2b', headerText: '#ffffff', container: '#c8e6c9', containerText: '#122417', bodyBg: '#e8f5e9', headings: '#122417' }, { name: "Golden Elegance", header: '#c99800', headerText: '#ffffff', container: '#fff9c4', containerText: '#6c4f00', bodyBg: '#fffde7', headings: '#6c4f00' }, { name: "Sky Calm", header: '#01477e', headerText: '#ffffff', container: '#b3e5fc', containerText: '#00223d', bodyBg: '#e1f5fe', headings: '#00223d' }, { name: "Default Green", header: '#7cb342', headerText: '#ffffff', container: '#dcedc8', containerText: '#33691e', bodyBg: '#f1f8e9', headings: '#33691e'} ]; function applyRandomTheme() { const rootStyle = document.documentElement.style; const randomTheme = themes[Math.floor(Math.random() * themes.length)]; rootStyle.setProperty('--theme-body-bg', randomTheme.bodyBg); rootStyle.setProperty('--theme-main-text', randomTheme.containerText); rootStyle.setProperty('--theme-header-bg', randomTheme.header); rootStyle.setProperty('--theme-header-text', randomTheme.headerText); rootStyle.setProperty('--theme-content-container-bg', randomTheme.container); rootStyle.setProperty('--theme-quiz-container-bg', '#ffffff'); // These are now overridden by direct CSS for darker text, but theme variables still set rootStyle.setProperty('--theme-question-text', randomTheme.headings); rootStyle.setProperty('--theme-choice-text', randomTheme.headings); rootStyle.setProperty('--theme-choice-bg', randomTheme.container); rootStyle.setProperty('--theme-choice-border', randomTheme.header); rootStyle.setProperty('--theme-explanation-bg', randomTheme.bodyBg); rootStyle.setProperty('--theme-explanation-border', randomTheme.header); rootStyle.setProperty('--theme-explanation-text', randomTheme.headings); rootStyle.setProperty('--theme-headings-text', randomTheme.headings); rootStyle.setProperty('--theme-counter-text', randomTheme.header); // Timer text color is defined in :root as --theme-timer-text: #c62828; // If you want timer text to match header: // rootStyle.setProperty('--theme-timer-text', randomTheme.header); } window.onload = function() { applyRandomTheme(); generateQuestionNav(); loadQuestion(); startTimer(); updateButtonVisibility(); prevButton.addEventListener('click', previousQuestion); nextButton.addEventListener('click', nextQuestion); submitQuizButton.addEventListener('click', showSubmitConfirmationModal); reviewQuizButton.addEventListener('click', startReview); restartQuizButton.addEventListener('click', restartQuiz); confirmSubmitBtn.addEventListener('click', submitQuizActions); cancelSubmitBtn.addEventListener('click', hideSubmitConfirmationModal); }; function showPopupMessage(message, type) { if (popupTimeout) clearTimeout(popupTimeout); popupMessageEl.innerText = message; popupMessageEl.className = 'hidden'; popupMessageEl.classList.add('show', type); popupTimeout = setTimeout(() => { popupMessageEl.classList.remove('show'); }, 2500); }