Add more review response options
John Smith

John Smith commited on 2022-1 21:03:20
Showing 2 changed files, with 25 additions and 7 deletions.


When reviewing, the user can now respond with one of
again/hard/good/easy/correction instead of just no/yes.
The scheduling algorithm has been tweaked accordingly.
... ...
@@ -7,11 +7,23 @@ local review = dofile "review.lua"
7 7
 local loader = dofile "loader.lua"
8 8
 
9 9
 --[[
10
-    checks (returns boolean) if a response-string is affirmative
10
+    gets the score (again/hard/good/easy/correction) from a string by first character
11
+    scores are numbers, higher is easier, -1 is correction
11 12
 ]]
12
-local function isyes(s)
13
+local function succfromstr(s)
13 14
     local f = s:sub(1, 1):lower()
14
-    return f == "y" or f == "t"
15
+    if f == "0" or f == "a" then
16
+        return 0
17
+    elseif f == "1" or f == "h" then
18
+        return 0.5
19
+    elseif f == "2" or f == "g" then
20
+        return 1
21
+    elseif f == "3" or f == "e" then
22
+        return 1.5
23
+    elseif f == "-" or f == "c" then
24
+        return -1
25
+    end
26
+    return 1
15 27
 end
16 28
 
17 29
 --[[
... ...
@@ -95,7 +107,7 @@ elseif action == "r" then
95 107
         local climn = tonumber(climt)
96 108
         if climn then
97 109
             local start = os.time()
98
-            -- review propmts in this session's set
110
+            -- review prompts in this session's set
99 111
             for ind, ip in ipairs(ctrt) do
100 112
                 if ind > climn then
101 113
                     break
... ...
@@ -110,11 +122,17 @@ elseif action == "r" then
110 122
                 ))
111 123
                 io.read("l")
112 124
                 io.write(string.format(
113
-                    "%s\nDid you get it? ",
125
+                    "%s\nAgain / Hard / Easy / Good / Correction ",
114 126
                     pst:gsub("%%A", (pr.ans:gsub("%%", "%%%%")))
115 127
                 ))
116 128
                 local resp = io.read("l")
117
-                review.update(deck[ip[1]][ip[2]], st, isyes(resp))
129
+                local sc = succfromstr(resp)
130
+                if sc == -1 then
131
+                    deck[ip[1]][ip[2]] = deck[ip[1]][ip[2]]
132
+                    -- TODO: edit card
133
+                else
134
+                    review.update(deck[ip[1]][ip[2]], st, sc)
135
+                end
118 136
                 clear()
119 137
             end
120 138
             local endt = os.time()
... ...
@@ -9,7 +9,7 @@
9 9
 local function update(prompt, revtime, revsucc)
10 10
     if revsucc then
11 11
         local ad = revtime - prompt.time
12
-        prompt.delay = 2 * ad + math.max(40000 - 0.5 * ad, 0)
12
+        prompt.delay = 2.5 ^ revsucc * ad + math.max(40000 - 0.5 * ad, 0)
13 13
         prompt.succ = prompt.succ + 1
14 14
     else
15 15
         prompt.delay = 30
16 16