fix(cefr): resolve authentic context sentence per term and repair legacy SRS cards

- Add resolve_context_sentence_for_term to replace placeholder blanks and lookup authentic sentences from cefr_questions or books
- Fix dual mistake ingestion in process_cefr_answer to assign distinct context to target and chosen distractor
- Provide authentic context_sentence in options_breakdown and pass it via data-context in cefr.js
- Add repair_mismatched_cefr_contexts in database.py to automatically repair cards with placeholder blanks
- Bump Service Worker cache to notes-v5.9
- Add test_cefr_context_resolution_and_repair covering resolution, dual ingestion, manual add, and DB repair
This commit is contained in:
Antigravity committed 2026-10-06 22:17:51 +03:00
1 parent 82b7a654ca
commit 3098d3016d
5 files changed
+230 -10

No files matched your search

+3 -2
View File
@@ -676,7 +676,7 @@ function renderOptionsBreakdown(breakdown) {
} else if (inLib) {
actionHtml = `<span class="wb-badge badge-in-lib"><i class="ph-check"></i> В библиотеке</span>`;
} else {
actionHtml = `<button type="button" class="btn btn-xs btn-outline btn-add-option-word" data-term="${escapeHtml(b.term)}">+ В словарь</button>`;
actionHtml = `<button type="button" class="btn btn-xs btn-outline btn-add-option-word" data-term="${escapeHtml(b.term)}" data-context="${escapeHtml(b.context_sentence || '')}">+ В словарь</button>`;
}
return `
@@ -708,7 +708,8 @@ function attachBreakdownListeners(container, contextSentence) {
btn.innerHTML = '...';
try {
await api.cefr.addWord(currentLevel, term, contextSentence || '');
const termContext = btn.dataset.context || contextSentence || '';
await api.cefr.addWord(currentLevel, term, termContext);
sessionStats.ingested++;
btn.outerHTML = '<span class="wb-badge badge-just-added"><i class="ph-check-circle-fill"></i> Добавлено!</span>';
showToast(`Слово «${term}» добавлено в утренний тренажёр SRS!`, 'success');