Skip to content

Commit ef24880

Browse files
committed
fix: quiz progress bar not syncing with respondent navigation
- Changed updateHUD() to track current question position (cur+1) instead of answered-question count - Added updateHUD(bi) call inside gotoScreen() so bar updates on every navigation - Progress bar now fills progressively as respondent moves through questions
1 parent 1104dd4 commit ef24880

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ TextAgent has undergone significant evolution since its inception. What started
538538

539539
| Date | Commits | Feature / Update |
540540
|------|---------|-----------------:|
541+
| **2026-03-28** | | 🎓 **Quiz Progress Bar Fix** — fixed progress bar not syncing with respondent navigation; bar now tracks current question position instead of answered-question count; `gotoScreen()` now updates HUD on every navigation |
541542
| **2026-03-27** | | 📊 **ECharts Chart System** — new `{{Chart:}}` DocGen tag with 7 declarative chart types (bar, line, pie, scatter, radar, gauge, heatmap) and raw ECharts JS code mode; `chart-docgen.js` (~720 lines) parser/builder/transformer; `chart-docgen.css` + `echarts.css` styling; lazy-loaded ECharts CDN via `window.getECharts()`; 📊 Chart toolbar button, composer chip, mobile integration; 11 chart gallery templates (Line, Bar, Pie, Scatter, Sunburst, Treemap, Advanced, Sankey, Parallel, Graph) with ~4,200 lines of copy-paste-ready examples; new Charts template category |
542543
| **2026-03-27** | | 📂 **Spaces** — personal document hub with email-based ownership and access key recovery; `space-manager.js` (~760 lines) CRUD, Firestore sync, hub rendering; `spaces.css` (~540 lines) glassmorphic modal UI; Spaces modal with create/recover/manage views; "Add to Space" picker in share modal; `#space=<slug>` URL routing; Firestore `/spaces/{spaceId}` collection rules with field validation, write-token ownership, 50-item limit |
543544
| **2026-03-27** | | 📊 **Chart Bug Fixes** — fixed 6 bugs in `{{Chart:}}` DocGen: ECharts memory leak (old instances never disposed on re-render), `@code` brace-depth tracker desyncing on braces inside strings/comments, `stripTypeScript` regex mangling valid JS object values, fragile `- 2` insert offset in Add Series, confusing area-style default logic, and block index desync from re-parsing `fullMatch` substrings; extracted `parseConfigFromBody()` shared helper; added `M._activeCharts` disposal tracking |
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Quiz Progress Bar Fix — Sync bar with respondent navigation
2+
3+
- Fixed: Quiz progress bar not filling as respondent navigates through questions
4+
- Fixed: `gotoScreen()` never called `updateHUD()`, so navigation didn't touch the bar
5+
- Changed progress calculation from answered-question count to current question position (`cur + 1`)
6+
7+
---
8+
9+
## Summary
10+
The quiz progress bar was stuck at 0% until answers were recorded because it tracked answered questions, not navigation position. Now it fills progressively as the respondent moves through questions.
11+
12+
---
13+
14+
## 1. Progress Bar Sync Fix
15+
**Files:** `js/quiz-docgen.js`
16+
**What:** Changed `updateHUD()` to use `(st.cur + 1) / st.total * 100` instead of `results.filter(r => r !== undefined).length / st.total * 100`. Added `updateHUD(bi)` call inside `gotoScreen()`.
17+
**Impact:** The progress bar now visually fills in sync with the respondent's current question, reaching 100% on the last question.
18+
19+
---
20+
21+
## Files Changed (1 total)
22+
23+
| File | Lines Changed | Type |
24+
|------|:---:|------|
25+
| `js/quiz-docgen.js` | +4 −2 | Bug fix — progress bar tracking |

js/quiz-docgen.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,9 @@
411411
// ─── HUD helpers ──────────────────────────────────────────────────────────
412412
function updateHUD(bi) {
413413
var st = getState(bi);
414-
var done = st.results.filter(function(r){return r!==undefined;}).length;
415-
var prog = document.getElementById('qd-prog'+bi); if(prog) prog.style.width=(done/st.total*100)+'%';
414+
// Progress bar tracks current question position (how far the respondent has navigated)
415+
var progressPct = st.total > 0 ? ((st.cur + 1) / st.total * 100) : 0;
416+
var prog = document.getElementById('qd-prog'+bi); if(prog) prog.style.width = progressPct + '%';
416417
var xpEl = document.getElementById('qd-xp'+bi); if(xpEl) xpEl.textContent='⭐ '+st.xp+' XP';
417418
var livEl= document.getElementById('qd-liv'+bi); if(livEl) livEl.textContent='❤️'.repeat(st.lives)+'🖤'.repeat(3-st.lives);
418419
}
@@ -441,6 +442,7 @@
441442
screens.forEach(function(s){ s.style.display='none'; });
442443
var t = document.getElementById('qd-s'+bi+'-'+qi); if(t) t.style.display='block';
443444
getState(bi).cur = qi;
445+
updateHUD(bi);
444446
}
445447
function showComplete(bi) {
446448
var st = getState(bi);

0 commit comments

Comments
 (0)