第三态:会但不稳——当天错了又对不算连对,次日再来一次(202 测试 + 41/22/21/29 冒烟)
This commit is contained in:
+25
-2
@@ -84,13 +84,17 @@ tests/
|
||||
入库 ──► 观察中 ──(次日复核做对)──► 粗心小记(不进队列)
|
||||
│
|
||||
└─(复核做错)──► 待复习 ──(做对 1 次)──► 已对 1 次 ──(再对)──► 待讲清
|
||||
▲ │
|
||||
│ 讲清通过 │
|
||||
▲ │ │
|
||||
│ └─(当天错了又对)──► 会但不稳 ──(次日再对)──┘
|
||||
│ │
|
||||
└──────── 答错/讲不清:间隔归零,明天 ────────┴──► 已毕业
|
||||
```
|
||||
|
||||
- **只错三次才入库**:第 1 次进「观察中」,第 2 次仍观察,第 3 次才进复习队列(`scheduler.on_import`)。
|
||||
- **粗心隔离**:24 小时内还能做对 → 判为执行失误,进「粗心小记」,不做重做训练。
|
||||
- **会但不稳(第三态)**:同一道题当天先错、看完解析当场又做对 → 不算连对一次,进 `unstable`,明天从头再来;
|
||||
做对一次才回到 `passed_once`。理由是「听完会了」不等于「明天还记得」,也是家长最常问的「怎么又错了」的解释。
|
||||
`mistakes.unstable_count` 记次数,周报里单独显示「会但不稳 N 道」。
|
||||
- **连对两次才到「讲清」**:同题第二次靠记忆,所以第二档之后必须讲一遍。
|
||||
- **间隔**:1 → 3 → 7 → 15 → 30 天;答错或讲不清 → 归零,明天再来。
|
||||
- **每天最多 5 道**:`DAILY_CAP=5`,服务端截断,第 5 道之后不再追加。
|
||||
@@ -502,3 +506,22 @@ python tests/smoke_http.py # 39 项 HTTP 冒烟(真起服务
|
||||
顺带记两个坑:`_LINE_NO` 少写 `(?!\d)` 会把 `1.8+0.6` 的 `1.` 当题号(算成 8.6);
|
||||
`safe_eval` 曾走 `normalize`,那里的 `strip_punct` 会把括号剥掉,`34×(90-46)` 静默变成
|
||||
`34*90-46`。(见四点二十一)
|
||||
|
||||
### 四点二十三、会但不稳:当天错了又对,不算连对
|
||||
|
||||
原来的规则是「做对就往前推一档」,于是课堂/家庭场景里最常见的一幕被记成了掌握:
|
||||
孩子做错 → 看解析 → 当场再写一遍,对了。但那只是「听完会了」,明天还记不记得,没验过。
|
||||
|
||||
- 新增状态 `unstable`(界面文案「会但不稳」):`mistakes.unstable_count` 记次数,`stage` 不动,
|
||||
`next_due` = 明天,`is_due` 认它,所以明天还会出现在队列里
|
||||
- 判定发生在 `services.attempt()` / `self_judge()`:做题前查
|
||||
`attempts` 里有没有**今天**这条错题的错答;有才传 `same_day_wrong=True`
|
||||
- 次日再做对 → 正常进 `passed_once`,间隔从 1 天重新开始(不是接着原来的 3/7 天)
|
||||
- 周报 `numbers.unstable_total`、首页「错题消灭率」小字、错题本筛选与橙色状态标签都把它显示出来:
|
||||
它既不是「已毕业」,也不是「没懂」,家长需要这个中间答案
|
||||
- `dev_advance()` 现在同时挪 `attempts` / `explain_attempts` 的 `created_at`——
|
||||
否则演示脚本里「今天错了今天又对」永远成立,第二天做对也判不成连对(踩过一次)
|
||||
|
||||
初中版(`junior/`)暂不套用这条规则:它用「做对一道变式」替代第二次连对,
|
||||
「当天再对一次」在那边本来就不算过关,语义已经不同。
|
||||
|
||||
|
||||
+9
-3
@@ -100,6 +100,7 @@ CREATE TABLE IF NOT EXISTS mistakes (
|
||||
interval_days INTEGER NOT NULL DEFAULT 1,
|
||||
next_due TEXT,
|
||||
explain_fails INTEGER NOT NULL DEFAULT 0,
|
||||
unstable_count INTEGER NOT NULL DEFAULT 0,
|
||||
created_at TEXT NOT NULL,
|
||||
graduated_at TEXT
|
||||
);
|
||||
@@ -270,10 +271,15 @@ def init_db(conn: sqlite3.Connection) -> None:
|
||||
|
||||
def _migrate(conn: sqlite3.Connection) -> None:
|
||||
"""老库补列(CREATE TABLE IF NOT EXISTS 不会改已存在的表)。"""
|
||||
want = {"questions": ["options", "kp"], "mistakes": ["options", "kp"],
|
||||
"guardians": ["phone"], "papers": ["clean_path", "image_path"]}
|
||||
want = {
|
||||
"questions": {"options": "TEXT", "kp": "TEXT"},
|
||||
"mistakes": {"options": "TEXT", "kp": "TEXT",
|
||||
"unstable_count": "INTEGER NOT NULL DEFAULT 0"},
|
||||
"guardians": {"phone": "TEXT"},
|
||||
"papers": {"clean_path": "TEXT", "image_path": "TEXT"},
|
||||
}
|
||||
for table, cols in want.items():
|
||||
ensure_columns(conn, table, {c: "TEXT" for c in cols})
|
||||
ensure_columns(conn, table, cols)
|
||||
|
||||
|
||||
def reset_db(conn: sqlite3.Connection) -> None:
|
||||
|
||||
+23
-4
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""错题状态机与复习调度(SM-2 简化版)。
|
||||
|
||||
状态(6 个):
|
||||
状态(7 个):
|
||||
observing 观察中 刚入库,错因暂定 E4;不进队列
|
||||
queued 待复习 到期了就进今日队列
|
||||
unstable 会但不稳 今天错过、当天又做对了——不算数,明天从头再来
|
||||
passed_once 已对 1 次 再做对一次就进「待讲清」
|
||||
to_explain 待讲清 等孩子讲一遍(不进刷题队列)
|
||||
graduated 已毕业 讲清通过 → 进「已消灭」档案,永不再推
|
||||
@@ -24,6 +25,7 @@ CLEAR_CARELESS_WINDOW_HOURS = 24
|
||||
STATUS_ZH = {
|
||||
"observing": "观察中",
|
||||
"queued": "待复习",
|
||||
"unstable": "会但不稳",
|
||||
"passed_once": "已对 1 次",
|
||||
"to_explain": "待讲清",
|
||||
"graduated": "已毕业",
|
||||
@@ -44,8 +46,9 @@ def is_due(mistake: dict, on: str | None = None) -> bool:
|
||||
"""到期 = 该出现在今天列表里。
|
||||
|
||||
观察中的题也会在次日回来「复核」一次:做对就是粗心,做错才确认没懂。
|
||||
不稳的题同样回到队列:今天错、今天对的,明天必须再做对一次才算过。
|
||||
"""
|
||||
if mistake.get("status") not in ("observing", "queued", "passed_once"):
|
||||
if mistake.get("status") not in ("observing", "queued", "unstable", "passed_once"):
|
||||
return False
|
||||
due = mistake.get("next_due")
|
||||
return bool(due) and due <= (on or today())
|
||||
@@ -58,8 +61,14 @@ def due_today(mistakes: list[dict], on: str | None = None, cap: int = DAILY_CAP)
|
||||
return items[:cap]
|
||||
|
||||
|
||||
def on_attempt(mistake: dict, correct: bool, created_at: str | None = None) -> dict:
|
||||
"""做了一次(重做/口答)。返回要写回 mistakes 的字段。"""
|
||||
def on_attempt(mistake: dict, correct: bool, *, created_at: str | None = None,
|
||||
same_day_wrong: bool = False) -> dict:
|
||||
"""做了一次(重做/口答)。返回要写回 mistakes 的字段。
|
||||
|
||||
:param same_day_wrong: 这道题「今天」已经错过一次。看完解析当场再做对,
|
||||
只能说明「听完会了」,说明不了「记住了」——所以不推进档位,
|
||||
只记一道「会但不稳」,明天再从头做对一次才算第一次。
|
||||
"""
|
||||
ts = created_at or now()
|
||||
stage = int(mistake.get("stage") or 0)
|
||||
wrong_count = int(mistake.get("wrong_count") or 1)
|
||||
@@ -74,6 +83,16 @@ def on_attempt(mistake: dict, correct: bool, created_at: str | None = None) -> d
|
||||
# 隔了更久还能做对 → 不是没懂,是「会但不熟」,拉开间隔进队列
|
||||
return {"status": "queued", "stage": 1, "interval_days": 3,
|
||||
"next_due": add_days(3, base=_date_of(ts)), "wrong_code": "E3"}
|
||||
if same_day_wrong:
|
||||
# 当天错了又对:不算数,明天重来;连错两次以上的是「没懂」,不是「不稳」
|
||||
return {
|
||||
"status": "unstable",
|
||||
"stage": 0,
|
||||
"interval_days": 1,
|
||||
"next_due": add_days(1, base=_date_of(ts)),
|
||||
"unstable_count": int(mistake.get("unstable_count") or 0) + 1,
|
||||
"wrong_code": mistake.get("wrong_code") or "E4",
|
||||
}
|
||||
stage += 1
|
||||
interval = INTERVALS[min(stage - 1, len(INTERVALS) - 1)]
|
||||
if stage >= 2:
|
||||
|
||||
+28
-5
@@ -917,7 +917,11 @@ def attempt(conn, gid: str, cid: str, mid: str, answer_text: str, cost_ms: int |
|
||||
if correct is None:
|
||||
return {"mistake_id": mid, "correct": None, "detail": detail, "refused": True,
|
||||
"hint": "机器不判这类题,标给家长/老师"}
|
||||
state = scheduler.on_attempt(mdict, correct)
|
||||
# 今天已经错过一次?那这次做对只能证明「看完解析会了」,不能算连对一次
|
||||
same_day_wrong = conn.execute(
|
||||
"SELECT 1 FROM attempts WHERE mistake_id=? AND is_correct=0"
|
||||
" AND substr(created_at,1,10)=? LIMIT 1", (mid, today())).fetchone() is not None
|
||||
state = scheduler.on_attempt(mdict, correct, same_day_wrong=same_day_wrong)
|
||||
with tx(conn):
|
||||
conn.execute("INSERT INTO attempts (id, mistake_id, child_id, answer_text, is_correct, cost_ms, created_at)"
|
||||
" VALUES (?,?,?,?,?,?,?)",
|
||||
@@ -938,6 +942,10 @@ def attempt(conn, gid: str, cid: str, mid: str, answer_text: str, cost_ms: int |
|
||||
"stage": state.get("stage", mdict["stage"]),
|
||||
"next_due": state.get("next_due"),
|
||||
"need_explain": state["status"] == "to_explain",
|
||||
# 会但不稳:当天错了又对。前端要明说「这次不算」,否则孩子以为过关了
|
||||
"unstable": state["status"] == "unstable",
|
||||
"unstable_hint": ("这次算「会但不稳」——明天同一道题再做对一次,才往前算。"
|
||||
if state["status"] == "unstable" else None),
|
||||
}
|
||||
|
||||
|
||||
@@ -1062,6 +1070,8 @@ def weekly_report(conn, gid: str, cid: str, week_of: str | None = None) -> dict:
|
||||
total_mistakes = conn.execute("SELECT COUNT(*) c FROM mistakes WHERE child_id=?", (cid,)).fetchone()["c"]
|
||||
graduated = conn.execute(
|
||||
"SELECT COUNT(*) c FROM mistakes WHERE child_id=? AND status='graduated'", (cid,)).fetchone()["c"]
|
||||
unstable = conn.execute(
|
||||
"SELECT COUNT(*) c FROM mistakes WHERE child_id=? AND status='unstable'", (cid,)).fetchone()["c"]
|
||||
return {
|
||||
"child": {"id": cid, "nickname": child["nickname"], "grade": child["grade"]},
|
||||
"week": {"start": start, "end": end},
|
||||
@@ -1071,6 +1081,7 @@ def weekly_report(conn, gid: str, cid: str, week_of: str | None = None) -> dict:
|
||||
"attempts_this_week": len(attempts),
|
||||
"review_days": len(daily),
|
||||
"graduated_total": graduated,
|
||||
"unstable_total": unstable,
|
||||
"active_total": total_mistakes - graduated,
|
||||
"kill_rate": round(graduated / total_mistakes * 100, 1) if total_mistakes else 0.0,
|
||||
},
|
||||
@@ -1275,6 +1286,8 @@ def stats(conn, gid: str, cid: str) -> dict:
|
||||
"mistakes_total": total,
|
||||
"by_status": by_status,
|
||||
"graduated": graduated,
|
||||
# 会但不稳:介于「已毕业」和「没懂」之间的第三态,家长看得懂,也解释了「怎么又错了」
|
||||
"unstable": by_status.get("unstable", 0),
|
||||
"kill_rate": round(graduated / total * 100, 1) if total else 0.0,
|
||||
"attempts_last7d": last7,
|
||||
"north_star": "月消灭率 ≥ 40%(已毕业 / 全部错题)",
|
||||
@@ -1282,9 +1295,15 @@ def stats(conn, gid: str, cid: str) -> dict:
|
||||
|
||||
|
||||
def dev_advance(conn, days: int = 1) -> dict:
|
||||
"""演示用:把「明天到期」提前到今天,方便一条命令看到完整生命周期。"""
|
||||
conn.execute("UPDATE mistakes SET next_due = date(next_due, ?) WHERE next_due IS NOT NULL",
|
||||
(f"-{int(days)} days",))
|
||||
"""演示用:把「明天到期」提前到今天,方便一条命令看到完整生命周期。
|
||||
|
||||
做题记录也一起往前挪:不然「今天错了、今天又对了」这条规则在演示里
|
||||
永远成立,孩子第二天做对也判不成「连对一次」。
|
||||
"""
|
||||
shift = f"-{int(days)} days"
|
||||
conn.execute("UPDATE mistakes SET next_due = date(next_due, ?) WHERE next_due IS NOT NULL", (shift,))
|
||||
conn.execute("UPDATE attempts SET created_at = datetime(created_at, ?)", (shift,))
|
||||
conn.execute("UPDATE explain_attempts SET created_at = datetime(created_at, ?)", (shift,))
|
||||
return {"advanced_days": days, "due_now": conn.execute(
|
||||
"SELECT COUNT(*) c FROM mistakes WHERE next_due<=?", (today(),)).fetchone()["c"]}
|
||||
|
||||
@@ -1562,7 +1581,10 @@ def self_judge(conn, gid: str, cid: str, mid: str, correct: bool, note: str = ""
|
||||
mdict = dict(m)
|
||||
if mdict["status"] in ("graduated", "careless"):
|
||||
raise ApiError(409, "NOT_IN_QUEUE", "这道题已经不在队列里了(已毕业或在粗心小记)")
|
||||
state = scheduler.on_attempt(mdict, bool(correct))
|
||||
same_day_wrong = conn.execute(
|
||||
"SELECT 1 FROM attempts WHERE mistake_id=? AND is_correct=0"
|
||||
" AND substr(created_at,1,10)=? LIMIT 1", (mid, today())).fetchone() is not None
|
||||
state = scheduler.on_attempt(mdict, bool(correct), same_day_wrong=same_day_wrong)
|
||||
with tx(conn):
|
||||
conn.execute(
|
||||
"INSERT INTO attempts (id, mistake_id, child_id, answer_text, is_correct, cost_ms, source, created_at)"
|
||||
@@ -1580,6 +1602,7 @@ def self_judge(conn, gid: str, cid: str, mid: str, correct: bool, note: str = ""
|
||||
"stage": state.get("stage", mdict["stage"]),
|
||||
"next_due": state.get("next_due"),
|
||||
"need_explain": state["status"] == "to_explain",
|
||||
"unstable": state["status"] == "unstable",
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user