update
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
@@ -78,13 +78,13 @@ export async function chatBaustein({ topic, baustein, section, section_kompakt =
|
||||
export async function pruefeBaustein({
|
||||
topic, baustein, section, section_kompakt = '', provider,
|
||||
aktion = 'frage', frage = '', letzte_bewertung = '', vermeide = [],
|
||||
nachgefragt = false, begruendung = '', muster = '', cap = 10, messages = [], gruendlich = false,
|
||||
auswahl = [], korrekt = [], loesung = '', alternativen = [], eingabe = '',
|
||||
nachgefragt = false, begruendung = '', muster = '', cap = 6, messages = [], gruendlich = false,
|
||||
auswahl = [], korrekt = [], loesung = '', alternativen = [], eingabe = '', schwer = false,
|
||||
}) {
|
||||
const res = await fetch(`${BASE}/bausteine/pruefung`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ topic, baustein, section, section_kompakt, aktion, frage, letzte_bewertung, vermeide, nachgefragt, begruendung, muster, cap, messages, provider, gruendlich, auswahl, korrekt, loesung, alternativen, eingabe }),
|
||||
body: JSON.stringify({ topic, baustein, section, section_kompakt, aktion, frage, letzte_bewertung, vermeide, nachgefragt, begruendung, muster, cap, messages, provider, gruendlich, auswahl, korrekt, loesung, alternativen, eingabe, schwer }),
|
||||
})
|
||||
return jsonOrThrow(res)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user