From 74bb76c6a1aee7f40119013f92a96be817f5f288 Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Wed, 26 Aug 2026 13:43:16 +0200 Subject: [PATCH 1/2] fix: index and swl --- src/build.py | 10 +++++++ test/test_swl_question_catalog.py | 44 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/src/build.py b/src/build.py index c9d9521..3ed3a18 100644 --- a/src/build.py +++ b/src/build.py @@ -657,6 +657,16 @@ class Build: "editions": [], }, ) + if edition != "SWL" and question_entry["editions"] == ["SWL"]: + # SWL reuses questions from the regular courses, but can place + # them in SWL-specific chapters. The question index exposes a + # single canonical location, so prefer the first regular + # course occurrence. Pure SWL questions keep their location. + question_entry.update( + section=section_ident, + chapter_title=chapter_title, + section_title=section_title, + ) if edition not in question_entry["editions"]: question_entry["editions"].append(edition) diff --git a/test/test_swl_question_catalog.py b/test/test_swl_question_catalog.py index 828e0e7..c8841d7 100644 --- a/test/test_swl_question_catalog.py +++ b/test/test_swl_question_catalog.py @@ -102,3 +102,47 @@ def test_lowercase_swl_toc_is_supported(tmp_path): build.build_edition("SWL") assert (tmp_path / "build" / "SWL_course_index.html").exists() assert (tmp_path / "build" / "SWL_swl_intro.html").exists() + + +def test_regular_course_location_takes_precedence_for_shared_swl_question(tmp_path): + prepare_content(tmp_path, include_swl=True) + build = Build(Config(content_path=tmp_path, build_path=tmp_path / "build")) + + build._Build__collect_question_occurrences( + "SWL", + "SWL-Kapitel", + "swl_buchstabieralphabet", + "SWL-Buchstabieralphabet", + "[question:NA101]", + ) + build._Build__collect_question_occurrences( + "N", + "Erste Schritte", + "buchstabiertafel", + "Internationale Buchstabiertafel", + "[question:NA101]", + ) + + assert build.question_index["NA101"] == { + "has_solution": False, + "section": "buchstabiertafel", + "chapter_title": "Erste Schritte", + "section_title": "Internationale Buchstabiertafel", + "editions": ["SWL", "N"], + } + + +def test_pure_swl_question_keeps_its_swl_location(tmp_path): + prepare_content(tmp_path, include_swl=True) + build = Build(Config(content_path=tmp_path, build_path=tmp_path / "build")) + + build._Build__collect_question_occurrences( + "SWL", + "SWL-Kapitel", + "swl_eigene_fragen", + "SWL-Fragen", + "[question:SWL001]", + ) + + assert build.question_index["SWL001"]["section"] == "swl_eigene_fragen" + assert build.question_index["SWL001"]["editions"] == ["SWL"] From 1ce514b27fa8893fe77dacca7518b6e45e06c454 Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Thu, 27 Aug 2026 12:26:28 +0200 Subject: [PATCH 2/2] refactor: remove swl from homework for now --- assets/homework.js | 1 - src/build.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/assets/homework.js b/assets/homework.js index c0279f2..b500b8b 100644 --- a/assets/homework.js +++ b/assets/homework.js @@ -2,7 +2,6 @@ "use strict"; var COURSE_CHOICES = [ - { edition: "SWL", label: "SWL-Kurs", detail: "Kurzwellenhören", color: "#FFFFFF" }, { edition: "N", label: "N-Kurs", detail: "N", color: "#47ABE8" }, { edition: "NE", label: "E-Kurs", detail: "N + E", color: "#FE756C" }, { edition: "NEA", label: "A-Kurs", detail: "N + E + A", color: "#3BB583" }, diff --git a/src/build.py b/src/build.py index 3ed3a18..66e74bd 100644 --- a/src/build.py +++ b/src/build.py @@ -215,7 +215,7 @@ class Build: def __build_homework_tool(self): toc_target = self.config.p_build_assets / "toc" toc_target.mkdir(parents=True, exist_ok=True) - for edition in ("SWL", "N", "NE", "NEA", "E", "EA", "A"): + for edition in ("N", "NE", "NEA", "E", "EA", "A"): source = self.config.p_data_toc / f"{edition}.json" if not source.exists(): source = self.config.p_data_toc / f"{edition.lower()}.json" @@ -228,7 +228,7 @@ class Build: page_scripts=[ "assets/vue.global.prod.js", "assets/question-catalog.js?ts=20260806", - "assets/homework.js?ts=202608061", + "assets/homework.js?ts=202608271", ], ) with (self.config.p_build / "hausaufgabe.html").open("w", encoding="utf-8") as file: