Implement Phase C2 Enhancements for Exercise Suggestions
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 18s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m14s
Test Suite / pytest-backend (pull_request) Successful in 38s
Test Suite / lint-backend (pull_request) Successful in 0s
Test Suite / build-frontend (pull_request) Successful in 13s
Test Suite / k6 /health Baseline (pull_request) Successful in 33s
Test Suite / playwright-tests (pull_request) Successful in 1m13s

- Incremented version to 0.8.184, reflecting the implementation of Phase C2 features.
- Added support for displaying variant lists and suggested variant names in exercise suggestions.
- Enhanced the ExercisePickerModal to allow selection of exercise variants and improved handling of variant IDs.
- Updated backend logic to enrich planning hits with variant metadata, ensuring accurate exercise variant selection.
- Documented changes in the changelog to highlight the new capabilities in planning AI functionality.
This commit is contained in:
Lars committed 2026-05-23 11:39:18 +02:00
1 parent b2157d8a40
commit a34e748be5
10 files changed
+280 -27

No files matched your search

+74
View File
@@ -211,6 +211,79 @@ def _resolve_anchor_variant_id(
return None
def _enrich_planning_hits_with_variant_meta(
cur,
hits: Sequence[Dict[str, Any]],
) -> List[Dict[str, Any]]:
"""Variantennamen und -listen für Treffer mit suggested_variant_id (Phase C2)."""
if not hits:
return []
variant_ids: Set[int] = set()
exercise_ids: Set[int] = set()
for h in hits:
exercise_ids.add(int(h["id"]))
raw = h.get("suggested_variant_id")
if raw is not None:
try:
vid = int(raw)
except (TypeError, ValueError):
vid = 0
if vid > 0:
variant_ids.add(vid)
names_by_variant: Dict[int, str] = {}
if variant_ids:
ph = ",".join(["%s"] * len(variant_ids))
cur.execute(
f"SELECT id, variant_name FROM exercise_variants WHERE id IN ({ph})",
list(variant_ids),
)
for row in cur.fetchall():
n = (row.get("variant_name") or "").strip()
if n:
names_by_variant[int(row["id"])] = n
variants_by_exercise: Dict[int, List[Dict[str, Any]]] = {}
if exercise_ids:
ph = ",".join(["%s"] * len(exercise_ids))
cur.execute(
f"""
SELECT exercise_id, id, variant_name, sequence_order
FROM exercise_variants
WHERE exercise_id IN ({ph})
ORDER BY exercise_id, sequence_order NULLS LAST, id
""",
list(exercise_ids),
)
for row in cur.fetchall():
eid = int(row["exercise_id"])
variants_by_exercise.setdefault(eid, []).append(
{
"id": int(row["id"]),
"variant_name": (row.get("variant_name") or "").strip() or None,
"sequence_order": row.get("sequence_order"),
}
)
out: List[Dict[str, Any]] = []
for h in hits:
item = dict(h)
eid = int(item["id"])
vars_for_ex = variants_by_exercise.get(eid) or []
if vars_for_ex:
item["variants"] = vars_for_ex
raw_vid = item.get("suggested_variant_id")
if raw_vid is not None:
try:
vid = int(raw_vid)
except (TypeError, ValueError):
vid = 0
if vid > 0:
item["suggested_variant_name"] = names_by_variant.get(vid)
out.append(item)
return out
def _finalize_progression_context(
cur,
tenant: TenantContext,
@@ -728,6 +801,7 @@ def suggest_planning_exercises(
hits = hits[: int(body.limit)]
hits = hits[: int(body.limit)]
hits = _enrich_planning_hits_with_variant_meta(cur, hits)
context_summary = {
"unit_title": pack.get("unit_title"),
@@ -0,0 +1,43 @@
"""Tests Phase C2: Varianten-Metadaten in Planungs-Treffern."""
from planning_exercise_suggest import _enrich_planning_hits_with_variant_meta
class _Cur:
def __init__(self, rows):
self._rows = rows
self.last_query = ''
def execute(self, query, params=None):
self.last_query = query
self._params = params
def fetchall(self):
q = self.last_query
if 'FROM exercise_variants WHERE id IN' in q:
return [
{'id': 7, 'variant_name': 'Leicht'},
]
if 'FROM exercise_variants' in q and 'exercise_id IN' in q:
return [
{
'exercise_id': 10,
'id': 7,
'variant_name': 'Leicht',
'sequence_order': 1,
},
{
'exercise_id': 10,
'id': 8,
'variant_name': 'Schwer',
'sequence_order': 2,
},
]
return []
def test_enrich_planning_hits_with_variant_meta():
hits = [{'id': 10, 'title': 'Test', 'suggested_variant_id': 7}]
out = _enrich_planning_hits_with_variant_meta(_Cur([]), hits)
assert out[0]['suggested_variant_name'] == 'Leicht'
assert len(out[0]['variants']) == 2
assert out[0]['variants'][0]['id'] == 7
+10 -2
View File
@@ -1,6 +1,6 @@
# Shinkan Jinkendo Version Information
APP_VERSION = "0.8.183"
APP_VERSION = "0.8.184"
BUILD_DATE = "2026-05-23"
DB_SCHEMA_VERSION = "20260531074"
@@ -29,7 +29,7 @@ MODULE_VERSIONS = {
"skill_profiles": "1.0.0", # Phase 3: gewichtetes Fähigkeiten-Profil + skill-discovery/suggestions
"methods": "0.1.0",
"exercises": "2.37.0", # Planungs-KI P1: Szenario-Pipeline + Query-Intent-Overlay
"planning_exercise_suggest": "0.11.0", # Phase C1: Graph auto-match + variantenbewusste Nachfolger
"planning_exercise_suggest": "0.12.0", # Phase C2: Varianten in Treffern + Übernahme
"training_units": "0.4.0", # POST .../publish-to-framework: Ablauf aus geplanter Einheit → Rahmen-Slot-Blueprint
"training_programs": "0.1.0",
"planning": "0.15.0", # Vorlagen: Strukturvorschau, Bearbeiten inkl. Split-Sessions + Beschreibung
@@ -44,6 +44,14 @@ MODULE_VERSIONS = {
}
CHANGELOG = [
{
"version": "0.8.184",
"date": "2026-05-23",
"changes": [
"Planungs-KI Phase C2: Treffer mit Variantenliste + suggested_variant_name; Picker wählt Graph-Variante vor Übernahme.",
"hydrateExercisePlanningRow übernimmt exercise_variant_id / suggested_variant_id in die Planungszeile.",
],
},
{
"version": "0.8.183",
"date": "2026-05-23",