feat(catalog): хаб-страница для Алгебры 8 (3 главы под единым слагом)

- migration 014: parent_slug column + algebra-8 hub row +
  rename old algebra-8 → algebra-8-ch1 (progress сохраняется
  через стабильный textbook_id=3)
- backend/routes/textbooks.js: GET / фильтрует parent_slug IS NULL;
  aggregated progress для хабов; новый GET /:slug/children
- algebra_8_hub.html: новая хаб-страница с 3 карточками глав,
  hero с общим прогрессом, XP-бейдж, ссылки на главы
- algebra_8/ch2/ch3: кнопки cross-chapter заменены на
  одну «К алгебре 8» в шапке

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Maxim Dolgolyov
2026-05-27 16:49:20 +03:00
parent 033c941b02
commit 699fdcc7fb
6 changed files with 469 additions and 24 deletions
@@ -0,0 +1,23 @@
-- Algebra 8 hub migration.
-- Adds parent_slug column so chapters can be grouped under a hub textbook.
-- The original algebra-8 row (id=3) becomes algebra-8-ch1; its id never changes
-- so all textbook_progress rows keep their FK references intact.
-- 1. Add nullable parent_slug column (idempotent: will fail gracefully if already exists,
-- but migrations-runner wraps each file in a transaction so this is fine as a fresh run).
ALTER TABLE textbooks ADD COLUMN parent_slug TEXT;
-- 2. Rename the existing chapter-1 slug from 'algebra-8' to 'algebra-8-ch1'.
-- Row id=3 is untouched, so textbook_progress.textbook_id=3 continues to resolve correctly.
UPDATE textbooks SET slug = 'algebra-8-ch1' WHERE slug = 'algebra-8';
-- 3. Insert the new hub row.
INSERT INTO textbooks
(slug, subject, grade, title, author, description, html_path, para_count, color, sort_order, is_active)
VALUES
('algebra-8', 'math', 8, 'Алгебра — 8 класс', '',
'Полный курс алгебры 8 класса: квадратные корни и действительные числа, квадратные уравнения, неравенства с одной переменной. 3 главы, 21 параграф + 3 финала, 100+ интерактивов, 21 босс-проверка.',
'algebra_8_hub.html', 21, 'pink', 3, 1);
-- 4. Tag all three chapter rows as children of the hub.
UPDATE textbooks SET parent_slug = 'algebra-8' WHERE slug IN ('algebra-8-ch1', 'algebra-8-ch2', 'algebra-8-ch3');