This commit is contained in:
team3
2026-07-12 22:41:27 +02:00
parent a9b2f5ab9e
commit 8cedcc87ec
7 changed files with 289 additions and 0 deletions

View File

@@ -276,6 +276,32 @@ def ueben_antwort(a: UebenAntwort):
return {"box": box}
@app.get("/api/topics/{topic}/baustein/{baustein_id}/karten")
def baustein_karten(topic: str, baustein_id: int):
# Flashcards genau dieses Bausteins — NICHT faellig-gefiltert (gerade gelesen → jetzt
# prüfen). Beantwortet wird über /api/ueben/antwort, Leitner-Spacing bleibt intakt.
rows = db.query(
"SELECT ar.id, ar.inhalt, a.titel, a.level, COALESCE(l.box,1) AS box"
" FROM artefakte ar JOIN atome a ON ar.atom_id=a.id"
" LEFT JOIN leitner l ON l.artefakt_id=ar.id"
" WHERE a.topic=? AND a.baustein_id=? AND ar.typ='flashcard'"
" AND ar.status='verifiziert' ORDER BY a.ord, ar.id", (topic, baustein_id))
return [{**r, "inhalt": db.uj(r["inhalt"], {})} for r in rows]
@app.get("/api/topics/{topic}/lernstand")
def lernstand_holen(topic: str):
return db.query("SELECT baustein_id, status, xp FROM lernstand WHERE topic=?", (topic,))
@app.post("/api/topics/{topic}/baustein/{baustein_id}/fertig")
def baustein_fertig(topic: str, baustein_id: int):
db.execute("INSERT INTO lernstand(topic, baustein_id, status) VALUES(?,?,'fertig')"
" ON CONFLICT(topic, baustein_id) DO UPDATE SET status='fertig'",
(topic, baustein_id))
return {"ok": True}
@app.get("/api/runs/{run_id}/kennzahlen")
def kennzahlen(run_id: int):
return {"zeilen": ledger.kennzahlen(run_id), "verbraucht": ledger.verbraucht(run_id)}