Skip to content

Commit adbdcfd

Browse files
committed
feat: add pause/stop button after answer reveal
1 parent d4abd02 commit adbdcfd

1 file changed

Lines changed: 43 additions & 1 deletion

File tree

content/intro-lecture/quiz/index.html

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@
157157
border-top: 1px solid rgba(255,255,255,0.12); padding-top: 6px;
158158
}
159159

160+
.stop-btn {
161+
padding: 10px 28px; font-size: 14px; font-weight: 800;
162+
background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.3);
163+
color: white; border-radius: 24px; cursor: pointer;
164+
transition: background 0.15s;
165+
}
166+
.stop-btn:hover { background: rgba(255,255,255,0.22); }
167+
.stop-btn.next-mode {
168+
background: rgba(99,102,241,0.35); border-color: #818cf8;
169+
}
170+
160171
/* ── Result ── */
161172
#result .trophy { font-size: 72px; text-align: center; margin: 16px 0 8px; }
162173
#result h2 { font-size: 26px; font-weight: 900; text-align: center; margin-bottom: 6px; }
@@ -248,6 +259,9 @@ <h3>Mixed (Both Types)</h3>
248259
<button class="confirm-btn" id="confirmBtn" onclick="confirmMulti()" disabled>Confirm ✓</button>
249260
</div>
250261
<div class="feedback" id="feedback"></div>
262+
<div id="stopBar" style="display:none;text-align:center;margin-top:10px">
263+
<button class="stop-btn" id="stopBtn" onclick="stopAutoAdvance()">⏸ Pause · Next →</button>
264+
</div>
251265
</div>
252266

253267
<!-- ── RESULT ── -->
@@ -359,6 +373,9 @@ <h2 id="rTitle"></h2>
359373
function loadQuestion() {
360374
multiSelected = new Set();
361375
clearInterval(timerInterval);
376+
clearTimeout(autoTimer); autoTimer = null;
377+
document.getElementById('stopBar').style.display = 'none';
378+
document.getElementById('stopBtn').onclick = stopAutoAdvance;
362379
timeLeft = 30;
363380

364381
const q = QUIZ_Q[currentIdx];
@@ -478,13 +495,38 @@ <h2 id="rTitle"></h2>
478495

479496
document.getElementById('scoreTop').textContent = score;
480497

481-
setTimeout(()=>{
498+
// Show pause/next bar and start auto-advance timer
499+
const stopBar = document.getElementById('stopBar');
500+
const stopBtn = document.getElementById('stopBtn');
501+
stopBar.style.display = 'block';
502+
stopBtn.className = 'stop-btn';
503+
stopBtn.textContent = '⏸ Pause · Next →';
504+
505+
autoTimer = setTimeout(() => {
506+
stopBar.style.display = 'none';
482507
currentIdx++;
483508
if (currentIdx < QUIZ_Q.length) loadQuestion();
484509
else showResult();
485510
}, 2500);
486511
}
487512

513+
let autoTimer = null;
514+
515+
function stopAutoAdvance() {
516+
clearTimeout(autoTimer);
517+
autoTimer = null;
518+
const stopBtn = document.getElementById('stopBtn');
519+
stopBtn.className = 'stop-btn next-mode';
520+
stopBtn.textContent = '▶ Next question →';
521+
stopBtn.onclick = () => {
522+
document.getElementById('stopBar').style.display = 'none';
523+
currentIdx++;
524+
if (currentIdx < QUIZ_Q.length) loadQuestion();
525+
else showResult();
526+
stopBtn.onclick = stopAutoAdvance; // reset for next round
527+
};
528+
}
529+
488530
// ── Result ────────────────────────────────────────────────────────────────
489531
function showResult() {
490532
show('result');

0 commit comments

Comments
 (0)