Improve review interface
John Smith

John Smith commited on 2021-342 22:02:25
Showing 2 changed files, with 34 additions and 7 deletions.


* braces surrounding non-omitted cloze portions are removed for display
* review sessions display card-count and time at end
... ...
@@ -1,14 +1,24 @@
1 1
 
2
+Successes: 1
3
+Successes: 1
4
+Successes: 1
5
+Failures: 0
6
+Failures: 0
7
+Failures: 0
8
+PromptText: paper size: {A4} = {210 mm} x {297 mm}
2 9
 LastReview: 1638933016
3 10
 LastReview: 1638933017
4 11
 LastReview: 1638933020
5 12
 LastDelay: 5374682
6 13
 LastDelay: 5374676
7 14
 LastDelay: 5374674
15
+
16
+Successes: 2.0
17
+Successes: 2.0
8 18
 Failures: 0
9 19
 Failures: 0
10
-Failures: 0
11
-Successes: 1
12
-Successes: 1
13
-Successes: 1
14
-PromptText: paper size: {A4} = {210 mm} x {297 mm}
20
+PromptText: pol: {recall election} = {election to remove an official}
21
+LastReview: 1639105251
22
+LastReview: 1639105280
23
+LastDelay: 328
24
+LastDelay: 334
... ...
@@ -91,27 +91,44 @@ elseif action == "h" then
91 91
 -- Review session
92 92
 elseif action == "r" then
93 93
     local deck = loaddeck(deckfname)
94
+    local cardcount = 0
95
+    local start = os.time()
94 96
     -- review each card that needs it
95 97
     for i, cg in ipairs(deck) do
96 98
         for j, pr in ipairs(cg) do
97 99
             if review.should(pr) then
100
+                -- remove braces for display
101
+                local pst = pr.text:gsub("%{([^{}]+)%}", "%1")
98 102
                 local st = os.time()
99 103
                 io.write(string.format(
100 104
                     "%s\n",
101
-                    pr.text:gsub("%%A", "___")
105
+                    pst:gsub("%%A", "___")
102 106
                 ))
103 107
                 io.read("l")
104 108
                 io.write(string.format(
105 109
                     "%s\nDid you get it? ",
106
-                    pr.text:gsub("%%A", pr.ans)
110
+                    pst:gsub("%%A", pr.ans)
107 111
                 ))
108 112
                 local resp = io.read("l")
109 113
                 review.update(pr, st, isyes(resp))
114
+                cardcount = cardcount + 1
110 115
                 clear()
111 116
             end
112 117
         end
113 118
     end
119
+    local endt = os.time()
120
+    io.write(string.format(
121
+        "Reviewed %d cards in %d seconds\n",
122
+        cardcount,
123
+        endt - start
124
+    ))
125
+    if cardcount > 0 then
126
+        io.write(string.format(
127
+            "(%f seconds per card)\n",
128
+            (endt - start) / cardcount
129
+        ))
114 130
         savedeck(deckfname, deck)
131
+    end
115 132
 -- Statistics
116 133
 elseif action == "s" then
117 134
     -- TODO
118 135