update
This commit is contained in:
@@ -106,6 +106,10 @@ CREATE TABLE IF NOT EXISTS leitner(
|
||||
CREATE TABLE IF NOT EXISTS befunde(
|
||||
id INTEGER PRIMARY KEY, run_id INTEGER NOT NULL, ebene TEXT NOT NULL, art TEXT NOT NULL,
|
||||
item TEXT DEFAULT '', detail TEXT DEFAULT '', status TEXT NOT NULL DEFAULT 'offen');
|
||||
CREATE TABLE IF NOT EXISTS lernstand(
|
||||
topic TEXT NOT NULL, baustein_id INTEGER NOT NULL,
|
||||
status TEXT NOT NULL DEFAULT 'aktiv', xp INTEGER NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(topic, baustein_id));
|
||||
"""
|
||||
|
||||
# Tabellen, deren Änderungen das Live-Board interessieren.
|
||||
|
||||
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user