Миграция questions.ai_hint и подсказки в редакторе теста
- Alembic 0003: колонка ai_hint (TEXT NULL) - API черновика: отдаём aiHint, сохраняем из payload - Карточка вопроса: textarea подсказки для прохождения Made-with: Cursor
This commit is contained in:
@@ -109,6 +109,14 @@
|
||||
syncOptionInputTypes(node);
|
||||
updateOptionsCounter(node);
|
||||
updateAiButtonLabel(node);
|
||||
|
||||
const hintEl = $('.q-hint', node);
|
||||
if (hintEl) {
|
||||
hintEl.value = q.aiHint || '';
|
||||
const rh = () => autoResize(hintEl);
|
||||
hintEl.addEventListener('input', () => { rh(); scheduleDirtyCheck(); });
|
||||
requestAnimationFrame(rh);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -207,6 +215,8 @@
|
||||
const qTextEl = $('.q-text', node);
|
||||
qTextEl.value = '';
|
||||
autoResize(qTextEl);
|
||||
const qh = $('.q-hint', node);
|
||||
if (qh) { qh.value = ''; autoResize(qh); }
|
||||
$$('.opt-text', node).forEach((t) => { t.value = ''; autoResize(t); });
|
||||
$$('.opt-correct', node).forEach((c) => { c.checked = false; });
|
||||
updateAiButtonLabel(node);
|
||||
@@ -406,16 +416,20 @@
|
||||
// ─── collect ───────────────────────────────────────────────────────
|
||||
|
||||
function collectPayload() {
|
||||
const questions = $$('#questions .q-item:not(.q-removed)').map((li, i) => ({
|
||||
const questions = $$('#questions .q-item:not(.q-removed)').map((li, i) => {
|
||||
const hintVal = ($('.q-hint', li) && $('.q-hint', li).value.trim()) || '';
|
||||
return {
|
||||
text: $('.q-text', li).value.trim(),
|
||||
question_order: i + 1,
|
||||
hasMultipleAnswers: $('.q-multi', li).checked,
|
||||
aiHint: hintVal || null,
|
||||
options: $$('.opt-item', li).map((op, j) => ({
|
||||
text: $('.opt-text', op).value.trim(),
|
||||
isCorrect: $('.opt-correct', op).checked,
|
||||
option_order: j + 1,
|
||||
})),
|
||||
}));
|
||||
};
|
||||
});
|
||||
const payload = {
|
||||
title: titleEl.value.trim() || null,
|
||||
description: descEl.value.trim() || null,
|
||||
|
||||
Reference in New Issue
Block a user