W6:变式自校验(verify)+严档(原题做对先换一道,变式做对才算)(267 测试)
This commit is contained in:
+25
-2
@@ -27,6 +27,7 @@ STATUS_ZH = {
|
||||
"queued": "待复习",
|
||||
"unstable": "会但不稳",
|
||||
"passed_once": "已对 1 次",
|
||||
"variant_pending": "换一道",
|
||||
"to_explain": "待讲清",
|
||||
"graduated": "已毕业",
|
||||
"careless": "粗心小记",
|
||||
@@ -48,7 +49,8 @@ def is_due(mistake: dict, on: str | None = None) -> bool:
|
||||
观察中的题也会在次日回来「复核」一次:做对就是粗心,做错才确认没懂。
|
||||
不稳的题同样回到队列:今天错、今天对的,明天必须再做对一次才算过。
|
||||
"""
|
||||
if mistake.get("status") not in ("observing", "queued", "unstable", "passed_once"):
|
||||
if mistake.get("status") not in ("observing", "queued", "unstable", "passed_once",
|
||||
"variant_pending"):
|
||||
return False
|
||||
due = mistake.get("next_due")
|
||||
return bool(due) and due <= (on or today())
|
||||
@@ -62,12 +64,16 @@ def due_today(mistakes: list[dict], on: str | None = None, cap: int = DAILY_CAP)
|
||||
|
||||
|
||||
def on_attempt(mistake: dict, correct: bool, *, created_at: str | None = None,
|
||||
same_day_wrong: bool = False) -> dict:
|
||||
same_day_wrong: bool = False, strict: bool = False,
|
||||
is_variant: bool = False) -> dict:
|
||||
"""做了一次(重做/口答)。返回要写回 mistakes 的字段。
|
||||
|
||||
:param same_day_wrong: 这道题「今天」已经错过一次。看完解析当场再做对,
|
||||
只能说明「听完会了」,说明不了「记住了」——所以不推进档位,
|
||||
只记一道「会但不稳」,明天再从头做对一次才算第一次。
|
||||
:param strict: 严档。打开后,第一次做对不算数——先换一道**没见过**的变式
|
||||
(`variant_pending`),变式做对才算第一次连对。默认关闭。
|
||||
:param is_variant: 这一次做的是变式题(不是原题)。
|
||||
"""
|
||||
ts = created_at or now()
|
||||
stage = int(mistake.get("stage") or 0)
|
||||
@@ -93,6 +99,23 @@ def on_attempt(mistake: dict, correct: bool, *, created_at: str | None = None,
|
||||
"unstable_count": int(mistake.get("unstable_count") or 0) + 1,
|
||||
"wrong_code": mistake.get("wrong_code") or "E4",
|
||||
}
|
||||
if strict:
|
||||
if status == "variant_pending":
|
||||
# 变式做对了:这才是「换一层皮还会」,算第一次连对
|
||||
stage = max(stage, 1)
|
||||
interval = INTERVALS[min(stage - 1, len(INTERVALS) - 1)]
|
||||
return {"status": "passed_once", "stage": stage, "interval_days": interval,
|
||||
"next_due": add_days(interval, base=_date_of(ts)),
|
||||
"wrong_code": mistake.get("wrong_code") or "E4"}
|
||||
if is_variant:
|
||||
# 变式做错了:说明还是没懂,回队列(间隔归零)
|
||||
return {"status": "queued", "stage": 0, "interval_days": 1,
|
||||
"next_due": add_days(1, base=_date_of(ts)),
|
||||
"wrong_count": wrong_count + 1, "wrong_code": "E2"}
|
||||
# 原题做对但还没验过变式:今天就给一道,别等到明天
|
||||
return {"status": "variant_pending", "stage": 0, "interval_days": 0,
|
||||
"next_due": _date_of(ts), "wrong_code": mistake.get("wrong_code") or "E4"}
|
||||
|
||||
stage += 1
|
||||
interval = INTERVALS[min(stage - 1, len(INTERVALS) - 1)]
|
||||
if stage >= 2:
|
||||
|
||||
Reference in New Issue
Block a user