This commit is contained in:
team3
2026-06-21 15:46:23 +02:00
parent 1910f730d2
commit 76ae2161e1
2 changed files with 9 additions and 8 deletions

View File

@@ -307,16 +307,17 @@ def _optionen_schema(opts) -> list[dict] | None:
return out
def _quiz_schema(data, genau_einer: bool = False) -> dict | None:
def _quiz_schema(data, schwer: bool = False) -> dict | None:
"""{"frage": str, "optionen": [{text, korrekt}]×4} → validiert · sonst None.
genau_einer (leichte Variante): exakt eine Option muss korrekt sein."""
leicht: genau 1 richtig (Single) · schwer: mindestens 2 richtig (mehrdeutig)."""
if not isinstance(data, dict):
return None
frage = str(data.get("frage", "")).strip()
out = _optionen_schema(data.get("optionen"))
if not frage or out is None:
return None
if genau_einer and sum(o["korrekt"] for o in out) != 1:
n_korrekt = sum(o["korrekt"] for o in out)
if (n_korrekt < 2 if schwer else n_korrekt != 1):
return None
return {"frage": frage, "optionen": out}
@@ -342,12 +343,12 @@ async def quiz_generieren(
try:
section_block, kompakt_block = _bloecke(section, kompakt)
anzahl_block = (
"0 bis 4 Optionen dürfen richtig sein (nicht zwingend genau eine). Mische bewusst."
"MINDESTENS ZWEI Optionen sind richtig (gern auch drei) — NIEMALS nur eine. Mische bewusst, welche."
if schwer else
"GENAU EINE Option ist richtig, die anderen drei sind klar falsch."
)
return await _gen_call(
"Baustein-Quiz", "guide", (lambda d: _quiz_schema(d, genau_einer=not schwer)), provider,
"Baustein-Quiz", "guide", (lambda d: _quiz_schema(d, schwer=schwer)), provider,
topic=topic, baustein=baustein, section_block=section_block,
kompakt_block=kompakt_block, muster=muster, anzahl_block=anzahl_block,
)