diff --git a/flask_app/app/static/js/editor.js b/flask_app/app/static/js/editor.js index 87f8e00..f007fb2 100644 --- a/flask_app/app/static/js/editor.js +++ b/flask_app/app/static/js/editor.js @@ -519,6 +519,22 @@ return data; } + async function refreshHintsInForm() { + const r = await fetch(`/api/tests/${TEST_ID}/editor`); + const data = await r.json().catch(() => ({})); + if (!r.ok || !Array.isArray(data.questions)) { + throw new Error(data.error || 'Не удалось обновить подсказки в форме.'); + } + const byOrder = (data.questions || []).slice().sort( + (a, b) => Number(a.questionOrder || 0) - Number(b.questionOrder || 0) + ); + // Надёжно подтягиваем подсказки: перерисовываем список вопросов с актуальными данными сервера. + questionsEl.innerHTML = ''; + byOrder.forEach((q) => questionsEl.appendChild(renderQuestion(q))); + renumber(); + scheduleDirtyCheck(); + } + // ─── actions ─────────────────────────────────────────────────────── $('#add-question').addEventListener('click', () => { @@ -665,6 +681,11 @@ const hr = await fetch(`/api/tests/${TEST_ID}/ai/hints/generate`, { method: 'POST' }); const hd = await hr.json().catch(() => ({})); if (hr.ok) { + try { + await refreshHintsInForm(); + } catch (_) { + // Не блокируем успех генерации вопросов. + } const skipped = Number(hd.skipped || 0); aiStatusEl.textContent = skipped ? `Готово: вопросы + подсказки (${hd.generated}, пропущено ${skipped}).` @@ -1527,6 +1548,11 @@ const r = await fetch(`/api/tests/${TEST_ID}/ai/hints/generate`, { method: 'POST' }); const data = await r.json().catch(() => ({})); if (!r.ok) throw new Error(data.error || 'Не удалось сгенерировать подсказки.'); + try { + await refreshHintsInForm(); + } catch (_) { + // Статус покажем как успешный; пользователь может перезагрузить страницу. + } const skipped = Number(data.skipped || 0); if (hintsStatusEl) { hintsStatusEl.textContent = data.failed