update
This commit is contained in:
@@ -307,16 +307,17 @@ def _optionen_schema(opts) -> list[dict] | None:
|
|||||||
return out
|
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.
|
"""{"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):
|
if not isinstance(data, dict):
|
||||||
return None
|
return None
|
||||||
frage = str(data.get("frage", "")).strip()
|
frage = str(data.get("frage", "")).strip()
|
||||||
out = _optionen_schema(data.get("optionen"))
|
out = _optionen_schema(data.get("optionen"))
|
||||||
if not frage or out is None:
|
if not frage or out is None:
|
||||||
return 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 None
|
||||||
return {"frage": frage, "optionen": out}
|
return {"frage": frage, "optionen": out}
|
||||||
|
|
||||||
@@ -342,12 +343,12 @@ async def quiz_generieren(
|
|||||||
try:
|
try:
|
||||||
section_block, kompakt_block = _bloecke(section, kompakt)
|
section_block, kompakt_block = _bloecke(section, kompakt)
|
||||||
anzahl_block = (
|
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
|
if schwer else
|
||||||
"GENAU EINE Option ist richtig, die anderen drei sind klar falsch."
|
"GENAU EINE Option ist richtig, die anderen drei sind klar falsch."
|
||||||
)
|
)
|
||||||
return await _gen_call(
|
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,
|
topic=topic, baustein=baustein, section_block=section_block,
|
||||||
kompakt_block=kompakt_block, muster=muster, anzahl_block=anzahl_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({
|
export async function pruefeBaustein({
|
||||||
topic, baustein, section, section_kompakt = '', provider,
|
topic, baustein, section, section_kompakt = '', provider,
|
||||||
aktion = 'frage', frage = '', letzte_bewertung = '', vermeide = [],
|
aktion = 'frage', frage = '', letzte_bewertung = '', vermeide = [],
|
||||||
nachgefragt = false, begruendung = '', muster = '', cap = 10, messages = [], gruendlich = false,
|
nachgefragt = false, begruendung = '', muster = '', cap = 6, messages = [], gruendlich = false,
|
||||||
auswahl = [], korrekt = [], loesung = '', alternativen = [], eingabe = '',
|
auswahl = [], korrekt = [], loesung = '', alternativen = [], eingabe = '', schwer = false,
|
||||||
}) {
|
}) {
|
||||||
const res = await fetch(`${BASE}/bausteine/pruefung`, {
|
const res = await fetch(`${BASE}/bausteine/pruefung`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
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)
|
return jsonOrThrow(res)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user