John Smith commited on 2021-347 21:18:55
Showing 2 changed files, with 54 additions and 12 deletions.
The Add option of `main.lua` loads a deck, reads all of standard input, parses it into cards, and saves the cards to add to the deck record.
| ... | ... |
@@ -1,11 +1,11 @@ |
| 1 | 1 |
|
| 2 |
-Successes: 1 |
|
| 3 |
-Successes: 1 |
|
| 4 |
-Successes: 1 |
|
| 2 |
+PromptText: paper size: {A4} = {210 mm} x {297 mm}
|
|
| 5 | 3 |
Failures: 0 |
| 6 | 4 |
Failures: 0 |
| 7 | 5 |
Failures: 0 |
| 8 |
-PromptText: paper size: {A4} = {210 mm} x {297 mm}
|
|
| 6 |
+Successes: 1 |
|
| 7 |
+Successes: 1 |
|
| 8 |
+Successes: 1 |
|
| 9 | 9 |
LastReview: 1638933016 |
| 10 | 10 |
LastReview: 1638933017 |
| 11 | 11 |
LastReview: 1638933020 |
| ... | ... |
@@ -13,12 +13,32 @@ LastDelay: 5374682 |
| 13 | 13 |
LastDelay: 5374676 |
| 14 | 14 |
LastDelay: 5374674 |
| 15 | 15 |
|
| 16 |
-Successes: 2.0 |
|
| 17 |
-Successes: 2.0 |
|
| 16 |
+PromptText: pol: {recall election} = {election to remove an official}
|
|
| 17 |
+Failures: 1.0 |
|
| 18 |
+Failures: 0 |
|
| 19 |
+Successes: 4.0 |
|
| 20 |
+Successes: 3.0 |
|
| 21 |
+LastReview: 1639447789 |
|
| 22 |
+LastReview: 1639275280 |
|
| 23 |
+LastDelay: 344676 |
|
| 24 |
+LastDelay: 340000 |
|
| 25 |
+ |
|
| 26 |
+PromptText: chem: {hydroxyl group structure} = {R-O-H}
|
|
| 18 | 27 |
Failures: 0 |
| 19 | 28 |
Failures: 0 |
| 20 |
-PromptText: pol: {recall election} = {election to remove an official}
|
|
| 21 |
-LastReview: 1639105251 |
|
| 22 |
-LastReview: 1639105280 |
|
| 23 |
-LastDelay: 328 |
|
| 24 |
-LastDelay: 334 |
|
| 29 |
+Successes: 1.0 |
|
| 30 |
+Successes: 1.0 |
|
| 31 |
+LastReview: 1639534558 |
|
| 32 |
+LastReview: 1639534562 |
|
| 33 |
+LastDelay: 280 |
|
| 34 |
+LastDelay: 288 |
|
| 35 |
+ |
|
| 36 |
+PromptText: chem: {carboxyl group structure} = {O=C-O-H, bond at C}
|
|
| 37 |
+Failures: 0 |
|
| 38 |
+Failures: 0 |
|
| 39 |
+Successes: 1.0 |
|
| 40 |
+Successes: 1.0 |
|
| 41 |
+LastReview: 1639534659 |
|
| 42 |
+LastReview: 1639534663 |
|
| 43 |
+LastDelay: 64 |
|
| 44 |
+LastDelay: 72 |
| ... | ... |
@@ -81,7 +81,29 @@ local deckfname = "example.rec" |
| 81 | 81 |
]] |
| 82 | 82 |
-- Add card(s) |
| 83 | 83 |
if action == "a" then |
| 84 |
- -- TODO |
|
| 84 |
+ local deck = loaddeck(deckfname) |
|
| 85 |
+ io.write("Reading prompts -- press Ctrl-D to stop\n")
|
|
| 86 |
+ local rt = io.read("a")
|
|
| 87 |
+ local cardctr = 0 |
|
| 88 |
+ local prctr = 0 |
|
| 89 |
+ for pt in rt:gmatch("(..-)\n\n") do
|
|
| 90 |
+ local nc = {}
|
|
| 91 |
+ -- these Prompts will just be converted to Rec, so we don't need to exclude answers from prompt-text |
|
| 92 |
+ for _re in pt:gmatch("%{[^%}]+%}") do
|
|
| 93 |
+ table.insert(nc, Prompt:new(pt, "", os.time(), 30, 0, 0)) |
|
| 94 |
+ prctr = prctr + 1 |
|
| 95 |
+ end |
|
| 96 |
+ table.insert(deck, nc) |
|
| 97 |
+ cardctr = cardctr + 1 |
|
| 98 |
+ end |
|
| 99 |
+ io.write(string.format( |
|
| 100 |
+ "Added %d cards (%d prompts)", |
|
| 101 |
+ cardctr, |
|
| 102 |
+ prctr |
|
| 103 |
+ )) |
|
| 104 |
+ if cardctr > 0 then |
|
| 105 |
+ savedeck(deckfname, deck) |
|
| 106 |
+ end |
|
| 85 | 107 |
-- Help |
| 86 | 108 |
elseif action == "h" then |
| 87 | 109 |
io.write(string.format( |
| 88 | 110 |