Nihongo Challenge - N3

// オプションイベントのバインド (回答ロックされていなければ) if (!answerLocked) const optionDivs = document.querySelectorAll('.option-btn'); optionDivs.forEach(btn => btn.addEventListener('click', (e) => if (answerLocked) return; const idxAttr = btn.getAttribute('data-opt-index'); if (idxAttr !== null) const idxNum = parseInt(idxAttr, 10); if (!isNaN(idxNum)) evaluateAndLock(idxNum, q.correct, q.explanation); ); );

const optionsHtml = q.options.map((opt, idx) => let additionalClass = ""; let prefixLetter = String.fromCharCode(65 + idx); // A, B, C, D // スタイル判定: // 1) 正解の選択肢は緑ハイライト (正解がどこか示す) // 2) もし間違った選択肢を選んだ場合、その選択肢は赤背景 let isCorrectOption = (idx === correctIdx); let isSelectedWrongOption = (selectedIdx === idx && idx !== correctIdx); let isSelectedCorrect = (selectedIdx === idx && idx === correctIdx); nihongo challenge n3

// 次の問題へ遷移 function goToNextQuestion() if (!answerLocked) return; // 安全策 currentIndex++; updateProgressUI(); if (currentIndex < currentQuestions.length) renderCurrentQuestion(); else // クイズ完了 showResultScreen(); if (answerLocked) return