update
This commit is contained in:
@@ -132,11 +132,10 @@ async def test_level_kalibrierung(monkeypatch):
|
||||
topic = topic_anlegen("level")
|
||||
run = run_anlegen(topic)
|
||||
ziel = db.insert("lernziele", topic=topic, text="Kann X", status="aktiv")
|
||||
b_id = db.insert("bausteine", topic=topic, ziel_id=ziel, titel="B", ord=0, status="neu")
|
||||
a1 = db.insert("atome", topic=topic, titel="Kern", typ="begriff", definition="d",
|
||||
level="M", status="neu", baustein_id=b_id, braucht=db.j([]))
|
||||
level="M", status="neu", ziel_id=ziel, braucht=db.j([]))
|
||||
a2 = db.insert("atome", topic=topic, titel="Detail", typ="aussage", definition="d",
|
||||
level="M", status="neu", baustein_id=b_id, braucht=db.j([]))
|
||||
level="M", status="neu", ziel_id=ziel, braucht=db.j([]))
|
||||
|
||||
def judge(prompt):
|
||||
return [{"atom": a1, "level": "E"}, {"atom": a2, "level": "S"},
|
||||
@@ -147,3 +146,67 @@ async def test_level_kalibrierung(monkeypatch):
|
||||
await struktur._level_kalibrieren(ctx)
|
||||
assert db.one("SELECT level FROM atome WHERE id=?", (a1,))["level"] == "E"
|
||||
assert db.one("SELECT level FROM atome WHERE id=?", (a2,))["level"] == "S"
|
||||
|
||||
|
||||
def test_level_konflikt_absenkung():
|
||||
# v(E) braucht z(S), z braucht w(M) → Kaskade senkt z UND w auf E
|
||||
topic = topic_anlegen("konflikt")
|
||||
run = run_anlegen(topic)
|
||||
ziel = db.insert("lernziele", topic=topic, text="Kann X", status="aktiv")
|
||||
def atom(titel, level):
|
||||
return db.insert("atome", topic=topic, titel=titel, typ="begriff",
|
||||
definition="d", level=level, status="neu", ziel_id=ziel,
|
||||
braucht=db.j([]))
|
||||
v, z, w = atom("V", "E"), atom("Z", "S"), atom("W", "M")
|
||||
for von, zu in ((v, z), (z, w)):
|
||||
db.execute("INSERT INTO kanten(topic, von_atom, zu_atom, art)"
|
||||
" VALUES(?,?,?,'braucht')", (topic, von, zu))
|
||||
struktur._level_konflikte_loesen(topic)
|
||||
assert db.one("SELECT level FROM atome WHERE id=?", (z,))["level"] == "E"
|
||||
assert db.one("SELECT level FROM atome WHERE id=?", (w,))["level"] == "E"
|
||||
ctx = llm.Kontext(run, topic, "minimax")
|
||||
assert not [b for b in struktur.messen(ctx) if b["art"] == "level_konflikt"]
|
||||
|
||||
|
||||
async def test_level_split_ordnung_kapitel():
|
||||
# Ein Ziel mit 4×E + 4×M → zwei Bausteine mit level, E-ord < M-ord,
|
||||
# Kapitel je Durchgang, kein level_mix/kapitel_level
|
||||
topic = topic_anlegen("split")
|
||||
run = run_anlegen(topic)
|
||||
soll = db.insert("soll", topic=topic, punkt="P", status="bestaetigt", belege=db.j([]))
|
||||
ziel = db.insert("lernziele", topic=topic, text="Kann P", soll_id=soll, status="aktiv")
|
||||
for i in range(4):
|
||||
db.insert("atome", topic=topic, titel=f"E{i}", typ="begriff", definition="d",
|
||||
level="E", status="neu", soll_id=soll, ziel_id=ziel, braucht=db.j([]))
|
||||
db.insert("atome", topic=topic, titel=f"M{i}", typ="begriff", definition="d",
|
||||
level="M", status="neu", soll_id=soll, ziel_id=ziel, braucht=db.j([]))
|
||||
ctx = llm.Kontext(run, topic, "minimax")
|
||||
ctx.ebene = "struktur"
|
||||
struktur._bausteine_schneiden(ctx)
|
||||
bausteine = db.query("SELECT * FROM bausteine WHERE topic=? ORDER BY ord", (topic,))
|
||||
assert [b["level"] for b in bausteine] == ["E", "M"]
|
||||
await struktur._kapitel_bilden(ctx)
|
||||
kaps = db.query("SELECT * FROM kapitel WHERE topic=? ORDER BY ord", (topic,))
|
||||
assert [k["level"] for k in kaps] == ["E", "M"]
|
||||
arten = {b["art"] for b in struktur.messen(ctx)}
|
||||
assert not arten & {"level_mix", "kapitel_level", "band", "partition"}
|
||||
|
||||
|
||||
def test_kein_merge_ueber_level():
|
||||
# kleine E-Gruppe darf NICHT mit kleiner M-Gruppe mergen
|
||||
topic = topic_anlegen("levelmerge")
|
||||
run = run_anlegen(topic)
|
||||
soll = db.insert("soll", topic=topic, punkt="P", status="bestaetigt", belege=db.j([]))
|
||||
z1 = db.insert("lernziele", topic=topic, text="Kann P1", soll_id=soll, status="aktiv")
|
||||
z2 = db.insert("lernziele", topic=topic, text="Kann P2", soll_id=soll, status="aktiv")
|
||||
for i in range(2):
|
||||
db.insert("atome", topic=topic, titel=f"E{i}", typ="begriff", definition="d",
|
||||
level="E", status="neu", soll_id=soll, ziel_id=z1, braucht=db.j([]))
|
||||
db.insert("atome", topic=topic, titel=f"M{i}", typ="begriff", definition="d",
|
||||
level="M", status="neu", soll_id=soll, ziel_id=z2, braucht=db.j([]))
|
||||
ctx = llm.Kontext(run, topic, "minimax")
|
||||
struktur._bausteine_schneiden(ctx)
|
||||
for b in db.query("SELECT * FROM bausteine WHERE topic=?", (topic,)):
|
||||
levels = {a["level"] for a in struktur._atome(topic)
|
||||
if a["baustein_id"] == b["id"]}
|
||||
assert levels == {b["level"]}
|
||||
|
||||
Reference in New Issue
Block a user