第三态:会但不稳——当天错了又对不算连对,次日再来一次(202 测试 + 41/22/21/29 冒烟)

This commit is contained in:
2026-11-21 16:14:25 +08:00
parent e32598553c
commit 5ffdcce377
12 changed files with 264 additions and 24 deletions
+23 -4
View File
@@ -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: