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": ["1.5 मिलियन", "2.0 मिलियन", "2.5 मिलियन", "3.0 मिलियन"], "correct": 2, "explanation": "पाषाण युग लगभग 2.5 मिलियन वर्ष पूर्व शुरू हुआ।" }, { "question": "पुरापाषाण काल की समय सीमा क्या है?", "options": ["10,000 ईसा पूर्व से 6,000 ईसा पूर्व", "6,000 ईसा पूर्व से 1,000 ईसा पूर्व", "2.5 मिलियन वर्ष पूर्व से 10,000 ईसा पूर्व", "1,000 ईसा पूर्व से 500 ईसा पूर्व"], "correct": 2, "explanation": "पुरापाषाण काल की समय सीमा लगभग 2.5 मिलियन वर्ष पूर्व से 10,000 ईसा पूर्व तक है।" }, { "question": "पुरापाषाण काल के मनुष्य की जीवन शैली क्या थी?", "options": ["कृषक", "स्थायी निवासी", "शिकारी और खाद्य संग्राहक", "व्यापारी"], "correct": 2, "explanation": "इस काल का मनुष्य मुख्यतः शिकारी और खाद्य संग्राहक (Hunter-Gatherer) था।" }, { "question": "निम्न पुरापाषाण काल के प्रमुख औजार कौन से थे?", "options": ["शल्क और खुरचनी", "फलक और ब्यूरिन", "हस्त-कुल्हाड़ी और विदारणी", "सूक्ष्म पाषाण औजार"], "correct": 2, "explanation": "हस्त-कुल्हाड़ी और विदारणी जैसे औजार निम्न पुरापाषाण काल में प्रमुख थे।" }, { "question": "किस पुरापाषाण काल में शल्क (Flakes) आधारित औजारों का विकास हुआ?", "options": ["निम्न पुरापाषाण काल", "मध्य पुरापाषाण काल", "उच्च पुरापाषाण काल", "नवपाषाण काल"], "correct": 1, "explanation": "मध्य पुरापाषाण काल में शल्क (Flakes) आधारित औजारों का विकास हुआ।" }, { "question": "आधुनिक मानव (होमो सेपियन्स) का उदय किस पुरापाषाण काल में हुआ?", "options": ["निम्न पुरापाषाण काल", "मध्य पुरापाषाण काल", "उच्च पुरापाषाण काल", "मध्यपाषाण काल"], "correct": 2, "explanation": "आधुनिक मानव (होमो सेपियन्स) का उदय उच्च पुरापाषाण काल में हुआ।" }, { "question": "गुफा चित्रकला के साक्ष्य (जैसे भीमबेटका में) किस पुरापाषाण काल से मिलते हैं?", "options": ["निम्न पुरापाषाण काल", "मध्य पुरापाषाण काल", "उच्च पुरापाषाण काल", "मध्यपाषाण काल"], "correct": 2, "explanation": "गुफा चित्रकला के साक्ष्य उच्च पुरापाषाण काल से मिलते हैं।" }, { "question": "मध्यपाषाण काल की समय सीमा क्या है?", "options": ["2.5 मिलियन वर्ष पूर्व से 10,000 ईसा पूर्व", "10,000 ईसा पूर्व से 6,000 ईसा पूर्व", "6,000 ईसा पूर्व से 1,000 ईसा पूर्व", "1,000 ईसा पूर्व से 500 ईसा पूर्व"], "correct": 1, "explanation": "मध्यपाषाण काल की समय सीमा लगभग 10,000 ईसा पूर्व से 6,000 ईसा पूर्व तक है।" }, { "question": "मध्यपाषाण काल की सबसे बड़ी विशेषता क्या है?", "options": ["पॉलिश किए गए औजार", "कृषि का आरंभ", "सूक्ष्म पाषाण औजार (Microliths)", "पहिए का आविष्कार"], "correct": 2, "explanation": "मध्यपाषाण काल की सबसे बड़ी विशेषता सूक्ष्म पाषाण औजार (Microliths) हैं।" }, { "question": "किस काल में पशुपालन की शुरुआत के प्रारंभिक साक्ष्य मिलते हैं?", "options": ["पुरापाषाण काल", "मध्यपाषाण काल", "नवपाषाण काल", "ताम्रपाषाण काल"], "correct": 1, "explanation": "मध्यपाषाण काल में पशुपालन की शुरुआत के प्रारंभिक साक्ष्य मिलते हैं (जैसे आदमगढ़ और बागोर में)।" }, { "question": "नवपाषाण काल की समय सीमा क्या है?", "options": ["10,000 ईसा पूर्व से 6,000 ईसा पूर्व", "6,000 ईसा पूर्व से 1,000 ईसा पूर्व", "2.5 मिलियन वर्ष पूर्व से 10,000 ईसा पूर्व", "1,000 ईसा पूर्व से 500 ईसा पूर्व"], "correct": 1, "explanation": "नवपाषाण काल की समय सीमा लगभग 6,000 ईसा पूर्व से 1,000 ईसा पूर्व तक है।" }, { "question": "किस काल में मानव जीवन में 'नवपाषाण क्रांति' आई?", "options": ["पुरापाषाण काल", "मध्यपाषाण काल", "नवपाषाण काल", "ताम्रपाषाण काल"], "correct": 2, "explanation": "नवपाषाण काल में मानव जीवन में एक बड़ा बदलाव आया, जिसे 'नवपाषाण क्रांति' कहा जाता है।" }, { "question": "नवपाषाण क्रांति की मुख्य विशेषता क्या है?", "options": ["शिकार और संग्रहण", "धातु का उपयोग", "कृषि का आरंभ", "गुफा चित्रकला"], "correct": 2, "explanation": "नवपाषाण क्रांति की मुख्य विशेषता कृषि का आरंभ है।" }, { "question": "किस काल के औजार पॉलिश किए गए पत्थर के बने होते थे?", "options": ["पुरापाषाण काल", "मध्यपाषाण काल", "नवपाषाण काल", "ताम्रपाषाण काल"], "correct": 2, "explanation": "नवपाषाण काल के औजार पॉलिश किए गए पत्थर के बने होते थे।" }, { "question": "पहिए का आविष्कार किस काल की महत्वपूर्ण देन है?", "options": ["पुरापाषाण काल", "मध्यपाषाण काल", "नवपाषाण काल", "हड़प्पा काल"], "correct": 2, "explanation": "पहिए का आविष्कार नवपाषाण काल की महत्वपूर्ण देन है।" }, { "question": "मेहरगढ़ किस काल का स्थल है और किस लिए प्रसिद्ध है?", "options": ["पुरापाषाण काल, गुफा चित्रकला", "मध्यपाषाण काल, सूक्ष्म पाषाण औजार", "नवपाषाण काल, कृषि के प्राचीनतम साक्ष्य", "ताम्रपाषाण काल, धातु के औजार"], "correct": 2, "explanation": "मेहरगढ़ (पाकिस्तान, बलूचिस्तान) नवपाषाण काल का महत्वपूर्ण स्थल है, जहाँ कृषि के प्राचीनतम साक्ष्य (लगभग 7000 ईसा पूर्व) मिले हैं।" }, { "question": "बुर्जहोम किस काल का स्थल है और किस लिए प्रसिद्ध है?", "options": ["पुरापाषाण काल, हस्त-कुल्हाड़ी", "मध्यपाषाण काल, पशुपालन", "नवपाषाण काल, गर्त-आवास और पालतू कुत्तों को मालिक के साथ दफनाने के साक्ष्य", "ताम्रपाषाण काल, तांबे के औजार"], "correct": 2, "explanation": "बुर्जहोम (जम्मू और कश्मीर) नवपाषाण काल का स्थल है, जहाँ गर्त-आवास (Pit-dwellings) और पालतू कुत्तों को मालिक के साथ दफनाने के साक्ष्य मिले हैं।" }, { "question": "चिरांद किस काल का स्थल है और किस लिए प्रसिद्ध है?", "options": ["पुरापाषाण काल, आग का उपयोग", "मध्यपाषाण काल, मछली पकड़ना", "नवपाषाण काल, हड्डी के औजारों की प्रचुरता", "ताम्रपाषाण काल, मृदभांड"], "correct": 2, "explanation": "चिरांद (बिहार) नवपाषाण काल का स्थल है, जहाँ हड्डी के औजारों की प्रचुरता मिली है।" }, { "question": "कोल्डीहवा किस काल का स्थल है और किस लिए प्रसिद्ध है?", "options": ["पुरापाषाण काल, शैल चित्र", "मध्यपाषाण काल, मानव कंकाल", "नवपाषाण काल, चावल की खेती के प्राचीनतम साक्ष्य", "ताम्रपाषाण काल, स्थायी बस्तियाँ"], "correct": 2, "explanation": "कोल्डीहवा (उत्तर प्रदेश) नवपाषाण काल का स्थल है, जहाँ चावल की खेती के प्राचीनतम साक्ष्य मिले हैं।" }, { "question": "भीमबेटका किस राज्य में स्थित है?", "options": ["उत्तर प्रदेश", "राजस्थान", "मध्य प्रदेश", "बिहार"], "correct": 2, "explanation": "भीमबेटका मध्य प्रदेश में स्थित है।" }, { "question": "भारत में पहली पुरापाषाण हस्त-कुल्हाड़ी की खोज का स्थल कौन सा है?", "options": ["भीमबेटका", "मेहरगढ़", "पल्लवरम", "चिरांद"], "correct": 2, "explanation": "पल्लवरम (तमिलनाडु) भारत में पहली पुरापाषाण हस्त-कुल्हाड़ी की खोज का स्थल है।" }, { "question": "पाषाण युग में जीवन शैली में क्या परिवर्तन आया?", "options": ["स्थायी से घुमंतू", "घुमंतू शिकारी-संग्राहक जीवन से स्थायी कृषि-आधारित जीवन शैली की ओर संक्रमण", "केवल शिकारी जीवन", "केवल कृषि जीवन"], "correct": 1, "explanation": "जीवन शैली में घुमंतू शिकारी-संग्राहक जीवन से अर्ध-स्थायी और फिर स्थायी कृषि-आधारित जीवन शैली की ओर संक्रमण हुआ।" }, { "question": "पाषाण युग में तकनीकी नवाचारों में क्या शामिल है?", "options": ["कंप्यूटर का आविष्कार", "औजारों का विकास, आग का नियंत्रित उपयोग और पहिए का आविष्कार", "अंतरिक्ष यात्रा", "टेलीफोन का आविष्कार"], "correct": 1, "explanation": "औजारों के विकास, आग के नियंत्रित उपयोग और पहिए के आविष्कार ने मानव जीवन को आसान बनाया और भविष्य के तकनीकी विकास का मार्ग प्रशस्त किया।" }, { "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); }