feat(exam-prep F8): слабые темы на дашборде + strategy=weak в тренажёре

This commit is contained in:
Maxim Dolgolyov
2026-05-29 11:38:55 +03:00
parent fe7d44aa83
commit 54b8d06c61
4 changed files with 182 additions and 9 deletions
+16 -3
View File
@@ -13,11 +13,16 @@
// Per-session state
let batch = null; // { strategy, session_id, tasks: [...] }
let strategy = readPersistedStrategy() || 'random';
let strategy = readStrategyFromUrl() || readPersistedStrategy() || 'random';
let count = readPersistedCount();
let finalized = false;
const results = new Map(); // taskId -> { isCorrect: 0|1|null, attempts: number }
function readStrategyFromUrl() {
const m = location.search.match(/[?&]strategy=(random|unsolved|weak)/);
return m ? m[1] : null;
}
/* ── Strategy persistence (local pref) ──────────────────────── */
function readPersistedStrategy() {
try { return localStorage.getItem(`exam_prep_${examKey}_practice_strategy`); } catch { return null; }
@@ -52,7 +57,8 @@
<button class="pr-strategy-btn ${strategy === 'unsolved' ? 'active' : ''}" data-strat="unsolved">
<i data-lucide="circle-dashed"></i> Только нерешённые
</button>
<button class="pr-strategy-btn disabled" disabled title="Появится в F8 после тегирования тем">
<button class="pr-strategy-btn ${strategy === 'weak' ? 'active' : ''}" data-strat="weak"
title="Топ-3 темы с худшей точностью (нужно ≥3 попыток в теме)">
<i data-lucide="target"></i> Слабые темы
</button>
</div>
@@ -192,7 +198,7 @@
</div>
<div class="pr-summary-stat">
<div class="ep-stat-label">Стратегия</div>
<div class="ep-stat-value" style="font-size:1.1rem">${strategy === 'unsolved' ? 'Нерешённые' : 'Случайные'}</div>
<div class="ep-stat-value" style="font-size:1.1rem">${strategyLabel(strategy)}</div>
</div>
</div>
<div class="ep-cta-row">
@@ -233,4 +239,11 @@
function escapeHtml(s) {
return String(s || '').replace(/[&<>"']/g, c => ({ '&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;', "'":'&#39;' }[c]));
}
function strategyLabel(s) {
if (s === 'unsolved') return 'Нерешённые';
if (s === 'weak') return 'Слабые темы';
if (s === 'unsolved-fallback') return 'Нерешённые (fallback)';
return 'Случайные';
}
})();