660e7e2747
Until now the 'gamification' feature flag did nothing: it had no row in
app_settings, the admin couldn't toggle it, awardXP/awardCoins ignored
it, and the CSS only hid three dashboard widgets — XP bars in textbooks
stayed visible regardless.
Phase 1 closes every hole.
Backend (source of truth):
• migration 029 seeds feature_gamification_enabled=1
• new isGamificationEnabled() helper in gamification/_shared.js with a
30s cache + invalidateGamificationCache() for instant admin toggles
• awardXP / awardCoins / updateStreak / unlockAchievement /
checkAchievements all bail out when the flag is off
• /api/gamification/* and /api/shop/* (user routes) return 404 when
disabled; admin routes remain open so the switch itself is reachable
• adminController.updateFeatures gains 'gamification' in the allow-list
and invalidates the cache on flip
Frontend:
• LS.isGamificationEnabled() (synchronous, populated by loadFeatures)
so xp.js + applyCosmetics can bail without a round-trip
• xp.js load/add/flush become no-ops when the flag is off
• applyCosmetics skips the round-trip when off
• CSS .no-gamification rule expanded to cover .hero-xp-badge, .po-xp,
.xp-card, .xp-bar, #frames-section, and a universal [data-gamified]
hook for future blocks
Textbooks (Variant 2 of the plan):
• backend/scripts/wrap_textbook_xp.py — idempotent script that adds
data-gamified to 167 XP tags across 63 textbook files (chapters +
hubs, all subjects/grades). Single CSS rule now hides everything.
Verified end-to-end: with the flag off, awardXP/awardCoins write nothing;
flipping back restores normal behavior.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
354 lines
18 KiB
HTML
354 lines
18 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="ru">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||
<meta http-equiv="Pragma" content="no-cache">
|
||
<meta http-equiv="Expires" content="0">
|
||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||
<title>Алгебра 7 класс — учебник</title>
|
||
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&family=Inter:wght@400;500;600;700&family=Unbounded:wght@400;700;800;900&display=swap" rel="stylesheet">
|
||
<script src="/js/api.js" defer></script>
|
||
<script src="/js/xp.js" defer></script>
|
||
<style>
|
||
:root{
|
||
--bg:#fdf2f8; --card:#fff;
|
||
--text:#1a1a2e; --muted:#6b5b73;
|
||
--border:#fce7f3;
|
||
--pri:#db2777; --pri-d:#9d174d;
|
||
--pri-soft:#fce7f3;
|
||
--ch1:#d97706; --ch1-d:#b45309;
|
||
--ch2:#059669; --ch2-d:#047857;
|
||
--ch3:#7c3aed; --ch3-d:#6d28d9;
|
||
--ch4:#0891b2; --ch4-d:#0e7490;
|
||
--sh:0 4px 16px rgba(219,39,119,.10);
|
||
--sh-h:0 12px 36px rgba(219,39,119,.18);
|
||
}
|
||
html.dark{
|
||
--bg:#1a0f1a; --card:#2a1929;
|
||
--text:#f5e6f0; --muted:#b0a0b0;
|
||
--border:#5a2a5a;
|
||
--pri-soft:rgba(219,39,119,.16);
|
||
}
|
||
*{margin:0;padding:0;box-sizing:border-box}
|
||
html,body{min-height:100vh}
|
||
body{font-family:'Inter',system-ui,sans-serif;background:var(--bg);color:var(--text);line-height:1.55;transition:background .25s,color .25s}
|
||
|
||
/* HEADER */
|
||
.hdr{position:relative;background:linear-gradient(110deg,#9d174d 0%,#db2777 55%,#f472b6 100%);color:#fff;padding:32px 24px 28px;overflow:hidden;border-bottom:2px solid rgba(255,180,210,.15)}
|
||
.hdr::before{content:'АЛГЕБРА';position:absolute;right:-14px;top:-18%;font-family:'Outfit',sans-serif;font-size:clamp(5rem,16vw,13rem);font-weight:900;letter-spacing:-.04em;color:transparent;-webkit-text-stroke:1.5px rgba(255,220,235,.10);line-height:1;pointer-events:none;user-select:none}
|
||
.hdr-inner{position:relative;z-index:1;max-width:1100px;margin:0 auto;display:flex;align-items:center;gap:18px;flex-wrap:wrap}
|
||
.hdr-back{display:inline-flex;align-items:center;gap:8px;padding:8px 14px;background:rgba(255,255,255,.14);border-radius:9px;color:#fff;text-decoration:none;font-size:.85rem;font-weight:600;transition:background .15s}
|
||
.hdr-back:hover{background:rgba(255,255,255,.24)}
|
||
.hdr h1{font-family:'Outfit',sans-serif;font-size:1.85rem;font-weight:900;letter-spacing:-.01em}
|
||
.hdr-sub{font-size:.92rem;opacity:.85;margin-top:4px}
|
||
.hdr-side{margin-left:auto;display:flex;gap:8px}
|
||
.hdr-btn{padding:8px 12px;background:rgba(255,255,255,.14);border:none;color:#fff;border-radius:9px;cursor:pointer;font-weight:600;font-size:.82rem;display:inline-flex;align-items:center;gap:6px;transition:background .15s;font-family:inherit}
|
||
.hdr-btn:hover{background:rgba(255,255,255,.24)}
|
||
.ic{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
|
||
|
||
main{max-width:1100px;margin:0 auto;padding:32px 24px 60px}
|
||
|
||
/* OVERALL PROGRESS */
|
||
.prog-overall{background:linear-gradient(135deg,var(--pri-soft),rgba(124,58,237,.10));border:1px solid var(--border);border-radius:14px;padding:14px 18px;margin-bottom:28px;display:flex;gap:14px;align-items:center;flex-wrap:wrap}
|
||
.po-icon{width:46px;height:46px;border-radius:12px;background:linear-gradient(135deg,#db2777,#7c3aed);color:#fff;display:flex;align-items:center;justify-content:center;flex-shrink:0;font-family:'Outfit',sans-serif;font-size:1.4rem;font-weight:900;font-style:italic}
|
||
.po-text{flex:1;min-width:160px}
|
||
.po-label{font-size:.78rem;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:4px}
|
||
.po-bar{height:8px;background:rgba(219,39,119,.12);border-radius:5px;overflow:hidden;margin-top:6px}
|
||
.po-fill{height:100%;background:linear-gradient(90deg,var(--pri),#7c3aed);border-radius:5px;transition:width .5s}
|
||
.po-xp{display:inline-flex;align-items:center;gap:6px;padding:6px 14px;background:linear-gradient(135deg,#f59e0b,var(--pri));color:#fff;border-radius:99px;font-size:.8rem;font-weight:800;font-family:'Unbounded',sans-serif;letter-spacing:.02em;box-shadow:0 4px 12px rgba(219,39,119,.22)}
|
||
|
||
/* CHAPTER GRID — 4 chapters: 1 / 2 / 4 columns */
|
||
.ch-grid{display:grid;grid-template-columns:1fr;gap:18px;margin-bottom:30px}
|
||
@media(min-width:600px){.ch-grid{grid-template-columns:1fr 1fr}}
|
||
@media(min-width:1000px){.ch-grid{grid-template-columns:repeat(4,1fr)}}
|
||
|
||
.ch-card{background:var(--card);border:1.5px solid var(--border);border-radius:18px;overflow:hidden;display:flex;flex-direction:column;transition:transform .2s,box-shadow .2s,border-color .2s;cursor:pointer;text-decoration:none;color:inherit}
|
||
.ch-card:hover{transform:translateY(-4px);box-shadow:var(--sh-h)}
|
||
.ch-cover{padding:22px 22px 18px;color:#fff;position:relative;overflow:hidden}
|
||
.ch-cover-wm{position:absolute;right:-8px;top:-22px;font-size:6rem;font-weight:900;font-family:'Outfit',sans-serif;line-height:1;color:rgba(255,255,255,.18);pointer-events:none}
|
||
.ch-num{display:inline-block;padding:4px 10px;background:rgba(255,255,255,.22);border-radius:99px;font-size:.7rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;margin-bottom:8px;position:relative;z-index:1}
|
||
.ch-title{font-family:'Outfit',sans-serif;font-size:1.1rem;font-weight:800;letter-spacing:-.01em;position:relative;z-index:1;line-height:1.3}
|
||
.ch-range{font-size:.84rem;opacity:.88;margin-top:4px;position:relative;z-index:1;font-weight:500}
|
||
|
||
.ch-cover.ch1{background:linear-gradient(135deg,#92400e,#d97706 60%,#fbbf24)}
|
||
.ch-cover.ch2{background:linear-gradient(135deg,#064e3b,#059669 60%,#34d399)}
|
||
.ch-cover.ch3{background:linear-gradient(135deg,#3b0764,#7c3aed 60%,#a78bfa)}
|
||
.ch-cover.ch4{background:linear-gradient(135deg,#164e63,#0891b2 60%,#22d3ee)}
|
||
|
||
.ch-body{padding:16px 20px 18px;display:flex;flex-direction:column;flex:1}
|
||
.ch-desc{font-size:.88rem;color:var(--text);opacity:.82;flex:1;margin-bottom:12px;line-height:1.55}
|
||
|
||
.ch-prog{margin-bottom:12px}
|
||
.ch-prog-label{display:flex;justify-content:space-between;font-size:.74rem;color:var(--muted);font-weight:600;margin-bottom:4px}
|
||
.ch-prog-bar{height:6px;background:rgba(0,0,0,.07);border-radius:4px;overflow:hidden}
|
||
.ch-prog-fill{height:100%;border-radius:4px;transition:width .5s}
|
||
.ch-card.ch1-card .ch-prog-fill{background:linear-gradient(90deg,var(--ch1),var(--ch1-d))}
|
||
.ch-card.ch2-card .ch-prog-fill{background:linear-gradient(90deg,var(--ch2),var(--ch2-d))}
|
||
.ch-card.ch3-card .ch-prog-fill{background:linear-gradient(90deg,var(--ch3),var(--ch3-d))}
|
||
.ch-card.ch4-card .ch-prog-fill{background:linear-gradient(90deg,var(--ch4),var(--ch4-d))}
|
||
|
||
.ch-action{display:flex;align-items:center;justify-content:space-between;padding:10px 14px;border-radius:11px;font-weight:700;font-size:.9rem;color:#fff;transition:filter .15s}
|
||
.ch-action:hover{filter:brightness(1.08)}
|
||
.ch-card.ch1-card .ch-action{background:linear-gradient(135deg,var(--ch1),#fbbf24)}
|
||
.ch-card.ch2-card .ch-action{background:linear-gradient(135deg,var(--ch2),#34d399)}
|
||
.ch-card.ch3-card .ch-action{background:linear-gradient(135deg,var(--ch3),#a78bfa)}
|
||
.ch-card.ch4-card .ch-action{background:linear-gradient(135deg,var(--ch4),#22d3ee)}
|
||
|
||
/* ACHIEVEMENT STRIP */
|
||
.ach-strip{background:var(--card);border:1.5px solid var(--border);border-radius:16px;padding:18px 22px;margin-bottom:28px;display:flex;align-items:center;gap:16px;transition:border-color .4s,box-shadow .4s}
|
||
.ach-strip.lit{border-color:#f59e0b;box-shadow:0 0 0 3px rgba(245,158,11,.18)}
|
||
.ach-icon{width:52px;height:52px;border-radius:14px;background:rgba(0,0,0,.06);display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background .4s}
|
||
.ach-strip.lit .ach-icon{background:linear-gradient(135deg,#fbbf24,#f59e0b)}
|
||
.ach-icon svg{width:28px;height:28px;stroke:var(--muted);fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
|
||
.ach-strip.lit .ach-icon svg{stroke:#fff}
|
||
.ach-text{flex:1}
|
||
.ach-title{font-weight:800;font-size:1.02rem;color:var(--text)}
|
||
.ach-sub{font-size:.85rem;color:var(--muted);margin-top:2px}
|
||
.ach-strip.lit .ach-title{color:#92400e}
|
||
|
||
.foot{text-align:center;padding:24px 16px;color:var(--muted);font-size:.78rem;border-top:1px solid var(--border)}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
|
||
<header class="hdr">
|
||
<div class="hdr-inner">
|
||
<div>
|
||
<a href="/textbooks" class="hdr-back">
|
||
<svg class="ic" viewBox="0 0 24 24"><polyline points="15 18 9 12 15 6"/></svg>
|
||
К каталогу
|
||
</a>
|
||
</div>
|
||
<div>
|
||
<h1>Алгебра — 7 класс</h1>
|
||
<div class="hdr-sub">Полный курс: степени, многочлены, уравнения, системы</div>
|
||
</div>
|
||
<div class="hdr-side">
|
||
<button id="theme-btn" class="hdr-btn" title="Сменить тему">
|
||
<svg class="ic" viewBox="0 0 24 24"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>
|
||
<span id="theme-lab">Тёмная</span>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</header>
|
||
|
||
<main>
|
||
|
||
<section class="prog-overall">
|
||
<div class="po-icon">x</div>
|
||
<div class="po-text">
|
||
<div class="po-label">Общий прогресс по курсу</div>
|
||
<div id="overall-text" style="font-size:1.05rem;font-weight:700">Загрузка...</div>
|
||
<div class="po-bar"><div id="overall-fill" class="po-fill" style="width:0%"></div></div>
|
||
</div>
|
||
<div id="hero-xp-badge" class="po-xp" style="display:none" data-gamified>0 XP</div>
|
||
</section>
|
||
|
||
<div class="ch-grid">
|
||
|
||
<a href="/textbook/algebra-7-ch1" class="ch-card ch1-card" id="ch-1">
|
||
<div class="ch-cover ch1">
|
||
<div class="ch-cover-wm">aⁿ</div>
|
||
<div class="ch-num">Глава 1</div>
|
||
<div class="ch-title">Степень с натуральным и целым показателем</div>
|
||
<div class="ch-range">§1–§3 + Финал</div>
|
||
</div>
|
||
<div class="ch-body">
|
||
<div class="ch-desc">Степень с натуральным и целым показателем, свойства степени, стандартный вид числа.</div>
|
||
<div class="ch-prog">
|
||
<div class="ch-prog-label"><span>Прогресс</span><span id="prog-1">0%</span></div>
|
||
<div class="ch-prog-bar"><div class="ch-prog-fill" id="fill-1" style="width:0%"></div></div>
|
||
</div>
|
||
<div class="ch-action">
|
||
<span id="btn-1">Открыть главу</span>
|
||
<svg class="ic" viewBox="0 0 24 24"><polyline points="9 18 15 12 9 6"/></svg>
|
||
</div>
|
||
</div>
|
||
</a>
|
||
|
||
<a href="/textbook/algebra-7-ch2" class="ch-card ch2-card" id="ch-2">
|
||
<div class="ch-cover ch2">
|
||
<div class="ch-cover-wm">P(x)</div>
|
||
<div class="ch-num">Глава 2</div>
|
||
<div class="ch-title">Выражения и их преобразования</div>
|
||
<div class="ch-range">§4–§14 + Финал</div>
|
||
</div>
|
||
<div class="ch-body">
|
||
<div class="ch-desc">Тождества, одночлены и многочлены, действия с ними, формулы сокращённого умножения, разложение на множители.</div>
|
||
<div class="ch-prog">
|
||
<div class="ch-prog-label"><span>Прогресс</span><span id="prog-2">0%</span></div>
|
||
<div class="ch-prog-bar"><div class="ch-prog-fill" id="fill-2" style="width:0%"></div></div>
|
||
</div>
|
||
<div class="ch-action">
|
||
<span id="btn-2">Открыть главу</span>
|
||
<svg class="ic" viewBox="0 0 24 24"><polyline points="9 18 15 12 9 6"/></svg>
|
||
</div>
|
||
</div>
|
||
</a>
|
||
|
||
<a href="/textbook/algebra-7-ch3" class="ch-card ch3-card" id="ch-3">
|
||
<div class="ch-cover ch3">
|
||
<div class="ch-cover-wm">y=kx</div>
|
||
<div class="ch-num">Глава 3</div>
|
||
<div class="ch-title">Линейные уравнения. Неравенства. Функция</div>
|
||
<div class="ch-range">§15–§20 + Финал</div>
|
||
</div>
|
||
<div class="ch-body">
|
||
<div class="ch-desc">Линейные уравнения и текстовые задачи, числовые и линейные неравенства, функция и её график, линейная функция.</div>
|
||
<div class="ch-prog">
|
||
<div class="ch-prog-label"><span>Прогресс</span><span id="prog-3">0%</span></div>
|
||
<div class="ch-prog-bar"><div class="ch-prog-fill" id="fill-3" style="width:0%"></div></div>
|
||
</div>
|
||
<div class="ch-action">
|
||
<span id="btn-3">Открыть главу</span>
|
||
<svg class="ic" viewBox="0 0 24 24"><polyline points="9 18 15 12 9 6"/></svg>
|
||
</div>
|
||
</div>
|
||
</a>
|
||
|
||
<a href="/textbook/algebra-7-ch4" class="ch-card ch4-card" id="ch-4">
|
||
<div class="ch-cover ch4">
|
||
<div class="ch-cover-wm">{</div>
|
||
<div class="ch-num">Глава 4</div>
|
||
<div class="ch-title">Системы линейных уравнений</div>
|
||
<div class="ch-range">§21–§25 + Финал</div>
|
||
</div>
|
||
<div class="ch-body">
|
||
<div class="ch-desc">Линейные уравнения с двумя переменными, графический способ, системы и способы их решения, текстовые задачи.</div>
|
||
<div class="ch-prog">
|
||
<div class="ch-prog-label"><span>Прогресс</span><span id="prog-4">0%</span></div>
|
||
<div class="ch-prog-bar"><div class="ch-prog-fill" id="fill-4" style="width:0%"></div></div>
|
||
</div>
|
||
<div class="ch-action">
|
||
<span id="btn-4">Открыть главу</span>
|
||
<svg class="ic" viewBox="0 0 24 24"><polyline points="9 18 15 12 9 6"/></svg>
|
||
</div>
|
||
</div>
|
||
</a>
|
||
|
||
</div>
|
||
|
||
<div class="ach-strip" id="ach-strip">
|
||
<div class="ach-icon">
|
||
<svg viewBox="0 0 24 24">
|
||
<path d="M6 9H4l-1-3h18l-1 3h-2M6 9l1 6h10l1-6M6 9h12"/><path d="M9 21h6M12 15v6"/>
|
||
</svg>
|
||
</div>
|
||
<div class="ach-text">
|
||
<div class="ach-title">Магистр алгебры 7</div>
|
||
<div class="ach-sub" id="ach-sub">Прочитайте все 25 параграфов четырёх глав, чтобы получить достижение</div>
|
||
</div>
|
||
</div>
|
||
|
||
</main>
|
||
|
||
<footer class="foot">
|
||
Интерактивный учебник «Алгебра — 7 класс» · LearnSpace
|
||
</footer>
|
||
|
||
<script>
|
||
'use strict';
|
||
|
||
/* THEME */
|
||
(function(){
|
||
var saved = localStorage.getItem('algebra7_theme') || localStorage.getItem('theme') || 'light';
|
||
if (saved === 'dark') document.documentElement.classList.add('dark');
|
||
var lab = document.getElementById('theme-lab');
|
||
if (lab) lab.textContent = saved === 'dark' ? 'Светлая' : 'Тёмная';
|
||
document.getElementById('theme-btn').addEventListener('click', function(){
|
||
document.documentElement.classList.toggle('dark');
|
||
var dark = document.documentElement.classList.contains('dark');
|
||
localStorage.setItem('algebra7_theme', dark ? 'dark' : 'light');
|
||
localStorage.setItem('theme', dark ? 'dark' : 'light');
|
||
if (lab) lab.textContent = dark ? 'Светлая' : 'Тёмная';
|
||
});
|
||
})();
|
||
|
||
/* PROGRESS */
|
||
var TOTAL = 25;
|
||
var CH_PARA = {
|
||
'algebra-7-ch1': 3,
|
||
'algebra-7-ch2': 11,
|
||
'algebra-7-ch3': 6,
|
||
'algebra-7-ch4': 5,
|
||
};
|
||
var CH_IDX = {
|
||
'algebra-7-ch1': 1,
|
||
'algebra-7-ch2': 2,
|
||
'algebra-7-ch3': 3,
|
||
'algebra-7-ch4': 4,
|
||
};
|
||
|
||
function setChProg(idx, readCount, total) {
|
||
var pct = total ? Math.round(readCount * 100 / total) : 0;
|
||
var labelEl = document.getElementById('prog-' + idx);
|
||
var fillEl = document.getElementById('fill-' + idx);
|
||
var btnEl = document.getElementById('btn-' + idx);
|
||
if (labelEl) labelEl.textContent = pct + '%';
|
||
if (fillEl) fillEl.style.width = pct + '%';
|
||
if (btnEl) {
|
||
if (readCount > 0 && readCount < total) btnEl.textContent = 'Продолжить';
|
||
else if (readCount >= total) btnEl.textContent = 'Открыть снова';
|
||
else btnEl.textContent = 'Открыть главу';
|
||
}
|
||
return pct;
|
||
}
|
||
|
||
function renderProgress(children) {
|
||
var totalRead = 0;
|
||
for (var i = 0; i < children.length; i++) {
|
||
var ch = children[i];
|
||
var idx = CH_IDX[ch.slug];
|
||
if (!idx) continue;
|
||
var read = ch.progress ? ch.progress.read.length : 0;
|
||
var total = ch.para_count || CH_PARA[ch.slug] || 1;
|
||
totalRead += read;
|
||
setChProg(idx, read, total);
|
||
}
|
||
|
||
var pct = Math.round(totalRead * 100 / TOTAL);
|
||
var overallEl = document.getElementById('overall-text');
|
||
var fillEl = document.getElementById('overall-fill');
|
||
if (overallEl) overallEl.textContent = totalRead + ' из ' + TOTAL + ' параграфов · ' + pct + '%';
|
||
if (fillEl) fillEl.style.width = pct + '%';
|
||
|
||
var xpBadge = document.getElementById('hero-xp-badge');
|
||
var xp = parseInt(localStorage.getItem('algebra7_xp') || '0', 10) || 0;
|
||
if (xpBadge && xp > 0) {
|
||
xpBadge.style.display = '';
|
||
xpBadge.textContent = xp + ' XP';
|
||
}
|
||
|
||
if (totalRead >= TOTAL) {
|
||
var strip = document.getElementById('ach-strip');
|
||
var sub = document.getElementById('ach-sub');
|
||
if (strip) strip.classList.add('lit');
|
||
if (sub) sub.textContent = 'Выполнено! Вы прочитали весь курс алгебры 7 класса.';
|
||
}
|
||
}
|
||
|
||
function loadProgress() {
|
||
if (typeof window.LS === 'undefined' || typeof window.LS.api !== 'function') {
|
||
renderProgress([]);
|
||
return;
|
||
}
|
||
window.LS.api('/api/textbooks/algebra-7/children')
|
||
.then(function(data) {
|
||
if (data && data.children) renderProgress(data.children);
|
||
else renderProgress([]);
|
||
})
|
||
.catch(function() { renderProgress([]); });
|
||
}
|
||
|
||
if (document.readyState === 'loading') {
|
||
document.addEventListener('DOMContentLoaded', loadProgress);
|
||
} else {
|
||
loadProgress();
|
||
}
|
||
window.addEventListener('focus', loadProgress);
|
||
</script>
|
||
|
||
</body>
|
||
</html>
|