Skip to content

Commit 59bf95e

Browse files
committed
feat: bihar tourism quiz section
1 parent da100b8 commit 59bf95e

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed

bihar-culture-landing/script.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ document.addEventListener('DOMContentLoaded', function() {
88
initInteractiveElements();
99
initAccessibility();
1010
initProgressiveEnhancement();
11+
initQuiz(); // attach quiz logic if present
1112
});
1213

1314
// Navigation enhancements
@@ -288,6 +289,38 @@ function initProgressiveEnhancement() {
288289
}
289290
}
290291

292+
// Quiz initialization and logic
293+
function initQuiz() {
294+
const form = document.getElementById('bihar-quiz');
295+
if (!form) return;
296+
const result = document.getElementById('quiz-result');
297+
const answers = {
298+
q1: 'bodh',
299+
q2: 'nalanda',
300+
q3: 'chhath',
301+
q4: 'patna',
302+
q5: 'valmiki'
303+
};
304+
305+
form.addEventListener('submit', function (e) {
306+
e.preventDefault();
307+
let score = 0;
308+
for (const [q, correct] of Object.entries(answers)) {
309+
const group = form.elements[q];
310+
if (group && group.value === correct) score++;
311+
}
312+
313+
let message = '';
314+
if (score === 5) message = 'Incredible! You’re a Bihar Boss!';
315+
else if (score >= 4) message = 'Great job! Bhojpuri Bravo!';
316+
else if (score >= 3) message = 'Nice! You’re on the Patna path.';
317+
else if (score >= 2) message = 'Not bad! Keep exploring Bihar.';
318+
else message = 'Time to tour Bihar’s wonders!';
319+
320+
if (result) result.textContent = 'You scored ' + score + '/5. ' + message;
321+
});
322+
}
323+
291324
// Utility functions for future enhancements
292325
const BiharCulture = {
293326
// Notification system

bihar-culture-landing/tourism.html

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,58 @@ <h2>Rajgir</h2>
3434
<h2>Valmiki Tiger Reserve</h2>
3535
<p>A natural reserve in West Champaran for wildlife lovers.</p>
3636
</section>
37+
38+
<section id="quiz">
39+
<h2>Quick Quiz: Bihar’s history, culture, and landmarks</h2>
40+
<form id="bihar-quiz">
41+
<fieldset>
42+
<legend>1) Where did Lord Buddha attain enlightenment?</legend>
43+
<label><input type="radio" name="q1" value="bodh" required> Bodh Gaya</label>
44+
<label><input type="radio" name="q1" value="rajgir"> Rajgir</label>
45+
<label><input type="radio" name="q1" value="vaishali"> Vaishali</label>
46+
</fieldset>
47+
48+
<fieldset>
49+
<legend>2) Which ancient university in Bihar is a UNESCO World Heritage Site?</legend>
50+
<label><input type="radio" name="q2" value="takshashila" required> Takshashila</label>
51+
<label><input type="radio" name="q2" value="nalanda"> Nalanda</label>
52+
<label><input type="radio" name="q2" value="vikramshila"> Vikramshila</label>
53+
</fieldset>
54+
55+
<fieldset>
56+
<legend>3) The festival where devotees worship the Sun God is:</legend>
57+
<label><input type="radio" name="q3" value="chhath" required> Chhath Puja</label>
58+
<label><input type="radio" name="q3" value="holi"> Holi</label>
59+
<label><input type="radio" name="q3" value="diwali"> Diwali</label>
60+
</fieldset>
61+
62+
<fieldset>
63+
<legend>4) The capital city of Bihar is:</legend>
64+
<label><input type="radio" name="q4" value="gaya" required> Gaya</label>
65+
<label><input type="radio" name="q4" value="patna"> Patna</label>
66+
<label><input type="radio" name="q4" value="muzaffarpur"> Muzaffarpur</label>
67+
</fieldset>
68+
69+
<fieldset>
70+
<legend>5) The wildlife reserve in West Champaran is:</legend>
71+
<label><input type="radio" name="q5" value="valmiki" required> Valmiki Tiger Reserve</label>
72+
<label><input type="radio" name="q5" value="kuno"> Kuno National Park</label>
73+
<label><input type="radio" name="q5" value="kaziranga"> Kaziranga National Park</label>
74+
</fieldset>
75+
76+
<div class="quiz-actions">
77+
<button type="submit">Submit</button>
78+
<button type="reset">Reset</button>
79+
</div>
80+
</form>
81+
<div id="quiz-result" role="status" aria-live="polite"></div>
82+
</section>
3783
</main>
3884

3985
<footer>
4086
<p>Contributors can add more tourist spots!</p>
4187
</footer>
88+
89+
<script src="script.js"></script>
4290
</body>
4391
</html>

package-lock.json

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)