Merge develop: deliver stored exercise HTML on the catalog API.
Deploy Production llm-node / deploy (push) Successful in 1m26s

This commit is contained in:
Lars committed 2026-11-23 22:12:15 +01:00
commit 099ffd0df0
4 files changed
+549 -13

No files matched your search

+23 -8
View File
@@ -15,6 +15,8 @@ from datetime import datetime, timezone
from html import unescape
from typing import Any, Iterable, Optional
from exercise_rich_text import normalize_inline_exercise_media_markup
PART_ROLES = (
"goal",
"prerequisites",
@@ -235,8 +237,20 @@ def catalog_available(offered: bool, in_scope: bool) -> bool:
return bool(offered) and bool(in_scope)
def catalog_html(value: Optional[str]) -> str:
"""Gespeichertes Übungs-HTML. Absätze, Umbrüche, Listen und Hervorhebungen bleiben erhalten."""
if value is None:
return ""
normalized = normalize_inline_exercise_media_markup(str(value))
return normalized or ""
def catalog_document(exercise: dict, variants: list[dict], media: list[dict]) -> dict:
"""Aktueller Übungsstand. Die Reihenfolge der Varianten und Medien gehört zum Inhalt."""
"""Aktueller Übungsstand. Die Reihenfolge der Varianten und Medien gehört zum Inhalt.
text_format html gilt für summary, goal, execution, preparation, trainer_notes
und variants.execution_changes. Titel, Variantenbeschreibung und Material bleiben Text.
"""
ordered_variants = sorted(
variants,
key=lambda item: (item.get("sequence_order") is None, item.get("sequence_order") or 0, int(item.get("id") or 0)),
@@ -247,12 +261,13 @@ def catalog_document(exercise: dict, variants: list[dict], media: list[dict]) ->
)
return {
"source_id": str(exercise.get("public_id")),
"text_format": "html",
"title": exercise.get("title") or "",
"summary": plaintext(exercise.get("summary")),
"goal": plaintext(exercise.get("goal")),
"execution": plaintext(exercise.get("execution")),
"preparation": plaintext(exercise.get("preparation")),
"trainer_notes": plaintext(exercise.get("trainer_notes")),
"summary": catalog_html(exercise.get("summary")),
"goal": catalog_html(exercise.get("goal")),
"execution": catalog_html(exercise.get("execution")),
"preparation": catalog_html(exercise.get("preparation")),
"trainer_notes": catalog_html(exercise.get("trainer_notes")),
"equipment": _equipment_text(exercise) or "",
"duration_min": exercise.get("duration_min"),
"duration_max": exercise.get("duration_max"),
@@ -260,8 +275,8 @@ def catalog_document(exercise: dict, variants: list[dict], media: list[dict]) ->
{
"id": str(item.get("public_id")),
"name": item.get("variant_name") or "",
"description": plaintext(item.get("description")),
"execution_changes": plaintext(item.get("execution_changes")),
"description": (item.get("description") or "").strip(),
"execution_changes": catalog_html(item.get("execution_changes")),
"sequence_order": item.get("sequence_order"),
}
for item in ordered_variants
@@ -0,0 +1,493 @@
{
"fixture_version": 1,
"note": "Synthetische Inhalte ohne produktive Rechte. Die Medienbytes dienen der Testung von Groesse und Hash. Sie sind keine abspielbare Filmdatei.",
"manifest_serialization": "UTF-8, JSON ohne Leerraum, Reihenfolge der Felder aus manifest, kein abschliessender Zeilenumbruch",
"channels": {
"lara_felix": {
"recipient_id": "caa20000-0000-4000-8000-0000000001f5",
"events": [
{
"event_id": "caa20000-0000-4000-8000-000000000258",
"type": "release.published",
"release_id": "caa20000-0000-4000-8000-0000000000c9",
"occurred_at": "2026-11-23T09:01:00Z",
"source_id": "caa20000-0000-4000-8000-00000000000a",
"revision": 1,
"manifest_sha256": "fcebc8c4db56328a55dc7f350e705822cef19f02392f26625274e68c0abc239c"
},
{
"event_id": "caa20000-0000-4000-8000-000000000259",
"type": "release.published",
"release_id": "caa20000-0000-4000-8000-0000000000ca",
"occurred_at": "2026-11-23T09:02:00Z",
"source_id": "caa20000-0000-4000-8000-00000000000b",
"revision": 1,
"manifest_sha256": "7dad43afb3077fb2d9fb3aa490bb91daf53f175c06575d648411021d352a1744"
},
{
"event_id": "caa20000-0000-4000-8000-00000000025a",
"type": "release.published",
"release_id": "caa20000-0000-4000-8000-0000000000cb",
"occurred_at": "2026-11-23T09:03:00Z",
"source_id": "caa20000-0000-4000-8000-00000000000a",
"revision": 2,
"manifest_sha256": "f0c8051cee6feb0e6399f1bc5681e0ef1ecd640c1cbe6b634c5df1c1b1df9ed0"
},
{
"event_id": "caa20000-0000-4000-8000-00000000025b",
"type": "release.retired",
"release_id": "caa20000-0000-4000-8000-0000000000c9",
"occurred_at": "2026-11-23T09:04:00Z"
},
{
"event_id": "caa20000-0000-4000-8000-00000000025c",
"type": "asset.withdrawn",
"release_id": "caa20000-0000-4000-8000-0000000000c9",
"occurred_at": "2026-11-23T09:05:00Z",
"target_id": "caa20000-0000-4000-8000-00000000012c",
"reason_code": "rights"
},
{
"event_id": "caa20000-0000-4000-8000-00000000025d",
"type": "asset.withdrawn",
"release_id": "caa20000-0000-4000-8000-0000000000cb",
"occurred_at": "2026-11-23T09:05:00Z",
"target_id": "caa20000-0000-4000-8000-00000000012c",
"reason_code": "rights"
}
]
},
"zweiter_verein": {
"recipient_id": "caa20000-0000-4000-8000-0000000001f6",
"events": [
{
"event_id": "caa20000-0000-4000-8000-0000000002bc",
"type": "release.published",
"release_id": "caa20000-0000-4000-8000-0000000000cc",
"occurred_at": "2026-11-23T09:03:00Z",
"source_id": "caa20000-0000-4000-8000-00000000000c",
"revision": 1,
"manifest_sha256": "3e34007864d308ac1cf6b555bb7fd00dd6962fb6f396eca16492ace0fec59603"
}
]
}
},
"releases": {
"vereinsfassung_1": {
"channel": "lara_felix",
"manifest_sha256": "fcebc8c4db56328a55dc7f350e705822cef19f02392f26625274e68c0abc239c",
"manifest": {
"schema_version": 1,
"resource_type": "exercise",
"release_id": "caa20000-0000-4000-8000-0000000000c9",
"source_id": "caa20000-0000-4000-8000-00000000000a",
"revision": 1,
"publisher_id": "caa20000-0000-4000-8000-00000000177a",
"published_at": "2026-11-23T09:01:00Z",
"exercise": {
"title": "Raum und Wege wahrnehmen",
"audience": "Kursleitungen",
"rights_id": "caa20000-0000-4000-8000-000000000191",
"parts": [
{
"id": "caa20000-0000-4000-8000-000000000065",
"role": "goal",
"text": "Die Gruppe nimmt freie Wege im Raum wahr.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
},
{
"id": "caa20000-0000-4000-8000-000000000066",
"role": "instructions",
"text": "Die Kursleitung legt Karten aus und bespricht die freien Wege.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
},
{
"id": "caa20000-0000-4000-8000-000000000067",
"role": "trainer_notes",
"text": "Vorab genug Platz vorsehen.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
},
{
"id": "caa20000-0000-4000-8000-000000000068",
"role": "instructions",
"text": "Den kurzen Film ansehen und danach die gezeigten Wege vergleichen.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
}
],
"assets": [
{
"id": "caa20000-0000-4000-8000-00000000012c",
"role": "demonstration",
"media_type": "video/mp4",
"size_bytes": 32,
"sha256": "0fb807ef5ec44b003f181dfa9ce317becbcfd5755ebf91a57702d2024df2b915",
"rights_id": "caa20000-0000-4000-8000-000000000192",
"label": "Demonstrationsfilm"
}
],
"common_part_ids": [
"caa20000-0000-4000-8000-000000000065",
"caa20000-0000-4000-8000-000000000067"
],
"common_asset_ids": [],
"variants": [
{
"id": "caa20000-0000-4000-8000-00000000006b",
"label": "Kartenvariante",
"part_ids": [
"caa20000-0000-4000-8000-000000000066"
],
"asset_ids": []
},
{
"id": "caa20000-0000-4000-8000-00000000006c",
"label": "Filmvariante",
"part_ids": [
"caa20000-0000-4000-8000-000000000068"
],
"asset_ids": [
"caa20000-0000-4000-8000-00000000012c"
]
}
]
},
"rights": [
{
"id": "caa20000-0000-4000-8000-000000000191",
"evidence_ref": "test-textrechte",
"actions": [
"store",
"render",
"grant_customer_use",
"commercial_course_use"
],
"territories": [
"DE"
],
"valid_from": "2026-11-23T09:00:00Z",
"valid_until": null
},
{
"id": "caa20000-0000-4000-8000-000000000192",
"evidence_ref": "test-filmrechte",
"actions": [
"store",
"stream",
"course_display",
"grant_customer_use",
"commercial_course_use"
],
"territories": [
"DE"
],
"valid_from": "2026-11-23T09:00:00Z",
"valid_until": null
}
]
},
"synthetic_asset_base64_by_id": {
"caa20000-0000-4000-8000-00000000012c": "U2hpbmthbiBkaXN0cmlidXRpb24gZml4dHVyZSB2MQo="
}
},
"eigener_bestand": {
"channel": "lara_felix",
"manifest_sha256": "7dad43afb3077fb2d9fb3aa490bb91daf53f175c06575d648411021d352a1744",
"manifest": {
"schema_version": 1,
"resource_type": "exercise",
"release_id": "caa20000-0000-4000-8000-0000000000ca",
"source_id": "caa20000-0000-4000-8000-00000000000b",
"revision": 1,
"publisher_id": "caa20000-0000-4000-8000-00000000177b",
"published_at": "2026-11-23T09:02:00Z",
"exercise": {
"title": "Aufmerksam im Raum ankommen",
"audience": "Kursleitungen",
"rights_id": "caa20000-0000-4000-8000-000000000191",
"parts": [
{
"id": "caa20000-0000-4000-8000-00000000006f",
"role": "goal",
"text": "Die Gruppe nimmt freie Wege im Raum wahr.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
},
{
"id": "caa20000-0000-4000-8000-000000000070",
"role": "instructions",
"text": "Die Kursleitung legt Karten aus und bespricht die freien Wege.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
},
{
"id": "caa20000-0000-4000-8000-000000000071",
"role": "trainer_notes",
"text": "Vorab genug Platz vorsehen.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
}
],
"assets": [],
"common_part_ids": [
"caa20000-0000-4000-8000-00000000006f",
"caa20000-0000-4000-8000-000000000071"
],
"common_asset_ids": [],
"variants": [
{
"id": "caa20000-0000-4000-8000-000000000075",
"label": "Kartenvariante",
"part_ids": [
"caa20000-0000-4000-8000-000000000070"
],
"asset_ids": []
}
]
},
"rights": [
{
"id": "caa20000-0000-4000-8000-000000000191",
"evidence_ref": "test-textrechte",
"actions": [
"store",
"render",
"grant_customer_use",
"commercial_course_use"
],
"territories": [
"DE"
],
"valid_from": "2026-11-23T09:00:00Z",
"valid_until": null
}
]
},
"synthetic_asset_base64_by_id": {}
},
"vereinsfassung_2": {
"channel": "lara_felix",
"manifest_sha256": "f0c8051cee6feb0e6399f1bc5681e0ef1ecd640c1cbe6b634c5df1c1b1df9ed0",
"manifest": {
"schema_version": 1,
"resource_type": "exercise",
"release_id": "caa20000-0000-4000-8000-0000000000cb",
"source_id": "caa20000-0000-4000-8000-00000000000a",
"revision": 2,
"publisher_id": "caa20000-0000-4000-8000-00000000177a",
"published_at": "2026-11-23T09:03:00Z",
"exercise": {
"title": "Raum und Wege wahrnehmen",
"audience": "Kursleitungen",
"rights_id": "caa20000-0000-4000-8000-000000000191",
"parts": [
{
"id": "caa20000-0000-4000-8000-000000000065",
"role": "goal",
"text": "Die Gruppe nimmt freie Wege im Raum wahr.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
},
{
"id": "caa20000-0000-4000-8000-000000000066",
"role": "instructions",
"text": "Die Kursleitung legt Karten aus und bespricht die freien Wege.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
},
{
"id": "caa20000-0000-4000-8000-000000000067",
"role": "trainer_notes",
"text": "Vorab genug Platz vorsehen und die Laufwege gemeinsam prüfen.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
},
{
"id": "caa20000-0000-4000-8000-000000000068",
"role": "instructions",
"text": "Den kurzen Film ansehen und danach die gezeigten Wege vergleichen.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
}
],
"assets": [
{
"id": "caa20000-0000-4000-8000-00000000012c",
"role": "demonstration",
"media_type": "video/mp4",
"size_bytes": 32,
"sha256": "0fb807ef5ec44b003f181dfa9ce317becbcfd5755ebf91a57702d2024df2b915",
"rights_id": "caa20000-0000-4000-8000-000000000192",
"label": "Demonstrationsfilm"
}
],
"common_part_ids": [
"caa20000-0000-4000-8000-000000000065",
"caa20000-0000-4000-8000-000000000067"
],
"common_asset_ids": [],
"variants": [
{
"id": "caa20000-0000-4000-8000-00000000006b",
"label": "Kartenvariante",
"part_ids": [
"caa20000-0000-4000-8000-000000000066"
],
"asset_ids": []
},
{
"id": "caa20000-0000-4000-8000-00000000006c",
"label": "Filmvariante",
"part_ids": [
"caa20000-0000-4000-8000-000000000068"
],
"asset_ids": [
"caa20000-0000-4000-8000-00000000012c"
]
}
]
},
"rights": [
{
"id": "caa20000-0000-4000-8000-000000000191",
"evidence_ref": "test-textrechte",
"actions": [
"store",
"render",
"grant_customer_use",
"commercial_course_use"
],
"territories": [
"DE"
],
"valid_from": "2026-11-23T09:00:00Z",
"valid_until": null
},
{
"id": "caa20000-0000-4000-8000-000000000192",
"evidence_ref": "test-filmrechte",
"actions": [
"store",
"stream",
"course_display",
"grant_customer_use",
"commercial_course_use"
],
"territories": [
"DE"
],
"valid_from": "2026-11-23T09:00:00Z",
"valid_until": null
}
]
},
"synthetic_asset_base64_by_id": {
"caa20000-0000-4000-8000-00000000012c": "U2hpbmthbiBkaXN0cmlidXRpb24gZml4dHVyZSB2MQo="
}
},
"zweiter_verein": {
"channel": "zweiter_verein",
"manifest_sha256": "3e34007864d308ac1cf6b555bb7fd00dd6962fb6f396eca16492ace0fec59603",
"manifest": {
"schema_version": 1,
"resource_type": "exercise",
"release_id": "caa20000-0000-4000-8000-0000000000cc",
"source_id": "caa20000-0000-4000-8000-00000000000c",
"revision": 1,
"publisher_id": "caa20000-0000-4000-8000-00000000177c",
"published_at": "2026-11-23T09:03:00Z",
"exercise": {
"title": "Gemeinsam den Raum erkunden",
"audience": "Kursleitungen",
"rights_id": "caa20000-0000-4000-8000-000000000191",
"parts": [
{
"id": "caa20000-0000-4000-8000-000000000079",
"role": "goal",
"text": "Die Gruppe nimmt freie Wege im Raum wahr.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
},
{
"id": "caa20000-0000-4000-8000-00000000007a",
"role": "instructions",
"text": "Die Kursleitung legt Karten aus und bespricht die freien Wege.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
},
{
"id": "caa20000-0000-4000-8000-00000000007b",
"role": "trainer_notes",
"text": "Vorab genug Platz vorsehen.",
"rights_id": "caa20000-0000-4000-8000-000000000191"
}
],
"assets": [],
"common_part_ids": [
"caa20000-0000-4000-8000-000000000079",
"caa20000-0000-4000-8000-00000000007b"
],
"common_asset_ids": [],
"variants": [
{
"id": "caa20000-0000-4000-8000-00000000007f",
"label": "Kartenvariante",
"part_ids": [
"caa20000-0000-4000-8000-00000000007a"
],
"asset_ids": []
}
]
},
"rights": [
{
"id": "caa20000-0000-4000-8000-000000000191",
"evidence_ref": "test-textrechte",
"actions": [
"store",
"render",
"grant_customer_use",
"commercial_course_use"
],
"territories": [
"DE"
],
"valid_from": "2026-11-23T09:00:00Z",
"valid_until": null
}
]
},
"synthetic_asset_base64_by_id": {}
}
},
"plans": {
"plan_a_mit_film": {
"release_id": "caa20000-0000-4000-8000-0000000000c9",
"variant_id": "caa20000-0000-4000-8000-00000000006c"
},
"plan_b_mit_karten": {
"release_id": "caa20000-0000-4000-8000-0000000000c9",
"variant_id": "caa20000-0000-4000-8000-00000000006b"
},
"plan_c_mit_film_neuere_fassung": {
"release_id": "caa20000-0000-4000-8000-0000000000cb",
"variant_id": "caa20000-0000-4000-8000-00000000006c"
},
"plan_d_eigener_bestand": {
"release_id": "caa20000-0000-4000-8000-0000000000ca",
"variant_id": "caa20000-0000-4000-8000-000000000075"
}
},
"expected": {
"plan_binding_after_revision": {
"release_id": "caa20000-0000-4000-8000-0000000000c9",
"variant_id": "caa20000-0000-4000-8000-00000000006c"
},
"blocked_plans_after_withdrawal": [
"plan_a_mit_film",
"plan_c_mit_film_neuere_fassung"
],
"available_plans_after_withdrawal": [
"plan_b_mit_karten",
"plan_d_eigener_bestand"
],
"lara_felix_can_retrieve_after_withdrawal": [
"caa20000-0000-4000-8000-0000000000ca"
],
"zweiter_verein_can_retrieve": [
"caa20000-0000-4000-8000-0000000000cc"
],
"course_film_allowed": true,
"film_download_allowed": false
}
}
+24 -3
View File
@@ -42,10 +42,9 @@ from main import app
from routers.exercises import _assert_can_edit_exercise
from tenant_context import TenantContext, get_tenant_context
# Liegt im Backend-Baum, weil Pytest im API-Image läuft und dort kein Repo-docs-Ordner existiert.
FIXTURE = json.loads(
(Path(__file__).resolve().parents[2] / "docs" / "architecture" / "distribution" / "Shinkan_Lara_Felix_Referenzfall_v1.json").read_text(
encoding="utf-8"
)
(Path(__file__).resolve().parent / "fixtures" / "Shinkan_Lara_Felix_Referenzfall_v1.json").read_text(encoding="utf-8")
)
@@ -346,6 +345,28 @@ def test_catalog_reports_variant_and_media_order_changes() -> None:
]
def test_catalog_keeps_stored_html() -> None:
exercise = _catalog_exercise()
exercise["execution"] = "<p>Stand aufrecht.</p><p>Drehe die <strong>Hüfte</strong>.</p><br><ul><li>eins</li><li>zwei</li></ul>"
exercise["goal"] = "<script>alert(1)</script><p>Sehen</p>"
variant = [{
"id": 1,
"public_id": "var-1",
"variant_name": "Karte",
"description": "Kurzer Text",
"execution_changes": "<p>Langsamer.</p><p>Mit Partner.</p>",
"sequence_order": 1,
}]
document = catalog_document(exercise, variant, [])
assert document["text_format"] == "html"
assert document["execution"] == "<p>Stand aufrecht.</p><p>Drehe die <strong>Hüfte</strong>.</p><br><ul><li>eins</li><li>zwei</li></ul>"
assert document["goal"] == "<p>Sehen</p>"
assert "<script>" not in document["goal"]
assert document["variants"][0]["description"] == "Kurzer Text"
assert document["variants"][0]["execution_changes"] == "<p>Langsamer.</p><p>Mit Partner.</p>"
assert catalog_hash(catalog_document(exercise, variant, [])) == catalog_hash(document)
def test_catalog_hides_unselected_and_out_of_scope_exercises() -> None:
assert catalog_available(True, True) is True
assert catalog_available(False, True) is False
+9 -2
View File
@@ -1,6 +1,6 @@
# Shinkan Jinkendo Version Information
APP_VERSION = "0.8.259"
APP_VERSION = "0.8.260"
BUILD_DATE = "2026-11-23"
DB_SCHEMA_VERSION = "20261123101"
@@ -39,7 +39,7 @@ MODULE_VERSIONS = {
"skill_profiles": "1.0.0", # Phase 3: gewichtetes Fähigkeiten-Profil + skill-discovery/suggestions
"methods": "0.1.0",
"exercises": "2.39.0", # API-Bereitstellung je Übung, einzeln und als Auswahl
"distribution": "1.5.1", # Produktivabruf standardmäßig an; Cursor-Signatur aus dem vorhandenen DB-Geheimnis
"distribution": "1.6.0", # Katalogabruf liefert das gespeicherte Übungs-HTML
"planning_exercise_suggest": "0.23.8", # Progressionsgraph: Katalog-Kontext (Fokus/Stil/TT/ZG) im Match-Profil
"training_units": "0.4.0", # POST .../publish-to-framework: Ablauf aus geplanter Einheit → Rahmen-Slot-Blueprint
"training_programs": "0.1.0",
@@ -55,6 +55,13 @@ MODULE_VERSIONS = {
}
CHANGELOG = [
{
"version": "0.8.260",
"date": "2026-11-23",
"changes": [
"Der Katalogabruf gibt Kurztext, Anleitung und Variantenabweichungen als gespeichertes HTML aus. Absätze, Zeilenumbrüche, Listen und Hervorhebungen bleiben erhalten.",
],
},
{
"version": "0.8.259",
"date": "2026-11-23",