fix(admin): отображать HTML-разметку вопросов в секции «Вопросы» при allow_html

Секция игнорировала флаг allow_html и всегда экранировала текст/опции/
пояснение, из-за чего <div class=task-figure><img>, <b> и пр. показывались
как сырой текст. Теперь — как в test-run.html: allow_html ? raw : esc.
Также добавлен q.allow_html в SELECT списка вопросов (его не было в ответе API).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maxim Dolgolyov
2026-05-30 21:29:00 +03:00
parent 5f481f5d11
commit 7c32501e18
2 changed files with 4 additions and 4 deletions
@@ -44,7 +44,7 @@ function list(req, res) {
const sql = `
SELECT q.id, q.text, q.type, q.correct_text, q.difficulty, q.explanation, q.image,
q.year, q.source_type,
q.year, q.source_type, q.allow_html,
t.name AS topic, t.id AS topic_id,
s.name AS subject_name, s.slug AS subject_slug,
(SELECT json_group_array(json_object(
+3 -3
View File
@@ -71,15 +71,15 @@
const diffCls = `diff-${q.difficulty}`;
const optsHtml = (q.options || []).map(o =>
`<div class="q-opt-row ${o.is_correct ? 'correct' : ''}">
<span class="q-opt-icon">${o.is_correct ? '<i data-lucide="check" style="width:13px;height:13px"></i>' : '<svg class="ic" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"/></svg>'}</span>${esc(o.text)}
<span class="q-opt-icon">${o.is_correct ? '<i data-lucide="check" style="width:13px;height:13px"></i>' : '<svg class="ic" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"/></svg>'}</span>${q.allow_html ? o.text : esc(o.text)}
</div>`).join('');
const explHtml = q.explanation
? `<div class="q-expl"><strong>Пояснение:</strong> ${esc(q.explanation)}</div>` : '';
? `<div class="q-expl"><strong>Пояснение:</strong> ${q.allow_html ? q.explanation : esc(q.explanation)}</div>` : '';
return `<div class="q-card" id="qcard-${q.id}">
<div class="q-card-head">
<span class="q-card-num">#${q.id}</span>
<div class="q-card-body" onclick="toggleQDetail(${q.id})">
<div class="q-card-text">${esc(q.text)}</div>
<div class="q-card-text">${q.allow_html ? q.text : esc(q.text)}</div>
<div class="q-card-meta">
${q.subject_name ? `<span class="q-badge q-badge-subj">${esc(q.subject_name)}</span>` : ''}
${q.topic ? `<span class="q-badge q-badge-topic">${esc(q.topic)}</span>` : ''}