Skip to content

Commit 7121514

Browse files
author
strejoarciles
committed
quiz feature and button
1 parent bda459e commit 7121514

4 files changed

Lines changed: 1042 additions & 3 deletions

File tree

templates/boneset.html

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<span id="text-button-Home" role="button" tabindex="0">Home</span>
2929
<span id="text-button-Tutor" role="button" tabindex="0">Tutor</span>
3030
<span id="text-button-Study" role="button" tabindex="0">Study</span>
31+
<span id="start-quiz-btn" role="button" tabindex="0">Quiz Me! 🎓</span>
3132
<div id="help-button-container">
3233
<span id="text-button-Help" role="button" tabindex="0" onclick="document.getElementById('new-help-modal').style.display='flex';" style="pointer-events: auto !important; z-index: 9999 !important; cursor: pointer;">Help</span>
3334
</div>
@@ -153,6 +154,48 @@ <h2>Visual Reference</h2>
153154
</div>
154155
</main>
155156

157+
<!-- Quiz Modal -->
158+
<div id="quiz-modal" role="dialog" aria-labelledby="quiz-title" aria-modal="true">
159+
<div id="quiz-container">
160+
<!-- Quiz Header -->
161+
<div class="quiz-header">
162+
<div class="quiz-info">
163+
<div id="quiz-progress">Question 1 of 10</div>
164+
<div id="quiz-score">Score: 0/10</div>
165+
</div>
166+
<button id="exit-quiz-btn" aria-label="Exit quiz">Exit Quiz</button>
167+
</div>
168+
169+
<!-- Quiz Content -->
170+
<div class="quiz-content">
171+
<h2 id="quiz-question-text">What bone is this?</h2>
172+
173+
<!-- Bone Image Display -->
174+
<div id="quiz-bone-image">
175+
<div class="quiz-image-placeholder">
176+
<p>🦴</p>
177+
<p>Loading bone image...</p>
178+
</div>
179+
</div>
180+
181+
<!-- Answer Choices -->
182+
<div id="quiz-choices">
183+
<!-- Choices will be dynamically inserted here -->
184+
</div>
185+
186+
<!-- Feedback -->
187+
<div id="quiz-feedback" class="quiz-feedback">
188+
<!-- Feedback will be dynamically inserted here -->
189+
</div>
190+
</div>
191+
192+
<!-- Quiz Actions -->
193+
<div class="quiz-actions">
194+
<button id="next-question-btn" style="display: none;">Next Question</button>
195+
</div>
196+
</div>
197+
</div>
198+
156199
<!-- NEW Help Modal - Clean Version -->
157200
<div id="new-help-modal" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 99999; align-items: center; justify-content: center;">
158201
<div style="background: white; padding: 40px; border-radius: 16px; max-width: 650px; margin: 20px; border: 3px solid #FFD700; box-shadow: 0 25px 60px rgba(0,0,0,0.4);">
@@ -184,6 +227,10 @@ <h2 style="color: #003366; text-align: center; margin-bottom: 25px; border-botto
184227
<span style="position: absolute; left: 0; color: #0369a1; font-weight: bold;"></span>
185228
Use Previous and Next navigation buttons to browse through related items
186229
</li>
230+
<li style="margin: 8px 0; position: relative; padding-left: 25px;">
231+
<span style="position: absolute; left: 0; color: #0369a1; font-weight: bold;"></span>
232+
Click <strong>"Quiz Me!"</strong> to test your knowledge with interactive quizzes
233+
</li>
187234
</ul>
188235

189236
<p style="margin: 20px 0 0 0; font-style: italic; color: #4a5568; font-size: 1rem;">Press the ESC key to close this help window at any time.</p>
@@ -208,6 +255,13 @@ <h2 style="color: #003366; text-align: center; margin-bottom: 25px; border-botto
208255
if (modal) {
209256
modal.style.display = 'none';
210257
}
258+
259+
// Also close quiz modal if open
260+
const quizModal = document.getElementById('quiz-modal');
261+
if (quizModal && quizModal.style.display === 'flex') {
262+
// Trigger exit quiz button click
263+
document.getElementById('exit-quiz-btn')?.click();
264+
}
211265
}
212266
});
213267
</script>

templates/js/main.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { setupNavigation, setBoneAndSubbones, disableButtons } from "./navigatio
55
import { loadDescription } from "./description.js";
66
import { displayBoneData, clearViewer } from "./viewer.js";
77
import { initializeSearch } from "./search.js";
8+
import quizManager from "./quiz.js";
89

910
let combinedData = { bonesets: [], bones: [], subbones: [] };
1011

@@ -21,13 +22,26 @@ document.addEventListener("DOMContentLoaded", async () => {
2122
// 2. Sidebar behavior
2223
initializeSidebar();
2324

24-
25-
26-
// 4. Fetch data and populate dropdowns
25+
// 3. Fetch data FIRST (moved from step 4)
2726
combinedData = await fetchCombinedData();
2827
populateBonesetDropdown(combinedData.bonesets);
2928
setupDropdownListeners(combinedData);
3029

30+
// 4. Initialize quiz system AFTER data is loaded
31+
try {
32+
// Manually set the bones data in quizManager
33+
quizManager.allBones = combinedData.bones || [];
34+
35+
if (quizManager.allBones.length >= 3) {
36+
quizManager.setupEventListeners();
37+
console.log("Quiz system initialized successfully with", quizManager.allBones.length, "bones");
38+
} else {
39+
console.warn("Not enough bones for quiz:", quizManager.allBones.length);
40+
}
41+
} catch (error) {
42+
console.error("Error initializing quiz:", error);
43+
}
44+
3145
// Keep bone and subbone selects disabled until the user explicitly selects a boneset
3246
const boneSelectEl = document.getElementById("bone-select");
3347
const subboneSelectEl = document.getElementById("subbone-select");

0 commit comments

Comments
 (0)