fix: resolve bugs 01 through 08 and set Ollama TTL to 1h

This commit is contained in:
2026-10-07 19:19:49 +03:00
parent a01bf64445
commit 9bbc9473de
14 changed files with 368 additions and 110 deletions
+9 -9
View File
@@ -4,7 +4,7 @@
// =======================================================================
import { api } from './api.js';
import { ui, escapeHtml, showToast, switchView, shuffleArray, escapeRegex, playAudio, playTextSpeech } from './ui.js';
import { ui, escapeHtml, showToast, switchView, shuffleArray, escapeRegex, playAudio, playTextSpeech, cleanPromptTranslation } from './ui.js';
let presets = [];
let currentPreset = null;
@@ -762,20 +762,20 @@ async function runVocabStep(step, container) {
// Mode A: 4 Options Quiz
// -----------------------------------------------------------------------
function renderQuizCard(card) {
const correctText = card.translation;
const correctText = cleanPromptTranslation(card.translation);
const candidates = [
...cards.filter(c => c.id !== card.id && c.translation).map(c => c.translation),
...distractorPool.filter(t => t && t !== correctText)
...cards.filter(c => c.id !== card.id && c.translation).map(c => cleanPromptTranslation(c.translation)),
...distractorPool.filter(t => t && cleanPromptTranslation(t) !== correctText).map(t => cleanPromptTranslation(t))
];
const uniqueCandidates = [...new Set(candidates.filter(t => t !== correctText))];
shuffleArray(uniqueCandidates);
const options = [correctText, ...uniqueCandidates.slice(0, 3)];
let options = [correctText, ...uniqueCandidates.slice(0, 3)];
const fallbackOptions = ['определять', 'проверять', 'исследовать', 'сохранять', 'показывать', 'понимать', 'находить', 'создавать'];
while (options.length < 4) {
const f = fallbackOptions.find(o => !options.includes(o)) || `Вариант ${options.length + 1}`;
options.push(f);
}
shuffleArray(options);
options = shuffleArray(options);
let answered = false;
@@ -1050,7 +1050,7 @@ async function runVocabStep(step, container) {
<div class="step-prompt-display text-center mt-3">
<span class="text-muted text-sm">Переведите на английский:</span>
<h2 class="display-term display-prompt">${escapeHtml(card.translation)}</h2>
<h2 class="display-term display-prompt">${escapeHtml(cleanPromptTranslation(card.translation))}</h2>
</div>
${card.context_sentence ? `
@@ -1171,7 +1171,7 @@ async function runVocabStep(step, container) {
<button id="dictation-big-audio-btn" class="btn btn-secondary btn-lg dictation-play-btn" type="button">
🔊 Прослушать слово (Пробел)
</button>
${card.translation ? `<p class="dictation-hint text-muted mt-2">Подсказка перевода: ${escapeHtml(card.translation)}</p>` : ''}
${card.translation ? `<p class="dictation-hint text-muted mt-2">Подсказка перевода: ${escapeHtml(cleanPromptTranslation(card.translation))}</p>` : ''}
</div>
<form id="lesson-dictation-form" class="mt-4">
@@ -1656,7 +1656,7 @@ async function runListeningStep(step, container) {
}
const data = await api.listening.getExercise(step.topic || 'all');
const scenario = data.scenario;
const scenario = (data && (data.scenario || data)) || {};
container.innerHTML = `
<div class="step-card-box">