Fix explanation letter prefix after answer shuffle

After shuffleQuestion() reorders answers, the hardcoded A–D prefix in
each explanation text no longer matched the displayed option letter.
Replace the leading letter dynamically based on the shuffled position.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
chriseo 2026-06-15 23:13:49 +02:00
parent ea9a60e5aa
commit 2210ef4623

View file

@ -172,7 +172,9 @@ function handleAnswer(chosen) {
expDiv.innerHTML = expDiv.innerHTML =
'<div class="explanation-source">Proefexamen ' + q.exam + ', vraag ' + q.qnum + '</div>' + '<div class="explanation-source">Proefexamen ' + q.exam + ', vraag ' + q.qnum + '</div>' +
'<div class="explanation-label">Toelichting</div>' + '<div class="explanation-label">Toelichting</div>' +
q.explanation.map(e => '<p>' + e + '</p>').join(''); q.explanation.map((e, i) =>
'<p>' + e.replace(/^[A-D]\.\s*/, 'ABCD'[i] + '. ') + '</p>'
).join('');
const nextBtn = document.getElementById('next-btn'); const nextBtn = document.getElementById('next-btn');
nextBtn.style.display = 'inline-flex'; nextBtn.style.display = 'inline-flex';