John Smith commited on 2022-172 00:34:54
Showing 1 changed files, with 3 additions and 3 deletions.
When editing an existing card, the user can (and should be able to) insert more cloze units/prompts than were already present. Before this change, reviewing the final prompts would result in an arithmetic-on-nil-value error, because the edit feature neglected to insert corresponding `ReviewDelay`, etc fields for new prompts.
| ... | ... |
@@ -22,9 +22,9 @@ end |
| 22 | 22 |
]] |
| 23 | 23 |
local function update(prompt, revtime, revsucc, conf) |
| 24 | 24 |
if revsucc and revsucc > 0 then |
| 25 |
- prompt.succ = prompt.succ + 1 |
|
| 25 |
+ prompt.succ = (prompt.succ or 0) + 1 |
|
| 26 | 26 |
else |
| 27 |
- prompt.fail = prompt.fail + 1 |
|
| 27 |
+ prompt.fail = (prompt.fail or 0) + 1 |
|
| 28 | 28 |
end |
| 29 | 29 |
-- allowed random variation, as a fraction of the "optimal" duration |
| 30 | 30 |
local ARV = conf:get("AllowedRandomVariation") or 0.1
|
| ... | ... |
@@ -36,7 +36,7 @@ end |
| 36 | 36 |
checks (returns boolean) if `Prompt` `prompt` should be reviewed now |
| 37 | 37 |
]] |
| 38 | 38 |
local function should(prompt) |
| 39 |
- return os.time() - prompt.time >= prompt.delay |
|
| 39 |
+ return os.time() - (prompt.time or 0) >= (prompt.delay or 0) |
|
| 40 | 40 |
end |
| 41 | 41 |
|
| 42 | 42 |
--[[ |
| 43 | 43 |