diff --git a/backend/src/db/migrations/015_physics_8_hub.sql b/backend/src/db/migrations/015_physics_8_hub.sql new file mode 100644 index 0000000..f790245 --- /dev/null +++ b/backend/src/db/migrations/015_physics_8_hub.sql @@ -0,0 +1,29 @@ +-- Physics 8 hub migration. +-- Converts physics-8 from a monolithic entry into a hub with 3 children, +-- mirroring the algebra-8 hub pattern established in migration 014. + +-- 1. Insert 3 child rows for the sub-textbooks. +INSERT OR IGNORE INTO textbooks + (slug, subject, grade, title, author, description, html_path, para_count, color, sort_order, is_active, parent_slug) +VALUES + ('physics-8-thermal', 'physics', 8, 'Физика 8 · Тепловые явления', + '', + 'Внутренняя энергия, теплопередача, удельная теплоёмкость, фазовые переходы, тепловые двигатели.', + 'physics8_thermal.html', 11, 'orange', 1, 1, 'physics-8'), + ('physics-8-electro', 'physics', 8, 'Физика 8 · Электрические явления', + '', + 'Электростатика, закон Кулона, электрический ток, закон Ома, электрические цепи.', + 'physics8_electro.html', 20, 'blue', 2, 1, 'physics-8'), + ('physics-8-optics', 'physics', 8, 'Физика 8 · Световые явления', + '', + 'Источники света, отражение, преломление, линзы, оптические приборы.', + 'physics8_optics.html', 9, 'purple', 3, 1, 'physics-8'); + +-- 2. Update the parent physics-8 row: clear author, set para_count=40, update description. +UPDATE textbooks +SET + author = '', + para_count = 40, + html_path = 'physics_8.html', + description = 'Полный курс физики 8 класса в трёх разделах: тепловые явления (§1–§11), электрические явления (§12–§31), световые явления (§32–§40).' +WHERE slug = 'physics-8'; diff --git a/frontend/js/textbook-tracker.js b/frontend/js/textbook-tracker.js index 09a2dab..e5e6ad9 100644 --- a/frontend/js/textbook-tracker.js +++ b/frontend/js/textbook-tracker.js @@ -12,7 +12,9 @@ if (m) return m[1]; // Fallback for direct file access during dev const fname = location.pathname.split('/').pop().replace(/\.html$/, ''); - return fname.replace(/_/g, '-'); + // Normalise physics8_* → physics-8-* (e.g. physics8_thermal → physics-8-thermal) + const norm = fname.replace(/^physics8_/, 'physics-8-'); + return norm.replace(/_/g, '-'); })(); const lsKey = 'textbook_progress_' + slug; @@ -196,6 +198,11 @@ if (!pill) return; const key = pill.dataset.para; setLastPara(key); + // Auto-mark-as-read: первый клик по пилюле = открыл параграф = считается прочитанным + // (мягкая семантика — соответствует реальному поведению учеников) + if (!localState.read.includes(key)) { + markRead(key); + } }); } diff --git a/frontend/textbooks/physics8_electro.html b/frontend/textbooks/physics8_electro.html index b0ae935..cb4f8e9 100644 --- a/frontend/textbooks/physics8_electro.html +++ b/frontend/textbooks/physics8_electro.html @@ -10,6 +10,7 @@ + @@ -118,8 +114,8 @@ main{max-width:1100px;margin:0 auto;padding:32px 24px 60px}