@@ -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)
|
||||
|
||||
|
||||
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user