Display scheduled times with review options
John Smith

John Smith commited on 2022-28 22:43:26
Showing 2 changed files, with 24 additions and 8 deletions.


When prompted for evaluation when reviewing, Memoire now displays
the delays that would be scheduled for each option. These delays are,
inconveniently, displayed in seconds for now, and will not
match actual scheduling (due to random offsets from d8a3532).

Yak-shaving: `review.lua` API now allows one to access scheduled times
(with `review.schedule()`) without updating cards, though these times
will not match actual scheduling (for reason mentioned above).
... ...
@@ -155,7 +155,12 @@ elseif action == "r" then
155 155
                 io.write("\n")
156 156
                 io.read("l")
157 157
                 imgify(pst:gsub("%%A", (pr.ans:gsub("%%", "%%%%"))))
158
-                io.write("\nAgain / Hard / Good / Easy / Correction ")
158
+                io.write(string.format(
159
+                    "\nAgain / Hard (%d) / Good (%d) / Easy (%d) / Correction ",
160
+                    math.floor(review.schedule(pr, st, 0.5)),
161
+                    math.floor(review.schedule(pr, st, 1)),
162
+                    math.floor(review.schedule(pr, st, 1.5))
163
+                ))
159 164
                 local resp = io.read("l")
160 165
                 local sc = succfromstr(resp)
161 166
                 if sc == -1 then
... ...
@@ -2,22 +2,33 @@
2 2
     stuff to help with the review mechanics
3 3
 ]]
4 4
 
5
+--[[
6
+    determines the delay until next review (in seconds)
7
+    when `Prompt` `prompt` is reviewed at timestamp `revtime`
8
+    with review success `revsucc`
9
+]]
10
+local function schedule(prompt, revtime, revsucc)
11
+    if revsucc and revsucc > 0 then
12
+        local ad = revtime - prompt.time
13
+        return 2.5 ^ revsucc * (ad + math.max(40000 - 0.5 * ad, 0))
14
+    else
15
+        return 15
16
+    end
17
+end
18
+
5 19
 --[[
6 20
     manipulates `Prompt` `prompt` in-place as it should be
7 21
     when reviewed at timestamp `revtime` with review success `revsucc`
8 22
 ]]
9 23
 local function update(prompt, revtime, revsucc)
10 24
     if revsucc and revsucc > 0 then
11
-        local ad = revtime - prompt.time
12
-        prompt.delay = 2.5 ^ revsucc * (ad + math.max(40000 - 0.5 * ad, 0))
13
-        -- allowed random variation, as a fraction of the "optimal" duration
14
-        local ARV = 0.1
15
-        prompt.delay = prompt.delay * ((1 - ARV) + 2 * ARV * math.random())
16 25
         prompt.succ = prompt.succ + 1
17 26
     else
18
-        prompt.delay = 30
19 27
         prompt.fail = prompt.fail + 1
20 28
     end
29
+    -- allowed random variation, as a fraction of the "optimal" duration
30
+    local ARV = 0.1
31
+    prompt.delay = schedule(prompt, revtime, revsucc) * ((1 - ARV) + 2 * ARV * math.random())
21 32
     prompt.time = revtime
22 33
 end
23 34
 
... ...
@@ -64,4 +75,4 @@ local function toreviewlist(deck)
64 75
     return ctrt
65 76
 end
66 77
 
67
-return { update = update, should = should, list = toreviewlist }
78
+return { schedule = schedule, update = update, should = should, list = toreviewlist }
68 79