Implement Comparison Logic for Progression Path Suggestions
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 45s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m18s

- Added `compare_with_assignments` flag to `ProgressionPathSuggestRequest` to enable comparison of proposed paths with existing slot assignments.
- Introduced `_assignment_preservation_active` function to determine if existing assignments should be preserved during path suggestions.
- Enhanced `suggest_progression_path` to handle comparison logic, including validation for minimum slot assignments required for comparison.
- Implemented `_build_progression_compare_response` to structure the response for comparison results, including slot differences and quality scores.
- Updated frontend components to support new comparison features, including handling of slot assignments and optimization comparisons.
- Bumped version to reflect the new features and improvements.
This commit is contained in:
Lars committed 2026-06-12 13:22:04 +02:00
1 parent b8f65e04c5
commit 5ed06002d9
7 files changed
+695 -26

No files matched your search

@@ -906,6 +906,23 @@ export function slotsToSlotAssignments(draft) {
}))
}
/** Mindestens ein Bibliotheks-Slot belegt → kuratierter Stand, Match prüft Abweichungen. */
export function draftHasLibrarySlotAssignments(draft) {
return slotsToSlotAssignments(draft).length >= 1
}
/** Diff-Einträge nur für Slots, die vorher schon eine Bibliotheks-Übung hatten. */
export function curatedSlotDiffs(comparison) {
const diffs = comparison?.slot_diffs
if (!Array.isArray(diffs)) return []
return diffs.filter((d) => d?.baseline_exercise_id != null)
}
/** Vergleich würde eine bestehende Zuordnung ändern (Dialog bei Match). */
export function compareResponseHasCuratedSlotChanges(res) {
return curatedSlotDiffs(res).length > 0
}
/** Alle Graph-Übungs-IDs für Retriever-Boost (Slots + Geschwister + gespeichertes Artefakt). */
export function draftRetrievalBoostExerciseIds(draft) {
const ids = new Set()
@@ -1046,6 +1063,38 @@ export function applyMatchStepsToSlots(draft, apiSteps) {
return syncProgressionRoadmapFromSlots({ ...draft, slots: nextSlots, dirty: true })
}
/** Vergleichs-Antwort: mindestens ein Slot mit anderer Übung als im Ist-Stand. */
export function compareResponseHasSlotChanges(res) {
const count = res?.slot_diff_count ?? res?.slot_diffs?.length ?? 0
return Number(count) > 0
}
/** Nur ausgewählte Slots aus Optimierungs-Vorschlag übernehmen. */
export function applySelectedCompareSteps(draft, proposedSteps, selectedMajorIndices) {
const selected = new Set(
(selectedMajorIndices || [])
.map((x) => Number(x))
.filter((x) => Number.isFinite(x)),
)
if (!selected.size) return draft
const stepByMajor = new Map()
for (const step of proposedSteps || []) {
if (step?.roadmap_major_step_index == null) continue
stepByMajor.set(Number(step.roadmap_major_step_index), step)
}
const nextSlots = (draft.slots || []).map((slot) => {
const midx = Number(slot.majorStepIndex)
if (!selected.has(midx)) {
return { ...slot, primary: { ...slot.primary }, siblings: [...(slot.siblings || [])] }
}
const step = stepByMajor.get(midx)
if (!step) return slot
const patched = applyMatchStepsToSlots({ ...draft, slots: [slot] }, [step])
return patched.slots[0]
})
return syncProgressionRoadmapFromSlots({ ...draft, slots: nextSlots, dirty: true })
}
/** Lücken-Angebote in leere Slots legen; Panel nur für verbleibende Lücken. */
export function applyGapOffersFromResponse(draft, res, { replaceOffTopicSlots = false } = {}) {
let next = draft