deploy: sync backend to Space root (learn-lesson HF cache fix)
Browse files
app/services/content_manifest.py
CHANGED
|
@@ -78,10 +78,14 @@ class ContentManifest:
|
|
| 78 |
|
| 79 |
def available_for_subject(self, subject: str) -> tuple[ManifestChapter, ...]:
|
| 80 |
key = subject.strip().casefold()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
return tuple(
|
| 82 |
chapter
|
| 83 |
for chapter in self.chapters
|
| 84 |
-
if chapter.subject.casefold()
|
| 85 |
and chapter.availability in AVAILABLE
|
| 86 |
and any(mission.assignable for mission in chapter.missions)
|
| 87 |
)
|
|
|
|
| 78 |
|
| 79 |
def available_for_subject(self, subject: str) -> tuple[ManifestChapter, ...]:
|
| 80 |
key = subject.strip().casefold()
|
| 81 |
+
# FE coverage/picker use "Mathematics"; curated manifest rows use "Maths".
|
| 82 |
+
subject_keys = {key}
|
| 83 |
+
if key in {"math", "maths", "mathematics"}:
|
| 84 |
+
subject_keys = {"math", "maths", "mathematics"}
|
| 85 |
return tuple(
|
| 86 |
chapter
|
| 87 |
for chapter in self.chapters
|
| 88 |
+
if chapter.subject.casefold() in subject_keys
|
| 89 |
and chapter.availability in AVAILABLE
|
| 90 |
and any(mission.assignable for mission in chapter.missions)
|
| 91 |
)
|
tests/test_adaptive_engine.py
CHANGED
|
@@ -225,8 +225,9 @@ def test_kerala_student_profile_drives_repair_revision_and_tomorrow_plan(
|
|
| 225 |
assert initial_plan["daily_minutes"] == 240
|
| 226 |
assert initial_plan["planned_minutes"] <= 240
|
| 227 |
# Only verified available content may become a guided lesson.
|
|
|
|
| 228 |
assert all(
|
| 229 |
-
task["subject"]
|
| 230 |
for task in initial_plan["tasks"]
|
| 231 |
if task["task_type"] in {"lesson", "new_lesson", "continue_lesson"}
|
| 232 |
)
|
|
|
|
| 225 |
assert initial_plan["daily_minutes"] == 240
|
| 226 |
assert initial_plan["planned_minutes"] <= 240
|
| 227 |
# Only verified available content may become a guided lesson.
|
| 228 |
+
# Class 10 contract now publishes Physics + Mathematics; English has none.
|
| 229 |
assert all(
|
| 230 |
+
task["subject"] in {"Physics", "Mathematics"}
|
| 231 |
for task in initial_plan["tasks"]
|
| 232 |
if task["task_type"] in {"lesson", "new_lesson", "continue_lesson"}
|
| 233 |
)
|
tests/test_content_manifest.py
CHANGED
|
@@ -14,11 +14,22 @@ def test_content_manifest_file_is_present_and_loadable() -> None:
|
|
| 14 |
assert manifest.mission("phy-p1-c1", "M1") is not None
|
| 15 |
|
| 16 |
|
| 17 |
-
def
|
| 18 |
mission = operational_manifest(EmptyContentState()).mission("chem-p1-c2", "M1")
|
| 19 |
|
| 20 |
assert mission is not None
|
| 21 |
-
assert mission.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
def test_rebuilt_guided_contract_is_assignable() -> None:
|
|
|
|
| 14 |
assert manifest.mission("phy-p1-c1", "M1") is not None
|
| 15 |
|
| 16 |
|
| 17 |
+
def test_repaired_chem_2025_guided_contract_is_assignable() -> None:
|
| 18 |
mission = operational_manifest(EmptyContentState()).mission("chem-p1-c2", "M1")
|
| 19 |
|
| 20 |
assert mission is not None
|
| 21 |
+
assert mission.title == "Chemical Reactions of Organic Compounds \u2014 full chapter"
|
| 22 |
+
assert mission.assignable is True
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def test_maths_subject_alias_matches_mathematics() -> None:
|
| 26 |
+
from app.services.content_manifest import load_content_manifest
|
| 27 |
+
|
| 28 |
+
manifest = load_content_manifest()
|
| 29 |
+
maths = {chapter.chapter_id for chapter in manifest.available_for_subject("Maths")}
|
| 30 |
+
mathematics = {chapter.chapter_id for chapter in manifest.available_for_subject("Mathematics")}
|
| 31 |
+
assert maths == mathematics
|
| 32 |
+
assert "math-p1-c1" in mathematics
|
| 33 |
|
| 34 |
|
| 35 |
def test_rebuilt_guided_contract_is_assignable() -> None:
|
tests/test_phase5_tuition_sessions.py
CHANGED
|
@@ -161,9 +161,8 @@ def test_tuition_contract_is_published_and_source_backed() -> None:
|
|
| 161 |
from app.services.tuition_content_contract import load_tuition_content_contract
|
| 162 |
|
| 163 |
contract = load_tuition_content_contract()
|
| 164 |
-
#
|
| 165 |
-
|
| 166 |
-
assert len(contract.lessons) == 109
|
| 167 |
physics = contract.lesson("phy-p1-c1", "M1")
|
| 168 |
assert physics is not None
|
| 169 |
assert physics.source_refs
|
|
@@ -175,6 +174,12 @@ def test_tuition_contract_is_published_and_source_backed() -> None:
|
|
| 175 |
assert chemistry.chapter_title == "Nomenclature of Organic Compounds and Isomerism"
|
| 176 |
assert chemistry.status == "published"
|
| 177 |
assert contract.lesson("chem-p1-c1", "M2") is None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
|
| 180 |
def test_authoritative_tuition_session_requires_real_evidence_and_is_idempotent(auth_client) -> None:
|
|
|
|
| 161 |
from app.services.tuition_content_contract import load_tuition_content_contract
|
| 162 |
|
| 163 |
contract = load_tuition_content_contract()
|
| 164 |
+
# Honest Phys/Chem/Bio seeds plus ready Maths/Social/chem-p2 pack M1 lessons.
|
| 165 |
+
assert len(contract.lessons) == 114
|
|
|
|
| 166 |
physics = contract.lesson("phy-p1-c1", "M1")
|
| 167 |
assert physics is not None
|
| 168 |
assert physics.source_refs
|
|
|
|
| 174 |
assert chemistry.chapter_title == "Nomenclature of Organic Compounds and Isomerism"
|
| 175 |
assert chemistry.status == "published"
|
| 176 |
assert contract.lesson("chem-p1-c1", "M2") is None
|
| 177 |
+
chem2 = contract.lesson("chem-p1-c2", "M1")
|
| 178 |
+
assert chem2 is not None
|
| 179 |
+
assert chem2.chapter_title == "Chemical Reactions of Organic Compounds"
|
| 180 |
+
assert chem2.status == "published"
|
| 181 |
+
assert contract.lesson("math-p1-c1", "M1") is not None
|
| 182 |
+
assert contract.lesson("geo-part1-ch01-weather-and-climate", "M1") is not None
|
| 183 |
|
| 184 |
|
| 185 |
def test_authoritative_tuition_session_requires_real_evidence_and_is_idempotent(auth_client) -> None:
|