import { esc, sanitizeHtml } from './sanitize.js'; export function renderQuizQuestions(questions) { return (questions || []).map(function(q, idx) { var isMulti = q.question_type === 'multi'; var typeLabel = q.question_type === 'true_false' ? 'True / False' : isMulti ? 'Multiple Select' : 'Single Choice'; var inputType = isMulti ? 'checkbox' : 'radio'; var nameAttr = isMulti ? 'lh-qm-' + q.id : 'lh-q-' + q.id; var hint = isMulti ? '
Select all that apply
' : ''; return '
' + '
' + 'Q' + (idx + 1) + '' + '' + typeLabel + '' + '
' + '

' + sanitizeHtml(q.question_text) + '

' + hint + '
' + renderQuizOptions(q.options, inputType, nameAttr) + '
' + '
'; }).join(''); } export function renderQuizResultExplanations(results) { return (results || []).map(function(r, idx) { var icon = r.isCorrect ? '' : ''; var explHtml = ''; if (!r.isCorrect && r.selectedExplanation) { explHtml += '
Why incorrect: ' + esc(r.selectedExplanation) + '
'; } if (!r.isCorrect) { explHtml += '
Correct answer: ' + esc(r.correctOptionText) + '
'; } if (r.generalExplanation) { explHtml += '
Explanation: ' + sanitizeHtml(r.generalExplanation) + '
'; } return '
' + '
' + icon + ' Q' + (idx + 1) + ': ' + sanitizeHtml(r.questionText) + '
' + explHtml + '
'; }).join(''); } function renderQuizOptions(options, inputType, nameAttr) { return (options || []).map(function(opt) { return ''; }).join(''); }