From 04e9bf384738472f20358e9108bfc0684770095f Mon Sep 17 00:00:00 2001 From: Ramon Date: Tue, 14 Jul 2026 15:00:31 +0200 Subject: [PATCH] v0.3.10-beta: rapporteer widgetvoortgang vanuit leerling-speelmodus - board.js: fix bug waarbij de opts-parameter (readonly e.d.) nooit bij mountMath aankwam, doordat de registry-wrapper hem liet vallen - math.js/letters.js/ball.js: nieuwe opts.onProgress-callback, aangeroepen bij resp. einde rekenronde, voltooid woord en geknapte ballon - pupil.js: geeft onProgress mee bij het mounten en post het naar /my/progress; alleen actief in leerling-speelmodus, niet bij bewerken --- VERSION | 2 +- public/js/board.js | 10 +++++----- public/js/core.js | 2 +- public/js/pupil.js | 10 ++++++++-- public/js/widgets/ball.js | 4 +++- public/js/widgets/letters.js | 2 ++ public/js/widgets/math.js | 4 +++- 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index 6234113..397aa31 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.09-beta +0.3.10-beta diff --git a/public/js/board.js b/public/js/board.js index 5b5bfaf..443bf36 100644 --- a/public/js/board.js +++ b/public/js/board.js @@ -33,11 +33,11 @@ const REGISTRY = [ { id:"ball", cat:"taal", icon:"🎈", w:620, h:560, minW:480, minH:440, mount:mountBall }, { id:"anchor", cat:"taal", icon:"⚓", w:680, h:500, minW:440, minH:340, mount:mountAnchor }, { id:"sentence", cat:"taal", icon:"🧩", w:620, h:520, minW:400, minH:360, mount:mountSentence }, - { id:"madd", cat:"rekenen", icon:"➕", w:460, h:620, minW:380, minH:520, mount:(r,s)=>mountMath(r,s,"add") }, - { id:"msub", cat:"rekenen", icon:"➖", w:460, h:620, minW:380, minH:520, mount:(r,s)=>mountMath(r,s,"sub") }, - { id:"mmul", cat:"rekenen", icon:"✖️", w:460, h:620, minW:380, minH:520, mount:(r,s)=>mountMath(r,s,"mul") }, - { id:"mdiv", cat:"rekenen", icon:"➗", w:460, h:620, minW:380, minH:520, mount:(r,s)=>mountMath(r,s,"div") }, - { id:"mpct", cat:"rekenen", icon:"💯", w:480, h:620, minW:400, minH:520, mount:(r,s)=>mountMath(r,s,"pct") }, + { id:"madd", cat:"rekenen", icon:"➕", w:460, h:620, minW:380, minH:520, mount:(r,s,o)=>mountMath(r,s,"add",o) }, + { id:"msub", cat:"rekenen", icon:"➖", w:460, h:620, minW:380, minH:520, mount:(r,s,o)=>mountMath(r,s,"sub",o) }, + { id:"mmul", cat:"rekenen", icon:"✖️", w:460, h:620, minW:380, minH:520, mount:(r,s,o)=>mountMath(r,s,"mul",o) }, + { id:"mdiv", cat:"rekenen", icon:"➗", w:460, h:620, minW:380, minH:520, mount:(r,s,o)=>mountMath(r,s,"div",o) }, + { id:"mpct", cat:"rekenen", icon:"💯", w:480, h:620, minW:400, minH:520, mount:(r,s,o)=>mountMath(r,s,"pct",o) }, { id:"numberline", cat:"rekenen", icon:"↔️", w:660, h:430, minW:420, minH:320, mount:mountNumberline }, { id:"fractions", cat:"rekenen", icon:"🍫", w:600, h:480, minW:380, minH:320, mount:mountFractions }, { id:"clock", cat:"rekenen", icon:"🕙", w:500, h:500, minW:340, minH:340, mount:mountClock }, diff --git a/public/js/core.js b/public/js/core.js index dca86c4..554b3d6 100644 --- a/public/js/core.js +++ b/public/js/core.js @@ -2,7 +2,7 @@ "use strict"; /* version — shown until /api/version resolves (or if the fetch fails, e.g. offline). Kept in sync by hand with the VERSION file at the repo root on every release. */ -const VERSION = "0.3.09-beta"; +const VERSION = "0.3.10-beta"; (function(){ const tag = document.getElementById("verTag"); tag.textContent = "v"+VERSION; diff --git a/public/js/pupil.js b/public/js/pupil.js index 10c7ec5..33b8983 100644 --- a/public/js/pupil.js +++ b/public/js/pupil.js @@ -25,7 +25,7 @@ function renderPupilWidgets(widgets){ pupilView.appendChild(hint); return; } - usable.forEach(({ w, def })=>{ + usable.forEach(({ w, def }, idx)=>{ const card = document.createElement("div"); card.className = "widget pupil-card"; card.style.width = def.w + "px"; @@ -34,7 +34,13 @@ function renderPupilWidgets(widgets){ body.className = "widget-body"; card.appendChild(body); pupilView.appendChild(card); - def.mount(body, w.state || null, { readonly:true }); + /* geen stabiel widget-instantie-id in het bord (alleen het widget-type in + w.id) - positie in de lijst is de fijnste identiteit die beschikbaar is, + stabiel zolang de leerkracht de widgets op het bord niet herschikt */ + const widgetId = def.id + ":" + idx; + def.mount(body, w.state || null, { readonly:true, onProgress: (p)=>{ + api("/my/progress", { method:"POST", body: { widgetId, widgetType: def.id, ...p } }).catch(()=>{}); + }}); }); } diff --git a/public/js/widgets/ball.js b/public/js/widgets/ball.js index 96395c8..68820df 100644 --- a/public/js/widgets/ball.js +++ b/public/js/widgets/ball.js @@ -2,7 +2,8 @@ /* ========================================================= Balloon word widget — guess before the balloons pop ==========================================================*/ -function mountBall(root, initState){ +function mountBall(root, initState, opts){ + const onProgress = opts && opts.onProgress; const S = { card:0, snd:true, lives:6, guessed:new Set(), over:false, order:[], idx:0, stars:0 }; if(initState){ S.card = initState.card ?? 0; S.snd = initState.snd !== false; } const play = f=>{ if(S.snd) f(); }; @@ -70,6 +71,7 @@ function mountBall(root, initState){ play(sndWin); confetti(el(".mt-card")); nextBtn.classList.add("show"); scoreEl.textContent = S.stars+" ★"; + if(onProgress) onProgress({ attempts: 1, correct: 1, stars: 1 }); } }else{ S.lives--; diff --git a/public/js/widgets/letters.js b/public/js/widgets/letters.js index b12dfd2..58621a1 100644 --- a/public/js/widgets/letters.js +++ b/public/js/widgets/letters.js @@ -1,6 +1,7 @@ /* widget: Letterblokken (Ik leer lezen) */ function mountLetterGame(root, initState, opts){ const readonly = !!(opts && opts.readonly); + const onProgress = opts && opts.onProgress; const S = { level:1, card:0, wordIdx:0, stars:0, lang:LANG, count:6, order:[], snd:true, amode:"blocks" }; if(initState){ S.level = initState.level||1; @@ -282,6 +283,7 @@ function mountLetterGame(root, initState, opts){ doneEl.querySelector(".dp").textContent = currentWord()[0]; doneEl.classList.add("show"); nextBtn.classList.add("show"); + if(onProgress) onProgress({ attempts: 1, correct: 1, stars: 1 }); } } function showCardDone(){ diff --git a/public/js/widgets/math.js b/public/js/widgets/math.js index db114b4..a344a1a 100644 --- a/public/js/widgets/math.js +++ b/public/js/widgets/math.js @@ -2,8 +2,9 @@ /* ========================================================= Math practice engine — add / sub / mul / div / percentages ==========================================================*/ -function mountMath(root, initState, mode){ +function mountMath(root, initState, mode, opts){ const ROUND = 10; + const onProgress = opts && opts.onProgress; const S = { level:1, snd:true, amode:"blocks", q:null, tries:0, done:0, good:0, input:"", busy:false }; if(initState){ S.level = initState.level||1; @@ -199,6 +200,7 @@ function mountMath(root, initState, mode){ doneEl.querySelector(".dg").textContent = S.good>=8 ? "🌟" : S.good>=5 ? "👍" : "💪"; doneEl.classList.add("show"); if(S.good>=8) play(sndWin); + if(onProgress) onProgress({ attempts: ROUND, correct: S.good, stars: 0 }); } function next(){ S.done++;