John Smith commited on 2021-329 15:52:17
Showing 3 changed files, with 24 additions and 5 deletions.
Each prompt-set record has a set of `Successes` and `Failures` fields, which count the number of successful and failed reviews, respectively. `Prompt` objects (`prompt.lua`) correspondingly have `.succ` and `.fail` fields. `review.update` has been updated to update these fields as appropriate.
| ... | ... |
@@ -1,8 +1,13 @@ |
| 1 | 1 |
PromptText: paper size: {A4} = {210 mm} x {297 mm}
|
| 2 | 2 |
LastReview: 1636245675 |
| 3 | 3 |
LastDelay: 65536 |
| 4 |
+Successes: 0 |
|
| 5 |
+Failures: 0 |
|
| 4 | 6 |
LastReview: 1636245679 |
| 5 | 7 |
LastDelay: 65536 |
| 8 |
+Successes: 0 |
|
| 9 |
+Failures: 0 |
|
| 6 | 10 |
LastReview: 1636245683 |
| 7 | 11 |
LastDelay: 65536 |
| 8 |
- |
|
| 12 |
+Successes: 0 |
|
| 13 |
+Failures: 0 |
| ... | ... |
@@ -1,6 +1,7 @@ |
| 1 | 1 |
--[[ |
| 2 | 2 |
a prompt consists of prompt text (with an answer-insertion point), |
| 3 |
- a correct answer, the review timestamp, and the review delay |
|
| 3 |
+ a correct answer, the review timestamp, the review delay, |
|
| 4 |
+ and counts of successful and failde reviews |
|
| 4 | 5 |
|
| 5 | 6 |
timestamps are seconds from the Unix epoch |
| 6 | 7 |
review delay is in seconds |
| ... | ... |
@@ -12,18 +13,20 @@ Prompt.__index = Prompt |
| 12 | 13 |
--[[ |
| 13 | 14 |
the answer-insertion point is indicated with a "%A" in the prompt text |
| 14 | 15 |
]] |
| 15 |
-function Prompt:new(pt, ca, rts, rd) |
|
| 16 |
+function Prompt:new(pt, ca, rts, rd, sc, fc) |
|
| 16 | 17 |
local o = {}
|
| 17 | 18 |
setmetatable(o, self) |
| 18 | 19 |
o.text = pt |
| 19 | 20 |
o.ans = ca |
| 20 | 21 |
o.time = tonumber(rts) |
| 21 | 22 |
o.delay = tonumber(rd) |
| 23 |
+ n.succ = sc |
|
| 24 |
+ n.fail = fc |
|
| 22 | 25 |
return o |
| 23 | 26 |
end |
| 24 | 27 |
|
| 25 | 28 |
function Prompt:__tostring() |
| 26 |
- return string.format("\"%s\" (\"%s\") %d+%d", self.text, self.ans, self.time, self.delay)
|
|
| 29 |
+ return string.format("\"%s\" (\"%s\") %d+%d %d/%d", self.text, self.ans, self.time, self.delay, self.succ, self.fail)
|
|
| 27 | 30 |
end |
| 28 | 31 |
|
| 29 | 32 |
--[[ |
| ... | ... |
@@ -48,7 +51,14 @@ function Prompt:fromrecs(recs) |
| 48 | 51 |
local ctr = 1 |
| 49 | 52 |
while m do |
| 50 | 53 |
local mpt = opt:sub(1, m - 1) .. "%A" .. opt:sub(n + 1) |
| 51 |
- table.insert(ret[i], Prompt:new(mpt, opt:sub(m + 1, n - 1), (rec.LastReview or {})[ctr], (rec.LastDelay)[ctr]))
|
|
| 54 |
+ table.insert(ret[i], Prompt:new( |
|
| 55 |
+ mpt, |
|
| 56 |
+ opt:sub(m + 1, n - 1), |
|
| 57 |
+ (rec.LastReview or {})[ctr],
|
|
| 58 |
+ (rec.LastDelay or {})[ctr],
|
|
| 59 |
+ (rec.Successes or {})[ctr],
|
|
| 60 |
+ (rec.Failures or {})[ctr]
|
|
| 61 |
+ )) |
|
| 52 | 62 |
m, n = opt:find("%{[^%}]+%}", n)
|
| 53 | 63 |
ctr = ctr + 1 |
| 54 | 64 |
end |
| ... | ... |
@@ -72,6 +82,8 @@ function Prompt:torec(prompts) |
| 72 | 82 |
end |
| 73 | 83 |
ret.LastReview[i] = pr.time |
| 74 | 84 |
ret.LastDelay[i] = pr.delay |
| 85 |
+ ret.Successes[i] = pr.succ |
|
| 86 |
+ ret.Failures[i] = pr.fail |
|
| 75 | 87 |
end |
| 76 | 88 |
return ret |
| 77 | 89 |
end |
| ... | ... |
@@ -9,8 +9,10 @@ |
| 9 | 9 |
local function update(prompt, revtime, revsucc) |
| 10 | 10 |
if revsucc then |
| 11 | 11 |
prompt.delay = 2 * (revtime - prompt.time) |
| 12 |
+ prompt.succ = prompt.succ + 1 |
|
| 12 | 13 |
else |
| 13 | 14 |
prompt.delay = 64 |
| 15 |
+ prompt.fail = prompt.fail + 1 |
|
| 14 | 16 |
end |
| 15 | 17 |
prompt.time = revtime |
| 16 | 18 |
end |
| 17 | 19 |