aboutsummaryrefslogtreecommitdiff
path: root/org-drill.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-27 21:47:19 -0500
committerCraig Jennings <c@cjennings.net>2026-05-27 21:47:19 -0500
commite45fec6778c1e483a73fb0f3652435f13b223f79 (patch)
tree7fa2dacb023b4cc6df2b407a91a0d95aa5f909bb /org-drill.el
parenta2a7471f88a8c0f5c710d5ffb90511fc54b432d7 (diff)
downloadorg-drill-e45fec6778c1e483a73fb0f3652435f13b223f79.tar.gz
org-drill-e45fec6778c1e483a73fb0f3652435f13b223f79.zip
refactor: take card-state in org-drill-determine-next-interval-simple8
Stage 5 of #147, closing the scheduler migration. simple8 now takes (state quality &optional delta-days) instead of seven positional args, binding the recall fields from the struct at the top so the algorithm body is unchanged. simple8 doesn't use ease, so the binding skips that slot. Both call-site branches collapse to (state quality [delta-days]), dropping the per-branch accessor unpacking. The testutil adapter test-scheduler--call-simple8 keeps the simple8 test calls a one-symbol rename per site. One direct simple8 call in tests/test-org-drill-prompt-and-format-helpers.el now uses the new struct API inline. With this stage landed, all three schedulers, the item-data round-trip, and every test caller go through the org-drill-card-state struct, finishing #147.
Diffstat (limited to 'org-drill.el')
-rw-r--r--org-drill.el39
1 files changed, 14 insertions, 25 deletions
diff --git a/org-drill.el b/org-drill.el
index d772657..35d4192 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -1435,17 +1435,12 @@ to a mean item quality of QUALITY."
(* -1.2403 quality)
1.4515))
-(defun org-drill-determine-next-interval-simple8 (last-interval repeats quality
- failures meanq totaln
- &optional delta-days)
- "Arguments:
-- LAST-INTERVAL -- the number of days since the item was last reviewed.
-- REPEATS -- the number of times the item has been successfully reviewed
-- EASE -- the \\='easiness factor\\='
-- QUALITY -- 0 to 5
-- DELTA-DAYS -- how many days overdue was the item when it was reviewed.
- 0 = reviewed on the scheduled day. +N = N days overdue.
- -N = reviewed N days early.
+(defun org-drill-determine-next-interval-simple8 (state quality &optional delta-days)
+ "Return the Simple8 schedule for STATE after a review of recall QUALITY (0-5).
+
+STATE is an `org-drill-card-state'. DELTA-DAYS is how many days overdue
+the item was when reviewed: 0 = on the scheduled day, +N = N days late,
+-N = N days early.
Returns the new item data, as a list of 6 values:
- NEXT-INTERVAL
@@ -1455,6 +1450,11 @@ Returns the new item data, as a list of 6 values:
- AVERAGE-QUALITY
- TOTAL-REPEATS.
See the documentation for `org-drill-get-item-data' for a description of these."
+ (let ((last-interval (org-drill-card-state-last-interval state))
+ (repeats (org-drill-card-state-repetitions state))
+ (failures (org-drill-card-state-failures state))
+ (meanq (org-drill-card-state-meanq state))
+ (totaln (org-drill-card-state-total-repeats state)))
(cl-assert (>= repeats 0))
(cl-assert (and (>= quality 0) (<= quality 5)))
(cl-assert (or (null meanq) (and (>= meanq 0) (<= meanq 5))))
@@ -1503,7 +1503,7 @@ See the documentation for `org-drill-get-item-data' for a description of these."
failures
meanq
totaln
- )))
+ ))))
;;; Essentially copied from `org-learn.el', but modified to
;;; optionally call the SM2 or simple8 functions.
@@ -1529,13 +1529,7 @@ item will be scheduled exactly this many days into the future."
(sm5 (org-drill-determine-next-interval-sm5 state quality ofmatrix))
(sm2 (org-drill-determine-next-interval-sm2 state quality))
(simple8 (org-drill-determine-next-interval-simple8
- (org-drill-card-state-last-interval state)
- (org-drill-card-state-repetitions state)
- quality
- (org-drill-card-state-failures state)
- (org-drill-card-state-meanq state)
- (org-drill-card-state-total-repeats state)
- delta-days)))
+ state quality delta-days)))
(if (numberp days-ahead)
(setq next-interval days-ahead))
@@ -1587,12 +1581,7 @@ of QUALITY."
state quality org-drill-sm5-optimal-factor-matrix))
(sm2 (org-drill-determine-next-interval-sm2 state quality))
(simple8 (org-drill-determine-next-interval-simple8
- (org-drill-card-state-last-interval state)
- (org-drill-card-state-repetitions state)
- quality
- (org-drill-card-state-failures state)
- (org-drill-card-state-meanq state)
- (org-drill-card-state-total-repeats state))))
+ state quality)))
(cond
((not (cl-plusp next-interval))
0)