Mehdi commited on
Commit
92295c9
·
1 Parent(s): ff2dbd5

fix: MCQ clicks broken — restore onclick in showMCQ, remove duplicate addEventListener

Browse files

btn.onclick in showMCQ is reliable (set fresh per question).
The addEventListener in wireButtons had timing issues with the _pp guard.
Keep mcqAnswered guard to prevent any double-count.

Files changed (1) hide show
  1. app.py +1 -5
app.py CHANGED
@@ -573,7 +573,7 @@ BRIDGE_JS = """() => {
573
  if (txt) txt.textContent = (data.choices && data.choices[l]) || '';
574
  if (btn) {
575
  btn.className = 'mcq-btn'; btn.disabled = false;
576
- btn.onclick = null;
577
  }
578
  }
579
  $('mcq-options')?.classList.remove('hidden');
@@ -711,10 +711,6 @@ BRIDGE_JS = """() => {
711
  if(qc) qc.scrollIntoView({behavior:'smooth',block:'start'});
712
  }],
713
  ];
714
- for (const l of ['A','B','C','D']) {
715
- const btn = $('mcq-'+l.toLowerCase());
716
- if (btn && !btn._pp) { btn._pp=true; btn.addEventListener('click', () => handleMCQAnswer(l)); }
717
- }
718
  for (const [id, fn] of pairs) {
719
  const el = $(id);
720
  if (el && !el._pp) { el._pp = true; el.addEventListener('click', fn); }
 
573
  if (txt) txt.textContent = (data.choices && data.choices[l]) || '';
574
  if (btn) {
575
  btn.className = 'mcq-btn'; btn.disabled = false;
576
+ btn.onclick = ((letter) => () => handleMCQAnswer(letter))(l);
577
  }
578
  }
579
  $('mcq-options')?.classList.remove('hidden');
 
711
  if(qc) qc.scrollIntoView({behavior:'smooth',block:'start'});
712
  }],
713
  ];
 
 
 
 
714
  for (const [id, fn] of pairs) {
715
  const el = $(id);
716
  if (el && !el._pp) { el._pp = true; el.addEventListener('click', fn); }