Add AI Suggestion Handling for Roadmap Gaps and Enhance Progression Graph Components
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 15s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m17s
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 15s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m17s
- Implemented functions to resolve neighboring steps based on major indices and build AI context for unfilled roadmap stages. - Enhanced `try_suggest_ai_stage_step` to generate AI proposals for empty roadmap stages, improving user experience in gap filling. - Updated `build_gap_fill_offer` to utilize major step neighbors for better context in offers related to unfilled slots. - Added tests to ensure correct functionality of AI suggestion handling in the context of roadmap gaps. - Incremented application version to reflect these updates.
This commit is contained in:
1 parent
ee22b22970
commit
e0ddfa6ce5
5 files changed
+490
-48
No files matched your search
@@ -11,17 +11,20 @@ import ProgressionFindingsPanel from './ProgressionFindingsPanel'
|
||||
import {
|
||||
aiPreviewToQuickCreateDraft,
|
||||
buildQuickCreateAiPreview,
|
||||
buildQuickCreateExercisePayloadFromDraft,
|
||||
} from '../utils/exerciseAiQuickCreate'
|
||||
import {
|
||||
buildPathGapPlanningContextForAi,
|
||||
gapOfferContextDisplayLines,
|
||||
initialStageLearningGoalFromOffer,
|
||||
} from '../utils/planningContextForExerciseAi'
|
||||
import ExerciseAiQuickCreateModal from './exercises/ExerciseAiQuickCreateModal'
|
||||
import {
|
||||
addSlotToDraft,
|
||||
applyEvaluateResponseToDraft,
|
||||
applyGapOfferToDraft,
|
||||
applyMatchStepsToSlots,
|
||||
collectGapOffersFromApiResponse,
|
||||
applyMatchResponseToDraft,
|
||||
buildPlanningArtifactFromDraft,
|
||||
hydrateProgressionGraphDraft,
|
||||
insertSlotInDraft,
|
||||
librarySlotExercise,
|
||||
@@ -30,10 +33,12 @@ import {
|
||||
patchSlotInDraft,
|
||||
removeSlotFromDraft,
|
||||
saveProgressionGraphDraft,
|
||||
setSlotPrimaryLibrary,
|
||||
SLOT_MAX,
|
||||
slotsAsPathStepRows,
|
||||
slotsToEvaluateSteps,
|
||||
syncProgressionRoadmapFromSlots,
|
||||
syncSlotPhasesFromRoadmap,
|
||||
} from '../utils/progressionGraphDraft'
|
||||
|
||||
function roadmapStructuredPayload(startSituation, targetState, roadmapNotes) {
|
||||
@@ -83,6 +88,12 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
const [gapPrepError, setGapPrepError] = useState('')
|
||||
const [generatingOfferId, setGeneratingOfferId] = useState(null)
|
||||
const [gapAiBusy, setGapAiBusy] = useState(false)
|
||||
const [currentEdges, setCurrentEdges] = useState([])
|
||||
const [slotQuickCreateOpen, setSlotQuickCreateOpen] = useState(false)
|
||||
const [slotQuickCreateIndex, setSlotQuickCreateIndex] = useState(null)
|
||||
const [slotQuickCreateDraft, setSlotQuickCreateDraft] = useState(null)
|
||||
const [slotQuickSaving, setSlotQuickSaving] = useState(false)
|
||||
const [slotQuickError, setSlotQuickError] = useState('')
|
||||
|
||||
const loadGraph = useCallback(async () => {
|
||||
if (!graphId) return
|
||||
@@ -93,11 +104,13 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
api.getExerciseProgressionGraph(Number(graphId)),
|
||||
api.listExerciseProgressionEdges(Number(graphId)),
|
||||
])
|
||||
const edgeList = Array.isArray(edges) ? edges : []
|
||||
setCurrentEdges(edgeList)
|
||||
setGraphMeta(graph)
|
||||
setDraft(
|
||||
hydrateProgressionGraphDraft({
|
||||
artifact: graph?.planning_roadmap,
|
||||
edges: Array.isArray(edges) ? edges : [],
|
||||
edges: edgeList,
|
||||
graphName: graph?.name,
|
||||
}),
|
||||
)
|
||||
@@ -248,13 +261,6 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
return draft.slots.filter((s) => (s.learning_goal || '').trim().length >= 3)
|
||||
}, [draft?.slots])
|
||||
|
||||
const applyApiResponse = (res) => {
|
||||
setSemanticBrief(res?.semantic_brief_summary || null)
|
||||
setTargetSummary(res?.target_profile_summary || null)
|
||||
setPathQa(res?.path_qa || null)
|
||||
setGapFillOffers(collectGapOffersFromApiResponse(res))
|
||||
}
|
||||
|
||||
const runRoadmapGenerate = async () => {
|
||||
const q = (draft?.goalQuery || '').trim()
|
||||
if (q.length < 3) {
|
||||
@@ -280,8 +286,10 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
})
|
||||
const roadmap = res?.progression_roadmap
|
||||
if (!roadmap) throw new Error('Keine Roadmap in der Antwort')
|
||||
const preservedArtifact = buildPlanningArtifactFromDraft(draft) || {}
|
||||
const hydrated = hydrateProgressionGraphDraft({
|
||||
artifact: {
|
||||
...preservedArtifact,
|
||||
goal_query: q,
|
||||
progression_roadmap: roadmap,
|
||||
start_situation: draft.startSituation,
|
||||
@@ -289,10 +297,11 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
roadmap_notes: draft.roadmapNotes,
|
||||
max_steps: (roadmap?.roadmap?.major_steps || []).length || draft.maxSteps,
|
||||
},
|
||||
edges: [],
|
||||
edges: currentEdges,
|
||||
graphName: draft.graphName,
|
||||
})
|
||||
setDraft({ ...hydrated, goalQuery: q, dirty: true })
|
||||
const withPhases = syncSlotPhasesFromRoadmap(hydrated, roadmap)
|
||||
setDraft({ ...withPhases, goalQuery: q, dirty: true })
|
||||
setSemanticBrief(res?.semantic_brief_summary || null)
|
||||
} catch (e) {
|
||||
setActionErr(e.message || 'Roadmap-Generierung fehlgeschlagen')
|
||||
@@ -331,16 +340,19 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
progression_graph_id: Number(graphId),
|
||||
...roadmapStructuredPayload(draft.startSituation, draft.targetState, draft.roadmapNotes),
|
||||
})
|
||||
const next = applyMatchStepsToSlots(
|
||||
const { draft: matched, remainingOffers } = applyMatchResponseToDraft(
|
||||
{
|
||||
...synced,
|
||||
progressionRoadmap: res?.progression_roadmap || synced.progressionRoadmap,
|
||||
pathSkillExpectations: res?.path_skill_expectations || synced.pathSkillExpectations,
|
||||
},
|
||||
res?.steps,
|
||||
res,
|
||||
)
|
||||
setDraft(next)
|
||||
applyApiResponse(res)
|
||||
setDraft(matched)
|
||||
setSemanticBrief(res?.semantic_brief_summary || null)
|
||||
setTargetSummary(res?.target_profile_summary || null)
|
||||
setPathQa(res?.path_qa || null)
|
||||
setGapFillOffers(remainingOffers)
|
||||
} catch (e) {
|
||||
setActionErr(e.message || 'Übungs-Match fehlgeschlagen')
|
||||
} finally {
|
||||
@@ -374,8 +386,11 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
progression_graph_id: Number(graphId),
|
||||
...roadmapStructuredPayload(draft.startSituation, draft.targetState, draft.roadmapNotes),
|
||||
})
|
||||
applyApiResponse(res)
|
||||
setDraft((prev) => (prev ? { ...prev, lastFindings: res?.path_qa || null } : prev))
|
||||
setSemanticBrief(res?.semantic_brief_summary || null)
|
||||
setPathQa(res?.path_qa || null)
|
||||
const { draft: evaluated, remainingOffers } = applyEvaluateResponseToDraft(synced, res)
|
||||
setDraft({ ...evaluated, lastFindings: res?.path_qa || null })
|
||||
setGapFillOffers(remainingOffers)
|
||||
} catch (e) {
|
||||
setActionErr(e.message || 'Bewertung fehlgeschlagen')
|
||||
} finally {
|
||||
@@ -492,10 +507,12 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
ai_suggestion: aiDraft,
|
||||
has_ai_payload: true,
|
||||
}
|
||||
setDraft((prev) => {
|
||||
const next = applyGapOfferToDraft(prev, enrichedOffer, { slotIndex })
|
||||
return { ...next, dirty: true }
|
||||
})
|
||||
setDraft((prev) => applyGapOfferToDraft(prev, enrichedOffer, { slotIndex }))
|
||||
if (slotIndex != null && Number.isFinite(slotIndex)) {
|
||||
setSlotQuickCreateIndex(slotIndex)
|
||||
setSlotQuickCreateDraft(aiDraft)
|
||||
setSlotQuickCreateOpen(true)
|
||||
}
|
||||
setGapFillOffers((prev) => prev.filter((o) => o.offer_id !== offer?.offer_id))
|
||||
setGapPrepOpen(false)
|
||||
setActiveOffer(null)
|
||||
@@ -507,6 +524,50 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
}
|
||||
}
|
||||
|
||||
const openSlotQuickCreate = (slotIndex) => {
|
||||
const slot = draft?.slots?.[slotIndex]
|
||||
if (!slot) return
|
||||
const primary = slot.primary
|
||||
setSlotQuickCreateIndex(slotIndex)
|
||||
setSlotQuickError('')
|
||||
if (primary?.kind === 'proposal' && primary.aiSuggestion) {
|
||||
setSlotQuickCreateDraft(primary.aiSuggestion)
|
||||
setSlotQuickCreateOpen(true)
|
||||
return
|
||||
}
|
||||
setActiveOfferSlotIndex(slotIndex)
|
||||
openGapFillPrep(
|
||||
{
|
||||
offer_id: `slot-${slotIndex}`,
|
||||
title_hint: primary?.exerciseTitle || slot.learning_goal,
|
||||
roadmap_major_step_index: slot.majorStepIndex,
|
||||
phase: slot.phase,
|
||||
source: 'roadmap_unfilled',
|
||||
goal_for_ai: slot.learning_goal,
|
||||
},
|
||||
slotIndex,
|
||||
)
|
||||
}
|
||||
|
||||
const applySlotQuickCreate = async () => {
|
||||
if (slotQuickCreateIndex == null || !slotQuickCreateDraft) return
|
||||
setSlotQuickSaving(true)
|
||||
setSlotQuickError('')
|
||||
try {
|
||||
const payload = buildQuickCreateExercisePayloadFromDraft(slotQuickCreateDraft)
|
||||
const created = await api.createExercise(payload)
|
||||
if (!created?.id) throw new Error('Anlegen fehlgeschlagen')
|
||||
setDraft((prev) => setSlotPrimaryLibrary(prev, slotQuickCreateIndex, created))
|
||||
setSlotQuickCreateOpen(false)
|
||||
setSlotQuickCreateDraft(null)
|
||||
setSlotQuickCreateIndex(null)
|
||||
} catch (e) {
|
||||
setSlotQuickError(e.message || 'Übung konnte nicht angelegt werden')
|
||||
} finally {
|
||||
setSlotQuickSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
const submitGapFillPrep = async () => {
|
||||
const title = (gapPrepTitle || '').trim()
|
||||
if (title.length < 3) {
|
||||
@@ -675,6 +736,7 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
onMoveDown={(i) => handleMoveSlot(i, 1)}
|
||||
onRemoveSlot={handleRemoveSlot}
|
||||
onInsertAfter={handleInsertAfter}
|
||||
onCreateFromProposal={openSlotQuickCreate}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
@@ -704,6 +766,22 @@ export default function ProgressionGraphEditor({ graphId, embedded = false, onSa
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<ExerciseAiQuickCreateModal
|
||||
open={slotQuickCreateOpen}
|
||||
onClose={() => {
|
||||
if (slotQuickSaving) return
|
||||
setSlotQuickCreateOpen(false)
|
||||
setSlotQuickCreateDraft(null)
|
||||
setSlotQuickError('')
|
||||
}}
|
||||
title={draft?.slots?.[slotQuickCreateIndex]?.primary?.exerciseTitle || ''}
|
||||
draft={slotQuickCreateDraft}
|
||||
onDraftChange={setSlotQuickCreateDraft}
|
||||
busy={slotQuickSaving}
|
||||
error={slotQuickError}
|
||||
onSubmit={applySlotQuickCreate}
|
||||
/>
|
||||
|
||||
<ExerciseGapFillPrepModal
|
||||
open={gapPrepOpen}
|
||||
offer={activeOffer}
|
||||
|
||||
@@ -25,6 +25,7 @@ export default function ProgressionSlotCard({
|
||||
onMoveDown,
|
||||
onRemoveSlot,
|
||||
onInsertAfter,
|
||||
onCreateFromProposal,
|
||||
disabled = false,
|
||||
}) {
|
||||
const { primary, siblings = [], phase, learning_goal: learningGoal } = slot
|
||||
@@ -133,6 +134,12 @@ export default function ProgressionSlotCard({
|
||||
<span style={{ color: 'var(--text3)', fontWeight: 400 }}>{` · ${primary.variantName}`}</span>
|
||||
) : null}
|
||||
</div>
|
||||
{primary.kind === 'proposal' && primary.aiSuggestion?.summary?.text ? (
|
||||
<p style={{ margin: '6px 0 0', fontSize: '12px', color: 'var(--text2)', lineHeight: 1.4 }}>
|
||||
{primary.aiSuggestion.summary.text.slice(0, 220)}
|
||||
{primary.aiSuggestion.summary.text.length > 220 ? '…' : ''}
|
||||
</p>
|
||||
) : null}
|
||||
<div style={{ display: 'flex', gap: '6px', flexWrap: 'wrap', marginTop: '8px' }}>
|
||||
<button
|
||||
type="button"
|
||||
@@ -143,6 +150,17 @@ export default function ProgressionSlotCard({
|
||||
>
|
||||
{primary.kind === 'empty' ? 'Übung wählen' : 'Übung ändern'}
|
||||
</button>
|
||||
{primary.kind === 'proposal' && typeof onCreateFromProposal === 'function' ? (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
style={{ fontSize: '12px', padding: '4px 10px' }}
|
||||
disabled={disabled}
|
||||
onClick={() => onCreateFromProposal(slotIndex)}
|
||||
>
|
||||
{primary.aiSuggestion ? 'Als Übung anlegen' : 'Mit KI anlegen'}
|
||||
</button>
|
||||
) : null}
|
||||
{primary.kind !== 'empty' ? (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -161,21 +161,76 @@ export function offerCanExpandSlots(draft, offer) {
|
||||
return (draft.slots?.length || 0) < SLOT_MAX
|
||||
}
|
||||
|
||||
const GAP_OFFER_SOURCE_PRIORITY = {
|
||||
roadmap_unfilled: 0,
|
||||
unfilled_gap: 1,
|
||||
llm_suggested: 2,
|
||||
off_topic: 3,
|
||||
}
|
||||
|
||||
export function collectGapOffersFromApiResponse(res) {
|
||||
const top = Array.isArray(res?.gap_fill_offers) ? res.gap_fill_offers : []
|
||||
if (top.length) return top
|
||||
const qa = res?.path_qa || {}
|
||||
const merged = [
|
||||
...(Array.isArray(res?.gap_fill_offers) ? res.gap_fill_offers : []),
|
||||
...(Array.isArray(qa?.gap_fill_offers) ? qa.gap_fill_offers : []),
|
||||
]
|
||||
const seen = new Set()
|
||||
return merged.filter((offer) => {
|
||||
const key = offer?.offer_id || `${offer?.source}-${offer?.title_hint}`
|
||||
if (!key || seen.has(key)) return false
|
||||
seen.add(key)
|
||||
return Array.isArray(qa?.gap_fill_offers) ? qa.gap_fill_offers : []
|
||||
}
|
||||
|
||||
/** Maximal ein Angebot pro Slot — Roadmap-Lücken vor Brücken/QS. */
|
||||
export function dedupeGapOffersBySlot(offers, draft) {
|
||||
const bySlot = new Map()
|
||||
for (const offer of offers || []) {
|
||||
const idx = resolveOfferSlotIndex(draft, offer)
|
||||
if (idx == null || !Number.isFinite(idx) || idx < 0) continue
|
||||
const existing = bySlot.get(idx)
|
||||
const prio = GAP_OFFER_SOURCE_PRIORITY[offer?.source] ?? 9
|
||||
const existingPrio = existing ? (GAP_OFFER_SOURCE_PRIORITY[existing?.source] ?? 9) : 99
|
||||
if (!existing || prio < existingPrio) {
|
||||
bySlot.set(idx, offer)
|
||||
}
|
||||
}
|
||||
return Array.from(bySlot.entries())
|
||||
.sort(([a], [b]) => a - b)
|
||||
.map(([, offer]) => offer)
|
||||
}
|
||||
|
||||
/** Angebote nur für Slots ohne belegte Primary (Bibliothek oder KI-Entwurf). */
|
||||
export function filterGapOffersForUnfilledSlots(draft, offers) {
|
||||
return (offers || []).filter((offer) => {
|
||||
const idx = resolveOfferSlotIndex(draft, offer)
|
||||
if (idx == null || idx < 0 || idx >= (draft?.slots?.length || 0)) return true
|
||||
const p = draft.slots[idx]?.primary
|
||||
if (p?.kind === 'library' && p.exerciseId != null) return false
|
||||
if (p?.kind === 'proposal') return false
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
export function syncSlotPhasesFromRoadmap(draft, progressionRoadmap) {
|
||||
if (!progressionRoadmap) return draft
|
||||
const majors = mapMajorStepsFromApi(progressionRoadmap)
|
||||
if (!majors.length) return draft
|
||||
const slots = (draft.slots || []).map((slot, i) => {
|
||||
const m = majors[i]
|
||||
if (!m) return slot
|
||||
return {
|
||||
...slot,
|
||||
phase: m.phase || slot.phase,
|
||||
learning_goal: m.learning_goal || slot.learning_goal,
|
||||
load_profile: m.load_profile?.length ? m.load_profile : slot.load_profile,
|
||||
success_criteria: m.success_criteria?.length ? m.success_criteria : slot.success_criteria,
|
||||
anti_patterns: m.anti_patterns?.length ? m.anti_patterns : slot.anti_patterns,
|
||||
exercise_type: m.exercise_type || slot.exercise_type,
|
||||
}
|
||||
})
|
||||
return syncProgressionRoadmapFromSlots({
|
||||
...draft,
|
||||
slots,
|
||||
progressionRoadmap,
|
||||
majorSteps: majors,
|
||||
maxSteps: Math.max(slots.length, majors.length),
|
||||
})
|
||||
}
|
||||
|
||||
export function slotsAsPathStepRows(draft) {
|
||||
return (draft.slots || []).map((slot) => ({
|
||||
exerciseId: slot.primary?.exerciseId ?? null,
|
||||
@@ -644,19 +699,23 @@ export function slotsToEvaluateSteps(draft) {
|
||||
|
||||
export function applyMatchStepsToSlots(draft, apiSteps) {
|
||||
const steps = Array.isArray(apiSteps) ? apiSteps : []
|
||||
const nextSlots = (draft.slots || []).map((slot) => ({ ...slot, primary: { ...slot.primary }, siblings: [...(slot.siblings || [])] }))
|
||||
const nextSlots = (draft.slots || []).map((slot) => ({
|
||||
...slot,
|
||||
primary: { ...slot.primary },
|
||||
siblings: [...(slot.siblings || [])],
|
||||
}))
|
||||
|
||||
for (const step of steps) {
|
||||
const idx =
|
||||
step.roadmap_major_step_index != null
|
||||
? Number(step.roadmap_major_step_index)
|
||||
: steps.indexOf(step)
|
||||
if (!Number.isFinite(idx) || idx < 0 || idx >= nextSlots.length) continue
|
||||
if (step.roadmap_major_step_index == null || !Number.isFinite(Number(step.roadmap_major_step_index))) {
|
||||
continue
|
||||
}
|
||||
const idx = Number(step.roadmap_major_step_index)
|
||||
if (idx < 0 || idx >= nextSlots.length) continue
|
||||
|
||||
const isProposal = Boolean(step.is_ai_proposal) || step.exercise_id == null
|
||||
if (isProposal) {
|
||||
nextSlots[idx].primary = proposalSlotExercise({
|
||||
title: step.title,
|
||||
title: step.title || nextSlots[idx].learning_goal,
|
||||
proposalKey: step.proposal_key,
|
||||
aiSuggestion: step.ai_suggestion,
|
||||
})
|
||||
@@ -672,6 +731,72 @@ export function applyMatchStepsToSlots(draft, apiSteps) {
|
||||
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) {
|
||||
let next = draft
|
||||
if (res?.progression_roadmap) {
|
||||
next = syncSlotPhasesFromRoadmap(next, res.progression_roadmap)
|
||||
}
|
||||
|
||||
const offers = dedupeGapOffersBySlot(collectGapOffersFromApiResponse(res), next)
|
||||
const placedIds = new Set()
|
||||
|
||||
for (const offer of offers) {
|
||||
const idx = resolveOfferSlotIndex(next, offer)
|
||||
if (idx == null || idx < 0 || idx >= (next.slots?.length || 0)) continue
|
||||
const primary = next.slots[idx]?.primary
|
||||
if (primary?.kind === 'library' && primary.exerciseId != null) continue
|
||||
if (primary?.kind === 'proposal') continue
|
||||
|
||||
next = applyGapOfferToSlot(next, idx, offer)
|
||||
if (offer?.offer_id) placedIds.add(offer.offer_id)
|
||||
}
|
||||
|
||||
const remainingOffers = filterGapOffersForUnfilledSlots(
|
||||
next,
|
||||
dedupeGapOffersBySlot(
|
||||
collectGapOffersFromApiResponse(res).filter((o) => !placedIds.has(o?.offer_id)),
|
||||
next,
|
||||
),
|
||||
)
|
||||
|
||||
return { draft: { ...next, dirty: true }, remainingOffers }
|
||||
}
|
||||
|
||||
/** Match-Antwort: Schritte + Lücken-Angebote direkt in Slots (wie früher im Pfad-Wizard sichtbar). */
|
||||
export function applyMatchResponseToDraft(draft, res) {
|
||||
let next = applyMatchStepsToSlots(draft, res?.steps)
|
||||
if (res?.progression_roadmap) {
|
||||
next = {
|
||||
...syncSlotPhasesFromRoadmap(next, res.progression_roadmap),
|
||||
pathSkillExpectations: res?.path_skill_expectations || next.pathSkillExpectations,
|
||||
}
|
||||
}
|
||||
const { draft: withOffers, remainingOffers } = applyGapOffersFromResponse(next, res)
|
||||
return { draft: withOffers, remainingOffers }
|
||||
}
|
||||
|
||||
/** Evaluate-Antwort: KI-Angebote in leere Slots (ohne Schritte neu zu matchen). */
|
||||
export function applyEvaluateResponseToDraft(draft, res) {
|
||||
return applyGapOffersFromResponse(draft, res)
|
||||
}
|
||||
|
||||
export function setSlotPrimaryLibrary(draft, slotIndex, exercise) {
|
||||
if (!exercise?.id) return draft
|
||||
const slots = (draft.slots || []).map((s, i) =>
|
||||
i === slotIndex
|
||||
? {
|
||||
...s,
|
||||
primary: librarySlotExercise({
|
||||
exerciseId: exercise.id,
|
||||
exerciseTitle: exercise.title || `Übung #${exercise.id}`,
|
||||
}),
|
||||
}
|
||||
: s,
|
||||
)
|
||||
return syncProgressionRoadmapFromSlots({ ...draft, slots, dirty: true })
|
||||
}
|
||||
|
||||
export function applyGapOfferToSlot(draft, slotIndex, offer, aiSuggestion = null) {
|
||||
const nextSlots = (draft.slots || []).map((s) => ({ ...s, primary: { ...s.primary }, siblings: [...(s.siblings || [])] }))
|
||||
if (slotIndex < 0 || slotIndex >= nextSlots.length) return draft
|
||||
|
||||
Reference in new issue
Block a user