Тесты и опросы: описания и пояснения в Markdown
- quizzes.description и описания вопросов рендерятся через WhatIDoMD.render на страницах прохождения и в списке (mdPlain для карточки) - Пояснения к вариантам — WhatIDoMD.inline - Системный промпт ИИ-генерации: description теста всегда в Markdown, пояснения по запросу - Стили .qz-desc / .qz-q-desc / .qp-desc (п, списки, код, таблицы, цитаты) - quizzes.html подключает js/md.js
This commit is contained in:
@@ -38,6 +38,13 @@
|
||||
return esc2(text);
|
||||
}
|
||||
|
||||
function renderMdInline(text) {
|
||||
if (typeof WhatIDoMD !== 'undefined' && WhatIDoMD && typeof WhatIDoMD.inline === 'function') {
|
||||
return WhatIDoMD.inline(String(text || ''));
|
||||
}
|
||||
return esc2(text);
|
||||
}
|
||||
|
||||
function fileUrl(asset) {
|
||||
const name = String(asset.path || '').split('/').pop();
|
||||
const play = asset.kind === 'audio' || asset.kind === 'video' ? '&play=1' : '';
|
||||
@@ -108,13 +115,13 @@
|
||||
const input = q.kind === 'multiple'
|
||||
? `<input type="checkbox" data-q="${q.id}" data-opt="${o.id}"${checked}>`
|
||||
: `<input type="radio" name="q${q.id}" data-q="${q.id}" data-opt="${o.id}"${checked}>`;
|
||||
return `<label class="qz-opt">${input}<span class="qz-opt-text">${esc2(o.text)}${o.description ? `<div class="qz-opt-desc">${esc2(o.description)}</div>` : ''}${assetsHtml(o.assets)}</span></label>`;
|
||||
return `<label class="qz-opt">${input}<span class="qz-opt-text">${esc2(o.text)}${o.description ? `<div class="qz-opt-desc">${renderMdInline(o.description)}</div>` : ''}${assetsHtml(o.assets)}</span></label>`;
|
||||
}).join('');
|
||||
body = `<div class="qz-opts${q.options_inline ? ' inline' : ''}">${items}</div>`;
|
||||
}
|
||||
return `<section class="qz-q">
|
||||
<div class="qz-q-head"><span class="qz-q-num">${index + 1}</span><span class="qz-q-text">${esc2(q.text)}</span></div>
|
||||
${q.description ? `<div class="qz-q-desc">${esc2(q.description)}</div>` : ''}
|
||||
${q.description ? `<div class="qz-q-desc">${renderMd(q.description)}</div>` : ''}
|
||||
${assetsHtml(q.assets)}
|
||||
<div style="margin-top:8px">${body}</div>
|
||||
</section>`;
|
||||
|
||||
+10
-3
@@ -65,6 +65,13 @@
|
||||
return esc(text);
|
||||
}
|
||||
|
||||
function renderMdInline(text) {
|
||||
if (typeof WhatIDoMD !== 'undefined' && WhatIDoMD && typeof WhatIDoMD.inline === 'function') {
|
||||
return WhatIDoMD.inline(String(text || ''));
|
||||
}
|
||||
return esc(text);
|
||||
}
|
||||
|
||||
function renderHead() {
|
||||
const q = state.quiz;
|
||||
const parts = [
|
||||
@@ -156,14 +163,14 @@
|
||||
body = `<select class="settings-input qz-answer" data-q="${q.id}">
|
||||
<option value="">— выберите —</option>
|
||||
${opts.map(o => `<option value="${o.id}"${chosen.has(Number(o.id)) ? ' selected' : ''}>${esc(o.text)}</option>`).join('')}
|
||||
</select>${opts.map(o => o.description ? `<div class="qz-opt-desc" style="margin-top:6px">${esc(o.text)} — ${esc(o.description)}</div>` : '').join('')}`;
|
||||
</select>${opts.map(o => o.description ? `<div class="qz-opt-desc" style="margin-top:6px">${esc(o.text)} — ${renderMdInline(o.description)}</div>` : '').join('')}`;
|
||||
} else {
|
||||
const items = opts.map(o => {
|
||||
const checked = chosen.has(Number(o.id)) ? ' checked' : '';
|
||||
const input = q.kind === 'multiple'
|
||||
? `<input type="checkbox" data-q="${q.id}" data-opt="${o.id}"${checked}>`
|
||||
: `<input type="radio" name="q${q.id}" data-q="${q.id}" data-opt="${o.id}"${checked}>`;
|
||||
return `<label class="qz-opt">${input}<span class="qz-opt-text">${esc(o.text)}${o.description ? `<div class="qz-opt-desc">${esc(o.description)}</div>` : ''}${assetsHtml(o.assets)}</span></label>`;
|
||||
return `<label class="qz-opt">${input}<span class="qz-opt-text">${esc(o.text)}${o.description ? `<div class="qz-opt-desc">${renderMdInline(o.description)}</div>` : ''}${assetsHtml(o.assets)}</span></label>`;
|
||||
}).join('');
|
||||
body = `<div class="qz-opts${q.options_inline ? ' inline' : ''}">${items}</div>`;
|
||||
}
|
||||
@@ -171,7 +178,7 @@
|
||||
<div class="qz-q-head"><span class="qz-q-num">${index + 1}</span>
|
||||
<span class="qz-q-text">${esc(q.text)}</span>
|
||||
</div>
|
||||
${q.description ? `<div class="qz-q-desc">${esc(q.description)}</div>` : ''}
|
||||
${q.description ? `<div class="qz-q-desc">${renderMd(q.description)}</div>` : ''}
|
||||
${assetsHtml(q.assets)}
|
||||
<div style="margin-top:8px">${body}</div>
|
||||
</section>`;
|
||||
|
||||
+10
-1
@@ -19,6 +19,15 @@
|
||||
return esc(String(s == null ? '' : s)).replace(/"/g, '"');
|
||||
}
|
||||
|
||||
function mdPlain(text) {
|
||||
const raw = String(text || '').trim();
|
||||
if (!raw) return '';
|
||||
if (typeof WhatIDoMD === 'undefined' || !WhatIDoMD || typeof WhatIDoMD.render !== 'function') return raw;
|
||||
const box = document.createElement('div');
|
||||
box.innerHTML = WhatIDoMD.render(raw);
|
||||
return (box.textContent || '').replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
|
||||
function filters() {
|
||||
return {
|
||||
search: document.getElementById('quizSearch').value.trim(),
|
||||
@@ -68,7 +77,7 @@
|
||||
<div class="quiz-cover">${cover}<span class="quiz-kind-badge${q.kind === 'survey' ? ' survey' : ''}">${kindLabel(q.kind)}</span></div>
|
||||
<div class="quiz-body">
|
||||
<div class="quiz-title">${esc(q.title || 'Без названия')}</div>
|
||||
${q.description ? `<div class="quiz-desc">${esc(q.description)}</div>` : ''}
|
||||
${q.description ? `<div class="quiz-desc">${esc(mdPlain(q.description))}</div>` : ''}
|
||||
<div class="quiz-meta">
|
||||
<span>Вопросов: <b>${q.question_count}</b></span>
|
||||
<span>${attempts}</span>
|
||||
|
||||
Reference in New Issue
Block a user