update
This commit is contained in:
@@ -66,6 +66,7 @@ CREATE TABLE IF NOT EXISTS baustein_progress (
|
||||
gute_antworten INTEGER NOT NULL DEFAULT 0,
|
||||
absolviert TEXT,
|
||||
verstanden TEXT,
|
||||
gemeistert TEXT,
|
||||
updated_at TEXT NOT NULL,
|
||||
PRIMARY KEY (topic, baustein)
|
||||
)
|
||||
@@ -101,6 +102,10 @@ async def init_db():
|
||||
await db.execute("ALTER TABLE baustein_progress ADD COLUMN verstanden TEXT")
|
||||
except aiosqlite.OperationalError:
|
||||
pass
|
||||
try: # Migration für Bestands-DBs ohne gemeistert-Spalte (Meisterpfad 25)
|
||||
await db.execute("ALTER TABLE baustein_progress ADD COLUMN gemeistert TEXT")
|
||||
except aiosqlite.OperationalError:
|
||||
pass
|
||||
# Migration: alte vertiefungen-Tabelle → baustein_texte (Bestand = lange Form, art 'deepdive')
|
||||
cursor = await db.execute("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'vertiefungen'")
|
||||
if await cursor.fetchone():
|
||||
@@ -338,10 +343,10 @@ async def list_vertiefungen(topic: str) -> dict[str, set[str]]:
|
||||
async def list_baustein_progress(topic: str) -> list[dict]:
|
||||
db = await get_db()
|
||||
cursor = await db.execute(
|
||||
"SELECT baustein, gute_antworten, absolviert, verstanden FROM baustein_progress WHERE topic = ?", (topic,)
|
||||
"SELECT baustein, gute_antworten, absolviert, verstanden, gemeistert FROM baustein_progress WHERE topic = ?", (topic,)
|
||||
)
|
||||
rows = await cursor.fetchall()
|
||||
return [{"baustein": b, "gute_antworten": n, "absolviert": a, "verstanden": v} for b, n, a, v in rows]
|
||||
return [{"baustein": b, "gute_antworten": n, "absolviert": a, "verstanden": v, "gemeistert": m} for b, n, a, v, m in rows]
|
||||
|
||||
|
||||
async def set_baustein_score(topic: str, baustein: str, score: int) -> int:
|
||||
@@ -375,6 +380,23 @@ async def set_baustein_verstanden(topic: str, baustein: str) -> bool:
|
||||
return cursor.rowcount > 0
|
||||
|
||||
|
||||
async def set_baustein_gemeistert(topic: str, baustein: str) -> bool:
|
||||
"""Markiert gemeistert (Meisterpfad, Score 25); True nur beim ersten Mal. Sticky."""
|
||||
db = await get_db()
|
||||
now = _now()
|
||||
await db.execute(
|
||||
"INSERT OR IGNORE INTO baustein_progress (topic, baustein, gute_antworten, updated_at) VALUES (?, ?, 0, ?)",
|
||||
(topic, baustein, now),
|
||||
)
|
||||
cursor = await db.execute(
|
||||
"UPDATE baustein_progress SET gemeistert = ?, updated_at = ? "
|
||||
"WHERE topic = ? AND baustein = ? AND gemeistert IS NULL",
|
||||
(now, now, topic, baustein),
|
||||
)
|
||||
await db.commit()
|
||||
return cursor.rowcount > 0
|
||||
|
||||
|
||||
async def set_baustein_absolviert(topic: str, baustein: str) -> bool:
|
||||
"""Markiert absolviert; True nur beim ersten Mal (steuert den Element-Task)."""
|
||||
db = await get_db()
|
||||
|
||||
Reference in New Issue
Block a user