dracosh 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/locales/de.json +19 -13
- package/locales/en.json +19 -13
- package/locales/fr.json +21 -14
- package/locales/pl.json +21 -13
- package/locales/uk.json +24 -16
- package/package.json +3 -2
- package/src/backup.js +10 -1
- package/src/cli.js +7 -4
- package/src/judge.js +1 -1
- package/src/library.js +1 -1
- package/src/progress.js +4 -4
- package/src/scheduler.js +107 -15
- package/src/session.js +21 -11
- package/src/store.js +23 -5
- package/src/ui/App.js +9 -3
- package/src/ui/Help.js +2 -3
package/README.md
CHANGED
|
@@ -23,8 +23,8 @@ It's made for people who live in a terminal or spend most of the day at a comput
|
|
|
23
23
|
- Dracosh works out which languages a deck is in (Spanish → English, say) and which of the two you're learning, from the cards, the deck's name and your other decks, whatever language you use Dracosh in, and says when it's only a guess; set either in `/decks` when it can't tell or guesses wrong
|
|
24
24
|
- Type the answer, or press Enter with nothing typed to see it and say whether you knew it (`1` or `2`): handy for whole sentences, and it counts just the same
|
|
25
25
|
- Cloze cards for sentences: `I {{look forward}} to it` asks one gap at a time
|
|
26
|
-
- Forgiving answer checks: case and punctuation don't matter, a missing accent or special letter (ż, ł, é, ø…, and ß written as ss) still counts and the right spelling is shown with it marked, German "Baer" for "Bär" and Danish "aa" for "å" count too, an article can be left out in English ("cat" for "the cat"), while a missing or wrong article where it carries the gender ("Hund" for "der Hund") or a German umlaut left plain ("Bar" for "Bär") counts as almost: right, but the card
|
|
27
|
-
-
|
|
26
|
+
- Forgiving answer checks: case and punctuation don't matter, a missing accent or special letter (ż, ł, é, ø…, and ß written as ss) still counts and the right spelling is shown with it marked, German "Baer" for "Bär" and Danish "aa" for "å" count too, an article can be left out in English ("cat" for "the cat"), while a missing or wrong article where it carries the gender ("Hund" for "der Hund") or a German umlaut left plain ("Bar" for "Bär") counts as almost: right, but the card comes back sooner, one typo is fine on longer words, and after a miss you see letter by letter where you went wrong. Chinese, Japanese and Korean answers are checked exactly
|
|
27
|
+
- Spaced repetition with FSRS, the open-source scheduler Anki offers too: every card gets its own spacing, so the ones you know come back less and less often, from days to months. A miss brings a card back in 10 minutes, and a typo, an "almost" or a hint brings it back sooner than a clean answer. A card is only asked when it's due, and can be done any time on that day; up to 20 new cards a day, and the rest are said to be waiting for tomorrow. Progress from older versions carries over
|
|
28
28
|
- Daily goal, streaks (weekends, days off and days with nothing to practise don't break them) and 36 badges (one of them a secret)
|
|
29
29
|
- A pixel dragon that hatches from an egg, evolves over a year of streaks, blinks, and falls asleep if you ignore it
|
|
30
30
|
- 8-bit sound effects, generated from code
|
|
@@ -156,7 +156,7 @@ npm link # puts `dracosh` on your PATH
|
|
|
156
156
|
npm test
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
-
The quiz logic in `src/session.js` and `src/progress.js` does no I/O, which keeps it easy to test. The UI is built with [Ink](https://github.com/vadimdemedes/ink) and lives in `src/ui/`; every text it shows is in `locales/en.json`, read through `t("key")` from `src/i18n.js`.
|
|
159
|
+
The quiz logic in `src/session.js` and `src/progress.js` does no I/O, which keeps it easy to test. Review times come from [ts-fsrs](https://github.com/open-spaced-repetition/ts-fsrs) in `src/scheduler.js`. The UI is built with [Ink](https://github.com/vadimdemedes/ink) and lives in `src/ui/`; every text it shows is in `locales/en.json`, read through `t("key")` from `src/i18n.js`.
|
|
160
160
|
|
|
161
161
|
The other languages live next to it in `locales/`, the tour included. `npm test` checks that each one has every English key, the same `{placeholders}` and all the plural forms its language needs. If you're a native speaker and something reads oddly, a pull request is very welcome. Sound effects are generated by `scripts/make-sounds.js` (`npm run sounds`). The demo at the top is recorded with [VHS](https://github.com/charmbracelet/vhs): `vhs docs/demo/demo.tape` writes `docs/demo.gif` from a throwaway deck in `/tmp`.
|
|
162
162
|
|
package/locales/de.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
|
-
"hint": "Noch einen Buchstaben (die Karte
|
|
3
|
+
"hint": "Noch einen Buchstaben (die Karte kommt früher wieder)",
|
|
4
4
|
"add": "Karten hinzufügen oder einen neuen Stapel anlegen",
|
|
5
5
|
"decks": "Stapel wechseln oder einen neuen anlegen",
|
|
6
6
|
"settings": "Sprache, Rhythmus, Intervall, Ruhezeiten, Ton, Ziel, Tipps",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"gradeWhat": "nach dem Zeigen: wusste ich nicht (oder Esc) / wusste ich"
|
|
37
37
|
},
|
|
38
38
|
"how": {
|
|
39
|
-
"
|
|
40
|
-
"typos": "Ein falscher Buchstabe in einem längeren Wort zählt trotzdem, und du siehst die richtige Schreibweise.",
|
|
39
|
+
"spacing": "Jede Karte bekommt ihren eigenen Abstand: Je besser du sie kannst, desto länger wartet sie, von Tagen bis zu Monaten. Ein Fehler holt sie nach 10 Minuten zurück.",
|
|
40
|
+
"typos": "Ein falscher Buchstabe in einem längeren Wort zählt trotzdem, und du siehst die richtige Schreibweise. Die Karte kommt dann etwas früher wieder, wie nach einem Hinweis.",
|
|
41
41
|
"streak": "Erreiche dein Tagesziel, um deine Serie zu halten; ein Tag, an dem du alle verfügbaren Karten geschafft hast, zählt auch. Dein Drache wächst mit deiner längsten Serie.",
|
|
42
42
|
"freezes": "Ein Freeze rettet einen verpassten Tag. Du startest mit {max} und bekommst jede Woche einen zurück, höchstens {max}.",
|
|
43
43
|
"cards": "In /add ist eine Zeile eine Karte: cat = Katze; Mieze // Beispiel. Geschweifte Klammern erzeugen eine Lücke: I {{look forward}} to it."
|
|
@@ -283,7 +283,7 @@
|
|
|
283
283
|
"quiz": {
|
|
284
284
|
"youWrote": "deine Antwort: ",
|
|
285
285
|
"closeEnough": " (nah genug)",
|
|
286
|
-
"hintUsed": "mit Hinweis
|
|
286
|
+
"hintUsed": "mit Hinweis",
|
|
287
287
|
"countedCorrect": "als richtig gezählt",
|
|
288
288
|
"acceptedFromNow": " · „{answer}“ zählt ab jetzt auch",
|
|
289
289
|
"tip": "Tipp · {cat}",
|
|
@@ -338,9 +338,14 @@
|
|
|
338
338
|
"umlaut": "Fast: achte auf den Umlaut (ä, ö, ü); ae, oe, ue gehen auch.",
|
|
339
339
|
"article-umlaut": "Fast: achte auf Artikel und Umlaut; ae, oe, ue gehen auch.",
|
|
340
340
|
"held": "Die Karte kommt {now} wieder, nicht {would}.",
|
|
341
|
+
"soon": "in ein paar Minuten",
|
|
341
342
|
"days": {
|
|
342
343
|
"one": "morgen",
|
|
343
344
|
"other": "in {count} Tagen"
|
|
345
|
+
},
|
|
346
|
+
"months": {
|
|
347
|
+
"one": "in etwa einem Monat",
|
|
348
|
+
"other": "in etwa {count} Monaten"
|
|
344
349
|
}
|
|
345
350
|
}
|
|
346
351
|
},
|
|
@@ -708,7 +713,7 @@
|
|
|
708
713
|
"cardDeck": "eine Karte in einem Stapel, den es nicht gibt",
|
|
709
714
|
"cardIds": "zwei Karten mit derselben ID",
|
|
710
715
|
"noProgress": "kein Fortschritt darin",
|
|
711
|
-
"progressEntry": "eine Karte ohne
|
|
716
|
+
"progressEntry": "eine Karte ohne Wiederholungstermin",
|
|
712
717
|
"streak": "Serie und Abzeichen sind nicht lesbar"
|
|
713
718
|
},
|
|
714
719
|
"slashSwitch": "„{text}“ müsste getippt werden, und im Quiz öffnet / die Befehle. Ändere zuerst diese Karte."
|
|
@@ -732,7 +737,7 @@
|
|
|
732
737
|
"one": "{count} Karte geübt, {correct}/{total} richtig ({percent} %)",
|
|
733
738
|
"other": "{count} Karten geübt, {correct}/{total} richtig ({percent} %)"
|
|
734
739
|
},
|
|
735
|
-
"
|
|
740
|
+
"spread": "in der Lernphase: {learning} · unter einer Woche: {week} · unter einem Monat: {month} · ab einem Monat: {mastered}"
|
|
736
741
|
},
|
|
737
742
|
"data": {
|
|
738
743
|
"where": "Dracosh speichert alles in {home}",
|
|
@@ -769,7 +774,8 @@
|
|
|
769
774
|
"before-reset": "vor Reset",
|
|
770
775
|
"before-delete": "vor Löschen",
|
|
771
776
|
"before-restore": "vor Wiederherstellen",
|
|
772
|
-
"before-import": "vor Import"
|
|
777
|
+
"before-import": "vor Import",
|
|
778
|
+
"before-upgrade": "vor Update"
|
|
773
779
|
}
|
|
774
780
|
},
|
|
775
781
|
"backups": {
|
|
@@ -808,17 +814,17 @@
|
|
|
808
814
|
"cat": "Karten",
|
|
809
815
|
"text": "Ein falscher Buchstabe in einem längeren Wort zählt trotzdem als richtig. Dracosh zeigt dir die richtige Schreibweise."
|
|
810
816
|
},
|
|
811
|
-
"cards-
|
|
817
|
+
"cards-spacing": {
|
|
812
818
|
"cat": "Karten",
|
|
813
|
-
"text": "
|
|
819
|
+
"text": "Jede Karte bekommt ihren eigenen Abstand: Kannst du sie gut, wartet sie Wochen; eine knifflige kommt früher wieder."
|
|
814
820
|
},
|
|
815
821
|
"cards-miss": {
|
|
816
822
|
"cat": "Karten",
|
|
817
|
-
"text": "Eine falsch beantwortete Karte
|
|
823
|
+
"text": "Eine falsch beantwortete Karte kommt nach wenigen Minuten wieder, bis sie sitzt."
|
|
818
824
|
},
|
|
819
825
|
"cards-hint": {
|
|
820
826
|
"cat": "Karten",
|
|
821
|
-
"text": "Hängst du fest? /hint zeigt noch einen Buchstaben. Die Karte zählt,
|
|
827
|
+
"text": "Hängst du fest? /hint zeigt noch einen Buchstaben. Die Karte zählt, kommt aber früher wieder."
|
|
822
828
|
},
|
|
823
829
|
"cards-correct": {
|
|
824
830
|
"cat": "Karten",
|
|
@@ -1022,14 +1028,14 @@
|
|
|
1022
1028
|
"4",
|
|
1023
1029
|
"vier"
|
|
1024
1030
|
],
|
|
1025
|
-
"example": "Jede richtige Antwort schiebt eine Karte
|
|
1031
|
+
"example": "Jede richtige Antwort schiebt eine Karte weiter hinaus, so siehst du sie immer seltener."
|
|
1026
1032
|
},
|
|
1027
1033
|
{
|
|
1028
1034
|
"front": "Du hängst fest? Tippe `/hint` und drück Enter, dann erscheint die Antwort Buchstabe für Buchstabe. Probier's, dann tippe `Apfel`",
|
|
1029
1035
|
"back": [
|
|
1030
1036
|
"Apfel"
|
|
1031
1037
|
],
|
|
1032
|
-
"example": "Eine Antwort mit Hinweis zählt, aber die Karte
|
|
1038
|
+
"example": "Eine Antwort mit Hinweis zählt, aber die Karte kommt früher wieder."
|
|
1033
1039
|
},
|
|
1034
1040
|
{
|
|
1035
1041
|
"front": "Wie lautet der geheime Name deines Drachen? Niemand weiß es, also antworte hier absichtlich falsch und tippe `Hund`",
|
package/locales/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
|
-
"hint": "Reveal another letter (the card
|
|
3
|
+
"hint": "Reveal another letter (the card comes back sooner)",
|
|
4
4
|
"add": "Add cards to a deck, or start a new one",
|
|
5
5
|
"decks": "Switch to another deck, or start a new one",
|
|
6
6
|
"settings": "Language, rhythm, interval, quiet hours, sound, goal, tips",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"gradeWhat": "after the answer is shown: didn't know (or Esc) / knew it"
|
|
37
37
|
},
|
|
38
38
|
"how": {
|
|
39
|
-
"
|
|
40
|
-
"typos": "One wrong letter in a longer word still counts, and you see the right spelling.",
|
|
39
|
+
"spacing": "Every card gets its own spacing: the better you know it, the longer it waits, from days to months. A miss brings it back in 10 minutes.",
|
|
40
|
+
"typos": "One wrong letter in a longer word still counts, and you see the right spelling. The card comes back a little sooner, as with a hint.",
|
|
41
41
|
"streak": "Reach your daily goal to keep your streak going; a day where you did every card there was counts too. Your dragon grows with your best streak.",
|
|
42
42
|
"freezes": "A freeze covers a day you missed. You start with {max} and get one back each week, {max} at most.",
|
|
43
43
|
"cards": "In /add a line is a card: kot = cat; kitty // example. Braces make a gap to fill in: I {{look forward}} to it."
|
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
"quiz": {
|
|
281
281
|
"youWrote": "you wrote ",
|
|
282
282
|
"closeEnough": " (close enough)",
|
|
283
|
-
"hintUsed": "hint used
|
|
283
|
+
"hintUsed": "hint used",
|
|
284
284
|
"countedCorrect": "counted as correct",
|
|
285
285
|
"acceptedFromNow": " · \"{answer}\" is accepted from now on",
|
|
286
286
|
"tip": "tip · {cat}",
|
|
@@ -335,9 +335,14 @@
|
|
|
335
335
|
"umlaut": "Almost: mind the umlaut (ä, ö, ü); ae, oe, ue work too.",
|
|
336
336
|
"article-umlaut": "Almost: mind the article and the umlaut; ae, oe, ue work too.",
|
|
337
337
|
"held": "The card comes back {now}, not {would}.",
|
|
338
|
+
"soon": "in a few minutes",
|
|
338
339
|
"days": {
|
|
339
340
|
"one": "tomorrow",
|
|
340
341
|
"other": "in {count} days"
|
|
342
|
+
},
|
|
343
|
+
"months": {
|
|
344
|
+
"one": "in about a month",
|
|
345
|
+
"other": "in about {count} months"
|
|
341
346
|
}
|
|
342
347
|
}
|
|
343
348
|
},
|
|
@@ -696,7 +701,7 @@
|
|
|
696
701
|
"cardDeck": "a card in a deck that doesn't exist",
|
|
697
702
|
"cardIds": "two cards with the same id",
|
|
698
703
|
"noProgress": "no progress in it",
|
|
699
|
-
"progressEntry": "a card without its
|
|
704
|
+
"progressEntry": "a card without its review date",
|
|
700
705
|
"streak": "the streak and badges are unreadable"
|
|
701
706
|
},
|
|
702
707
|
"slashSwitch": "\"{text}\" would have to be typed, and in the quiz / opens the commands. Change that card first."
|
|
@@ -717,7 +722,7 @@
|
|
|
717
722
|
"goalReached": " ✓ goal reached",
|
|
718
723
|
"badges": "Badges {unlocked}/{total} · {mastered} cards mastered · companion: {companion}",
|
|
719
724
|
"practised": "{count} cards practised, {correct}/{total} correct ({percent}%)",
|
|
720
|
-
"
|
|
725
|
+
"spread": "learning: {learning} · under a week: {week} · under a month: {month} · a month or more: {mastered}"
|
|
721
726
|
},
|
|
722
727
|
"data": {
|
|
723
728
|
"where": "Dracosh keeps everything in {home}",
|
|
@@ -754,7 +759,8 @@
|
|
|
754
759
|
"before-reset": "before reset",
|
|
755
760
|
"before-delete": "before delete",
|
|
756
761
|
"before-restore": "before restore",
|
|
757
|
-
"before-import": "before import"
|
|
762
|
+
"before-import": "before import",
|
|
763
|
+
"before-upgrade": "before upgrade"
|
|
758
764
|
}
|
|
759
765
|
},
|
|
760
766
|
"backups": {
|
|
@@ -793,17 +799,17 @@
|
|
|
793
799
|
"cat": "Cards",
|
|
794
800
|
"text": "One wrong letter in a longer word still counts as right. Dracosh shows you the correct spelling."
|
|
795
801
|
},
|
|
796
|
-
"cards-
|
|
802
|
+
"cards-spacing": {
|
|
797
803
|
"cat": "Cards",
|
|
798
|
-
"text": "
|
|
804
|
+
"text": "Each card gets its own spacing: one you know well waits weeks, a tricky one comes back sooner."
|
|
799
805
|
},
|
|
800
806
|
"cards-miss": {
|
|
801
807
|
"cat": "Cards",
|
|
802
|
-
"text": "A missed card
|
|
808
|
+
"text": "A missed card comes back within minutes, until it sticks."
|
|
803
809
|
},
|
|
804
810
|
"cards-hint": {
|
|
805
811
|
"cat": "Cards",
|
|
806
|
-
"text": "Stuck on a card? /hint reveals one more letter. The card still counts, but
|
|
812
|
+
"text": "Stuck on a card? /hint reveals one more letter. The card still counts, but comes back sooner."
|
|
807
813
|
},
|
|
808
814
|
"cards-correct": {
|
|
809
815
|
"cat": "Cards",
|
|
@@ -1004,14 +1010,14 @@
|
|
|
1004
1010
|
"4",
|
|
1005
1011
|
"four"
|
|
1006
1012
|
],
|
|
1007
|
-
"example": "Every right answer
|
|
1013
|
+
"example": "Every right answer sends a card further off, so you see it less and less often."
|
|
1008
1014
|
},
|
|
1009
1015
|
{
|
|
1010
1016
|
"front": "Stuck? Type `/hint` and press Enter, and the answer shows up letter by letter. Try it, then type `apple`",
|
|
1011
1017
|
"back": [
|
|
1012
1018
|
"apple"
|
|
1013
1019
|
],
|
|
1014
|
-
"example": "A hinted answer still counts, but the card
|
|
1020
|
+
"example": "A hinted answer still counts, but the card comes back sooner."
|
|
1015
1021
|
},
|
|
1016
1022
|
{
|
|
1017
1023
|
"front": "What is your dragon's secret name? Nobody knows, so get this one wrong on purpose and type `dog`",
|
package/locales/fr.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
|
-
"hint": "Révéler une lettre (la carte
|
|
3
|
+
"hint": "Révéler une lettre (la carte revient plus tôt)",
|
|
4
4
|
"add": "Ajouter des cartes à un paquet, ou en créer un",
|
|
5
5
|
"decks": "Passer à un autre paquet, ou en créer un",
|
|
6
6
|
"settings": "Langue, rythme, intervalle, heures calmes, son, objectif, astuces",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"gradeWhat": "une fois la réponse affichée : je ne savais pas (ou Échap) / je savais"
|
|
37
37
|
},
|
|
38
38
|
"how": {
|
|
39
|
-
"
|
|
40
|
-
"typos": "Une seule lettre fausse dans un mot assez long compte quand même, et tu vois la bonne orthographe.",
|
|
39
|
+
"spacing": "Chaque carte a son propre espacement : mieux tu la connais, plus elle attend, de quelques jours à plusieurs mois. Une erreur la fait revenir 10 minutes plus tard.",
|
|
40
|
+
"typos": "Une seule lettre fausse dans un mot assez long compte quand même, et tu vois la bonne orthographe. La carte revient alors un peu plus tôt, comme avec un indice.",
|
|
41
41
|
"streak": "Atteins ton objectif du jour pour garder ta série ; un jour où tu as fait toutes les cartes disponibles compte aussi. Ton dragon grandit avec ta meilleure série.",
|
|
42
42
|
"freezes": "Un gel couvre un jour manqué. Tu commences avec {max} et tu en récupères un chaque semaine, {max} au maximum.",
|
|
43
43
|
"cards": "Dans /add, une ligne fait une carte : cat = chat; minou // exemple. Les accolades font un trou à remplir : I {{look forward}} to it."
|
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
"quiz": {
|
|
292
292
|
"youWrote": "ta réponse : ",
|
|
293
293
|
"closeEnough": " (assez proche)",
|
|
294
|
-
"hintUsed": "indice utilisé
|
|
294
|
+
"hintUsed": "indice utilisé",
|
|
295
295
|
"countedCorrect": "comptée comme juste",
|
|
296
296
|
"acceptedFromNow": " · « {answer} » est accepté désormais",
|
|
297
297
|
"tip": "astuce · {cat}",
|
|
@@ -347,11 +347,17 @@
|
|
|
347
347
|
"article": "Presque : attention à l’article.",
|
|
348
348
|
"umlaut": "Presque : attention au tréma (ä, ö, ü) ; ae, oe, ue marchent aussi.",
|
|
349
349
|
"article-umlaut": "Presque : attention à l’article et au tréma ; ae, oe, ue marchent aussi.",
|
|
350
|
-
"held": "La carte
|
|
350
|
+
"held": "La carte reviendra {now}, et non {would}.",
|
|
351
|
+
"soon": "dans quelques minutes",
|
|
351
352
|
"days": {
|
|
352
353
|
"one": "demain",
|
|
353
354
|
"many": "dans {count} jours",
|
|
354
355
|
"other": "dans {count} jours"
|
|
356
|
+
},
|
|
357
|
+
"months": {
|
|
358
|
+
"one": "dans environ un mois",
|
|
359
|
+
"many": "dans environ {count} mois",
|
|
360
|
+
"other": "dans environ {count} mois"
|
|
355
361
|
}
|
|
356
362
|
}
|
|
357
363
|
},
|
|
@@ -752,7 +758,7 @@
|
|
|
752
758
|
"cardDeck": "une carte dans un paquet qui n'existe pas",
|
|
753
759
|
"cardIds": "deux cartes avec le même identifiant",
|
|
754
760
|
"noProgress": "aucune progression dedans",
|
|
755
|
-
"progressEntry": "une carte sans
|
|
761
|
+
"progressEntry": "une carte sans date de révision",
|
|
756
762
|
"streak": "la série et les badges sont illisibles"
|
|
757
763
|
},
|
|
758
764
|
"slashSwitch": "Il faudrait taper « {text} », et dans le quiz / ouvre les commandes. Modifie d'abord cette carte."
|
|
@@ -778,7 +784,7 @@
|
|
|
778
784
|
"many": "{count} cartes révisées, {correct}/{total} justes ({percent} %)",
|
|
779
785
|
"other": "{count} cartes révisées, {correct}/{total} justes ({percent} %)"
|
|
780
786
|
},
|
|
781
|
-
"
|
|
787
|
+
"spread": "en apprentissage : {learning} · moins d'une semaine : {week} · moins d'un mois : {month} · un mois ou plus : {mastered}"
|
|
782
788
|
},
|
|
783
789
|
"data": {
|
|
784
790
|
"where": "Dracosh garde tout dans {home}",
|
|
@@ -815,7 +821,8 @@
|
|
|
815
821
|
"before-reset": "avant réinit.",
|
|
816
822
|
"before-delete": "avant suppression",
|
|
817
823
|
"before-restore": "avant restauration",
|
|
818
|
-
"before-import": "avant import"
|
|
824
|
+
"before-import": "avant import",
|
|
825
|
+
"before-upgrade": "avant mise à jour"
|
|
819
826
|
}
|
|
820
827
|
},
|
|
821
828
|
"backups": {
|
|
@@ -855,17 +862,17 @@
|
|
|
855
862
|
"cat": "Cartes",
|
|
856
863
|
"text": "Une seule lettre fausse dans un mot assez long compte quand même comme juste. Dracosh te montre la bonne orthographe."
|
|
857
864
|
},
|
|
858
|
-
"cards-
|
|
865
|
+
"cards-spacing": {
|
|
859
866
|
"cat": "Cartes",
|
|
860
|
-
"text": "
|
|
867
|
+
"text": "Chaque carte a son propre espacement : une carte bien connue attend des semaines, une plus difficile revient plus tôt."
|
|
861
868
|
},
|
|
862
869
|
"cards-miss": {
|
|
863
870
|
"cat": "Cartes",
|
|
864
|
-
"text": "Une carte ratée
|
|
871
|
+
"text": "Une carte ratée revient quelques minutes plus tard, jusqu'à ce qu'elle rentre."
|
|
865
872
|
},
|
|
866
873
|
"cards-hint": {
|
|
867
874
|
"cat": "Cartes",
|
|
868
|
-
"text": "Tu sèches sur une carte ? /hint révèle une lettre de plus. La carte compte, mais
|
|
875
|
+
"text": "Tu sèches sur une carte ? /hint révèle une lettre de plus. La carte compte, mais revient plus tôt."
|
|
869
876
|
},
|
|
870
877
|
"cards-correct": {
|
|
871
878
|
"cat": "Cartes",
|
|
@@ -1070,14 +1077,14 @@
|
|
|
1070
1077
|
"4",
|
|
1071
1078
|
"quatre"
|
|
1072
1079
|
],
|
|
1073
|
-
"example": "Chaque bonne réponse
|
|
1080
|
+
"example": "Chaque bonne réponse éloigne la carte, alors tu la vois de moins en moins souvent."
|
|
1074
1081
|
},
|
|
1075
1082
|
{
|
|
1076
1083
|
"front": "Tu sèches ? Tape `/hint` et appuie sur Entrée : la réponse apparaît lettre par lettre. Essaie, puis tape `pomme`",
|
|
1077
1084
|
"back": [
|
|
1078
1085
|
"pomme"
|
|
1079
1086
|
],
|
|
1080
|
-
"example": "Une réponse avec indice compte, mais la carte
|
|
1087
|
+
"example": "Une réponse avec indice compte, mais la carte revient plus tôt."
|
|
1081
1088
|
},
|
|
1082
1089
|
{
|
|
1083
1090
|
"front": "Quel est le nom secret de ton dragon ? Personne ne le sait, alors trompe-toi exprès et tape `chien`",
|
package/locales/pl.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
|
-
"hint": "Odsłoń kolejną literę (karta
|
|
3
|
+
"hint": "Odsłoń kolejną literę (karta wróci wcześniej)",
|
|
4
4
|
"add": "Dodaj karty do talii albo stwórz nową",
|
|
5
5
|
"decks": "Przełącz się na inną talię albo stwórz nową",
|
|
6
6
|
"settings": "Język, rytm, interwał, godziny ciszy, dźwięk, cel, porady",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"gradeWhat": "po pokazaniu odpowiedzi: nie pamiętam (albo Esc) / pamiętam"
|
|
37
37
|
},
|
|
38
38
|
"how": {
|
|
39
|
-
"
|
|
40
|
-
"typos": "Jedna zła litera w dłuższym słowie wciąż się liczy, a Dracosh pokazuje poprawną pisownię.",
|
|
39
|
+
"spacing": "Każda karta ma własny odstęp między powtórkami: im lepiej ją znasz, tym dłużej czeka, od kilku dni do miesięcy. Po błędzie wraca za 10 minut.",
|
|
40
|
+
"typos": "Jedna zła litera w dłuższym słowie wciąż się liczy, a Dracosh pokazuje poprawną pisownię. Karta wraca wtedy trochę wcześniej, jak po podpowiedzi.",
|
|
41
41
|
"streak": "Osiągaj cel dnia, żeby utrzymać serię; dzień, w którym zrobisz wszystkie dostępne karty, też się liczy. Twój smok rośnie wraz z najdłuższą serią.",
|
|
42
42
|
"freezes": "Zamrożenie ratuje opuszczony dzień. Na start masz {max} i co tydzień jedno wraca, maksymalnie {max}.",
|
|
43
43
|
"cards": "W /add jedna linia to karta: cat = kot; kotek // przykład. Nawiasy klamrowe tworzą lukę do uzupełnienia: I {{look forward}} to it."
|
|
@@ -299,7 +299,7 @@
|
|
|
299
299
|
"quiz": {
|
|
300
300
|
"youWrote": "twoja odpowiedź: ",
|
|
301
301
|
"closeEnough": " (wystarczająco blisko)",
|
|
302
|
-
"hintUsed": "z podpowiedzią
|
|
302
|
+
"hintUsed": "z podpowiedzią",
|
|
303
303
|
"countedCorrect": "uznane za poprawne",
|
|
304
304
|
"acceptedFromNow": " · „{answer}” od teraz też się liczy",
|
|
305
305
|
"tip": "porada · {cat}",
|
|
@@ -358,11 +358,18 @@
|
|
|
358
358
|
"umlaut": "Prawie: zwróć uwagę na umlaut (ä, ö, ü); można też pisać ae, oe, ue.",
|
|
359
359
|
"article-umlaut": "Prawie: zwróć uwagę na rodzajnik i umlaut; można też pisać ae, oe, ue.",
|
|
360
360
|
"held": "Karta wróci {now}, a nie {would}.",
|
|
361
|
+
"soon": "za kilka minut",
|
|
361
362
|
"days": {
|
|
362
363
|
"one": "jutro",
|
|
363
364
|
"few": "za {count} dni",
|
|
364
365
|
"many": "za {count} dni",
|
|
365
366
|
"other": "za {count} dnia"
|
|
367
|
+
},
|
|
368
|
+
"months": {
|
|
369
|
+
"one": "za około miesiąc",
|
|
370
|
+
"few": "za około {count} miesiące",
|
|
371
|
+
"many": "za około {count} miesięcy",
|
|
372
|
+
"other": "za około {count} miesiąca"
|
|
366
373
|
}
|
|
367
374
|
}
|
|
368
375
|
},
|
|
@@ -775,7 +782,7 @@
|
|
|
775
782
|
"cardDeck": "karta w talii, która nie istnieje",
|
|
776
783
|
"cardIds": "dwie karty z tym samym identyfikatorem",
|
|
777
784
|
"noProgress": "brak w nim postępów",
|
|
778
|
-
"progressEntry": "karta bez
|
|
785
|
+
"progressEntry": "karta bez terminu powtórki",
|
|
779
786
|
"streak": "nie da się odczytać serii i odznak"
|
|
780
787
|
},
|
|
781
788
|
"slashSwitch": "Trzeba by wpisać „{text}”, a w quizie / otwiera komendy. Najpierw popraw tę kartę."
|
|
@@ -803,7 +810,7 @@
|
|
|
803
810
|
"many": "{count} przećwiczonych kart, {correct}/{total} poprawnych ({percent}%)",
|
|
804
811
|
"other": "{count} przećwiczonej karty, {correct}/{total} poprawnych ({percent}%)"
|
|
805
812
|
},
|
|
806
|
-
"
|
|
813
|
+
"spread": "w nauce: {learning} · do tygodnia: {week} · do miesiąca: {month} · miesiąc i dłużej: {mastered}"
|
|
807
814
|
},
|
|
808
815
|
"data": {
|
|
809
816
|
"where": "Dracosh trzyma wszystko w {home}",
|
|
@@ -840,7 +847,8 @@
|
|
|
840
847
|
"before-reset": "przed resetem",
|
|
841
848
|
"before-delete": "przed usunięciem",
|
|
842
849
|
"before-restore": "przed przywróceniem",
|
|
843
|
-
"before-import": "przed importem"
|
|
850
|
+
"before-import": "przed importem",
|
|
851
|
+
"before-upgrade": "przed aktualizacją"
|
|
844
852
|
}
|
|
845
853
|
},
|
|
846
854
|
"backups": {
|
|
@@ -881,17 +889,17 @@
|
|
|
881
889
|
"cat": "Karty",
|
|
882
890
|
"text": "Jedna zła litera w dłuższym słowie wciąż się liczy. Dracosh pokazuje poprawną pisownię."
|
|
883
891
|
},
|
|
884
|
-
"cards-
|
|
892
|
+
"cards-spacing": {
|
|
885
893
|
"cat": "Karty",
|
|
886
|
-
"text": "
|
|
894
|
+
"text": "Każda karta ma własny odstęp między powtórkami: dobrze znana czeka tygodniami, trudniejsza wraca wcześniej."
|
|
887
895
|
},
|
|
888
896
|
"cards-miss": {
|
|
889
897
|
"cat": "Karty",
|
|
890
|
-
"text": "Karta z błędem wraca
|
|
898
|
+
"text": "Karta z błędem wraca po kilku minutach, aż zapadnie w pamięć."
|
|
891
899
|
},
|
|
892
900
|
"cards-hint": {
|
|
893
901
|
"cat": "Karty",
|
|
894
|
-
"text": "Karta stawia opór? /hint odsłania kolejną literę. Karta się liczy, ale
|
|
902
|
+
"text": "Karta stawia opór? /hint odsłania kolejną literę. Karta się liczy, ale wróci wcześniej."
|
|
895
903
|
},
|
|
896
904
|
"cards-correct": {
|
|
897
905
|
"cat": "Karty",
|
|
@@ -1097,14 +1105,14 @@
|
|
|
1097
1105
|
"4",
|
|
1098
1106
|
"cztery"
|
|
1099
1107
|
],
|
|
1100
|
-
"example": "Każda dobra odpowiedź
|
|
1108
|
+
"example": "Każda dobra odpowiedź odsuwa kartę dalej, więc widzisz ją coraz rzadziej."
|
|
1101
1109
|
},
|
|
1102
1110
|
{
|
|
1103
1111
|
"front": "Nie pamiętasz? Wpisz `/hint` i naciśnij Enter, a odpowiedź pojawi się litera po literze. Spróbuj, a potem wpisz `jabłko`",
|
|
1104
1112
|
"back": [
|
|
1105
1113
|
"jabłko"
|
|
1106
1114
|
],
|
|
1107
|
-
"example": "Odpowiedź z podpowiedzią się liczy, ale karta
|
|
1115
|
+
"example": "Odpowiedź z podpowiedzią się liczy, ale karta wróci wcześniej."
|
|
1108
1116
|
},
|
|
1109
1117
|
{
|
|
1110
1118
|
"front": "Jak brzmi sekretne imię twojego smoka? Nikt nie wie, więc tym razem celowo odpowiedz źle: wpisz `pies`",
|
package/locales/uk.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
|
-
"hint": "Відкрити ще одну літеру (картка
|
|
3
|
+
"hint": "Відкрити ще одну літеру (картка повернеться раніше)",
|
|
4
4
|
"add": "Додати картки до колоди або створити нову",
|
|
5
5
|
"decks": "Перейти до іншої колоди або створити нову",
|
|
6
6
|
"settings": "Мова, ритм, інтервал, тихі години, звук, ціль, поради",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"gradeWhat": "після показу відповіді: не пам'ятаю (або Esc) / пам'ятаю"
|
|
37
37
|
},
|
|
38
38
|
"how": {
|
|
39
|
-
"
|
|
40
|
-
"typos": "Одна неправильна літера в довшому слові все одно зараховується, і ти бачиш правильне написання.",
|
|
39
|
+
"spacing": "Кожна картка має власний проміжок між повтореннями: що краще ти її знаєш, то довше вона чекає, від кількох днів до місяців. Помилка повертає її через 10 хвилин.",
|
|
40
|
+
"typos": "Одна неправильна літера в довшому слові все одно зараховується, і ти бачиш правильне написання. Картка тоді повертається трохи раніше, як після підказки.",
|
|
41
41
|
"streak": "Досягай денної цілі, щоб зберегти серію; день, коли пройдено всі доступні картки, теж рахується. Твій дракон росте разом із найдовшою серією.",
|
|
42
42
|
"freezes": "Заморозка рятує пропущений день. На старті їх {max}, і щотижня одна повертається, щонайбільше {max}.",
|
|
43
43
|
"cards": "У /add кожен рядок є карткою: cat = кіт; котик // приклад. Фігурні дужки створюють пропуск: I {{look forward}} to it."
|
|
@@ -299,7 +299,7 @@
|
|
|
299
299
|
"quiz": {
|
|
300
300
|
"youWrote": "твоя відповідь: ",
|
|
301
301
|
"closeEnough": " (досить близько)",
|
|
302
|
-
"hintUsed": "з підказкою
|
|
302
|
+
"hintUsed": "з підказкою",
|
|
303
303
|
"countedCorrect": "зараховано як правильну",
|
|
304
304
|
"acceptedFromNow": " · «{answer}» відтепер теж приймається",
|
|
305
305
|
"tip": "порада · {cat}",
|
|
@@ -358,11 +358,18 @@
|
|
|
358
358
|
"umlaut": "Майже: зверни увагу на умлаут (ä, ö, ü); можна писати ae, oe, ue.",
|
|
359
359
|
"article-umlaut": "Майже: зверни увагу на артикль і умлаут; можна писати ae, oe, ue.",
|
|
360
360
|
"held": "Картка повернеться {now}, а не {would}.",
|
|
361
|
+
"soon": "через кілька хвилин",
|
|
361
362
|
"days": {
|
|
362
363
|
"one": "завтра",
|
|
363
|
-
"few": "
|
|
364
|
-
"many": "
|
|
365
|
-
"other": "
|
|
364
|
+
"few": "через {count} дні",
|
|
365
|
+
"many": "через {count} днів",
|
|
366
|
+
"other": "через {count} дня"
|
|
367
|
+
},
|
|
368
|
+
"months": {
|
|
369
|
+
"one": "приблизно через місяць",
|
|
370
|
+
"few": "приблизно через {count} місяці",
|
|
371
|
+
"many": "приблизно через {count} місяців",
|
|
372
|
+
"other": "приблизно через {count} місяця"
|
|
366
373
|
}
|
|
367
374
|
}
|
|
368
375
|
},
|
|
@@ -775,7 +782,7 @@
|
|
|
775
782
|
"cardDeck": "картка в колоді, якої не існує",
|
|
776
783
|
"cardIds": "дві картки з однаковим ідентифікатором",
|
|
777
784
|
"noProgress": "у ньому немає прогресу",
|
|
778
|
-
"progressEntry": "картка без
|
|
785
|
+
"progressEntry": "картка без дати повторення",
|
|
779
786
|
"streak": "серію і значки неможливо прочитати"
|
|
780
787
|
},
|
|
781
788
|
"slashSwitch": "Довелося б вводити «{text}», а у вікторині / відкриває команди. Спершу зміни цю картку."
|
|
@@ -803,7 +810,7 @@
|
|
|
803
810
|
"many": "{count} повторених карток, {correct}/{total} правильних ({percent}%)",
|
|
804
811
|
"other": "{count} повтореної картки, {correct}/{total} правильних ({percent}%)"
|
|
805
812
|
},
|
|
806
|
-
"
|
|
813
|
+
"spread": "вивчаються: {learning} · до тижня: {week} · до місяця: {month} · місяць і більше: {mastered}"
|
|
807
814
|
},
|
|
808
815
|
"data": {
|
|
809
816
|
"where": "Dracosh зберігає все в {home}",
|
|
@@ -840,7 +847,8 @@
|
|
|
840
847
|
"before-reset": "перед скиданням",
|
|
841
848
|
"before-delete": "перед видаленням",
|
|
842
849
|
"before-restore": "перед відновленням",
|
|
843
|
-
"before-import": "перед імпортом"
|
|
850
|
+
"before-import": "перед імпортом",
|
|
851
|
+
"before-upgrade": "перед оновленням"
|
|
844
852
|
}
|
|
845
853
|
},
|
|
846
854
|
"backups": {
|
|
@@ -881,17 +889,17 @@
|
|
|
881
889
|
"cat": "Картки",
|
|
882
890
|
"text": "Одна неправильна літера в довшому слові все одно зараховується. Dracosh показує правильне написання."
|
|
883
891
|
},
|
|
884
|
-
"cards-
|
|
892
|
+
"cards-spacing": {
|
|
885
893
|
"cat": "Картки",
|
|
886
|
-
"text": "
|
|
894
|
+
"text": "Кожна картка має власний проміжок між повтореннями: добре відома чекає тижнями, складніша повертається раніше."
|
|
887
895
|
},
|
|
888
896
|
"cards-miss": {
|
|
889
897
|
"cat": "Картки",
|
|
890
|
-
"text": "Картка з помилкою повертається
|
|
898
|
+
"text": "Картка з помилкою повертається через кілька хвилин, поки не запам'ятається."
|
|
891
899
|
},
|
|
892
900
|
"cards-hint": {
|
|
893
901
|
"cat": "Картки",
|
|
894
|
-
"text": "Не знаєш, що далі? /hint відкриває ще одну літеру. Картка рахується, але
|
|
902
|
+
"text": "Не знаєш, що далі? /hint відкриває ще одну літеру. Картка рахується, але повернеться раніше."
|
|
895
903
|
},
|
|
896
904
|
"cards-correct": {
|
|
897
905
|
"cat": "Картки",
|
|
@@ -1097,14 +1105,14 @@
|
|
|
1097
1105
|
"4",
|
|
1098
1106
|
"чотири"
|
|
1099
1107
|
],
|
|
1100
|
-
"example": "Кожна правильна відповідь
|
|
1108
|
+
"example": "Кожна правильна відповідь відсуває картку далі, тож ти бачиш її дедалі рідше."
|
|
1101
1109
|
},
|
|
1102
1110
|
{
|
|
1103
1111
|
"front": "Не знаєш відповіді? Введи `/hint` і натисни Enter, і відповідь з'являтиметься літера за літерою. Спробуй, а потім введи `яблуко`",
|
|
1104
1112
|
"back": [
|
|
1105
1113
|
"яблуко"
|
|
1106
1114
|
],
|
|
1107
|
-
"example": "Відповідь із підказкою рахується, але картка
|
|
1115
|
+
"example": "Відповідь із підказкою рахується, але картка повернеться раніше."
|
|
1108
1116
|
},
|
|
1109
1117
|
{
|
|
1110
1118
|
"front": "Яке таємне ім'я твого дракона? Ніхто не знає, тож цього разу навмисно відповідай неправильно: введи `собака`",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dracosh",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A gamified language or definitions trainer for your terminal. Your personal pixel dragon grows with your progress.",
|
|
5
5
|
"author": "Tomasz Przyborowski (https://github.com/lynthius)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"htm": "3.1.1",
|
|
46
46
|
"ink": "7.1.1",
|
|
47
|
-
"react": "19.2.4"
|
|
47
|
+
"react": "19.2.4",
|
|
48
|
+
"ts-fsrs": "5.4.2"
|
|
48
49
|
}
|
|
49
50
|
}
|
package/src/backup.js
CHANGED
|
@@ -2,7 +2,7 @@ import { t } from "./i18n.js";
|
|
|
2
2
|
import { copyFile, readdir, rm } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { dayKey } from "./dates.js";
|
|
5
|
-
import { DATA_FILES, HOME, readJson, writeJson } from "./store.js";
|
|
5
|
+
import { DATA_FILES, HOME, readJson, saveState, writeJson } from "./store.js";
|
|
6
6
|
|
|
7
7
|
// A backup is one JSON file in ~/.dracosh/backups holding the library, progress and settings as they
|
|
8
8
|
// were. One is taken on the first start of each day, and right before anything that changes a lot at
|
|
@@ -73,6 +73,15 @@ export async function dailyBackup(now = Date.now()) {
|
|
|
73
73
|
return backupNow("daily", now, { skipDamaged: true });
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
// Progress an older Dracosh wrote, brought up to date by loadState (`upgraded`): backed up as it was on
|
|
77
|
+
// disk, then saved in this version's shape. → whether it did
|
|
78
|
+
export async function saveUpgraded(state, now = Date.now()) {
|
|
79
|
+
if (!state.upgraded) return false;
|
|
80
|
+
await backupNow("before-upgrade", now);
|
|
81
|
+
await saveState(state);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
76
85
|
// → newest first: { file, created, reason, decks, cards, practiced }
|
|
77
86
|
export async function listBackups() {
|
|
78
87
|
const list = [];
|
package/src/cli.js
CHANGED
|
@@ -6,9 +6,9 @@ import { createInterface } from "node:readline/promises";
|
|
|
6
6
|
import { createAlerts } from "./alerts.js";
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
import { language, setLanguage, t } from "./i18n.js";
|
|
9
|
-
import { BACKUP_DIR, dailyBackup, listBackups, restoreBackup } from "./backup.js";
|
|
9
|
+
import { BACKUP_DIR, dailyBackup, listBackups, restoreBackup, saveUpgraded } from "./backup.js";
|
|
10
10
|
import { ensureProgress, snapshot } from "./progress.js";
|
|
11
|
-
import {
|
|
11
|
+
import { intervalDays, MASTERED_DAYS } from "./scheduler.js";
|
|
12
12
|
import { createSession } from "./session.js";
|
|
13
13
|
import { DEFAULTS, formatInterval, normalizeSettings } from "./settings.js";
|
|
14
14
|
import { seedLibrary } from "./starter.js";
|
|
@@ -45,11 +45,13 @@ function printStats(state, settings) {
|
|
|
45
45
|
|
|
46
46
|
const entries = Object.values(state.items);
|
|
47
47
|
if (!entries.length) return;
|
|
48
|
-
|
|
48
|
+
// how far apart the reviews are: still learning (minutes), under a week, under a month, a month or more
|
|
49
|
+
const spread = { learning: 0, week: 0, month: 0, mastered: 0 };
|
|
50
|
+
for (const entry of entries) spread[entry.phase !== "review" ? "learning" : intervalDays(entry) < 7 ? "week" : intervalDays(entry) < MASTERED_DAYS ? "month" : "mastered"] += 1;
|
|
49
51
|
const correct = entries.reduce((sum, e) => sum + e.correct, 0);
|
|
50
52
|
const total = entries.reduce((sum, e) => sum + e.seen, 0);
|
|
51
53
|
console.log(t("cli.stats.practised", { count: entries.length, correct, total, percent: Math.round((correct / total) * 100) }));
|
|
52
|
-
console.log(
|
|
54
|
+
console.log(t("cli.stats.spread", spread));
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
const formatTime = (ms) => new Date(ms).toLocaleString("sv").slice(0, 16);
|
|
@@ -163,6 +165,7 @@ async function main() {
|
|
|
163
165
|
|
|
164
166
|
acquireLock();
|
|
165
167
|
await dailyBackup();
|
|
168
|
+
await saveUpgraded(state);
|
|
166
169
|
if (seeded) await saveLibrary(library);
|
|
167
170
|
|
|
168
171
|
// --deck must exist (fail fast, before taking over the screen); a deck saved in /decks that has
|
package/src/judge.js
CHANGED
|
@@ -124,7 +124,7 @@ function spelledAnyWay(answer, candidate, lang) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
// German umlauts and articles are what a learner has to get right: an answer without them still counts,
|
|
127
|
-
// but as "almost" (the card
|
|
127
|
+
// but as "almost" (the card comes back sooner)
|
|
128
128
|
const NO_GENDER = new Set(["to", "att", "at", "å"]); // infinitive markers
|
|
129
129
|
// elided or plural articles that don't show the gender, per language
|
|
130
130
|
const NO_GENDER_SHOWN = { fr: new Set(["l'", "les", "des", "de l'"]), it: new Set(["l'"]), ca: new Set(["l'"]) };
|
package/src/library.js
CHANGED
|
@@ -87,7 +87,7 @@ export function createDeck(library, { name, type = "translation", languages = nu
|
|
|
87
87
|
return deck;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
// Progress is kept per direction, so turning one off only stops asking it: its
|
|
90
|
+
// Progress is kept per direction, so turning one off only stops asking it: its progress stays for later.
|
|
91
91
|
// `updated` says when: an Anki package written later makes its notes ask the new way too
|
|
92
92
|
export function setDirections(library, deckId, directions, now = Date.now()) {
|
|
93
93
|
if (!DIRECTIONS.includes(directions)) throw new Error(`Unknown direction "${directions}".`);
|
package/src/progress.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { dateLocale, t } from "./i18n.js";
|
|
2
2
|
import { addDays, dayKey, daysBetween, weekStart } from "./dates.js";
|
|
3
|
-
import {
|
|
3
|
+
import { isMastered } from "./scheduler.js";
|
|
4
4
|
|
|
5
5
|
export const MAX_FREEZES = 2;
|
|
6
|
-
const MAX_BOX = BOX_INTERVALS_DAYS.length;
|
|
7
6
|
const AT_RISK_HOUR = 19;
|
|
8
7
|
const COMEBACK_AFTER_DAYS = 5;
|
|
9
8
|
const MISSED_KEEP_DAYS = 14;
|
|
@@ -260,13 +259,14 @@ for (const badge of BADGES) {
|
|
|
260
259
|
// progress is kept per card and direction ("id:en-pl"); badges count cards
|
|
261
260
|
const cardOf = (key) => key.slice(0, key.lastIndexOf(":"));
|
|
262
261
|
|
|
263
|
-
// a card is mastered once every direction it's asked in
|
|
262
|
+
// a card is mastered once every direction it's asked in waits a month or more between reviews (see
|
|
263
|
+
// isMastered); a direction its deck
|
|
264
264
|
// no longer asks (`dormant`, kept for when it's turned back on) doesn't hold it back
|
|
265
265
|
function masteredCards(items, dormant = []) {
|
|
266
266
|
const resting = new Set(dormant);
|
|
267
267
|
items = items.filter(([key]) => !resting.has(key));
|
|
268
268
|
const byCard = new Map();
|
|
269
|
-
for (const [key, entry] of items) byCard.set(cardOf(key), (byCard.get(cardOf(key)) ?? true) && entry
|
|
269
|
+
for (const [key, entry] of items) byCard.set(cardOf(key), (byCard.get(cardOf(key)) ?? true) && isMastered(entry));
|
|
270
270
|
return [...byCard.values()].filter(Boolean).length;
|
|
271
271
|
}
|
|
272
272
|
|
package/src/scheduler.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { createEmptyCard, fsrs, Rating } from "ts-fsrs";
|
|
1
2
|
import { dayKey } from "./dates.js";
|
|
2
3
|
|
|
3
4
|
const MINUTE = 60_000;
|
|
4
5
|
const DAY = 24 * 60 * MINUTE;
|
|
5
6
|
|
|
6
|
-
//
|
|
7
|
-
|
|
7
|
+
// Each card's next review comes from FSRS (the open-source scheduler Anki offers too): it keeps an estimate of how
|
|
8
|
+
// well you know the card (stability, in days, and difficulty, 1 to 10) and asks it again when
|
|
9
|
+
// you're about to forget it, at 90% recall. A miss brings the card back in 10 minutes, and a new card
|
|
10
|
+
// answered right waits a couple of days.
|
|
11
|
+
const scheduler = fsrs({ request_retention: 0.9, learning_steps: ["10m"], relearning_steps: ["10m"], enable_fuzz: true });
|
|
8
12
|
export const RELEARN_DELAY = 10 * MINUTE;
|
|
9
13
|
export const NEW_PER_DAY = 20;
|
|
14
|
+
// a card waiting a month or more between reviews is one you know
|
|
15
|
+
export const MASTERED_DAYS = 30;
|
|
16
|
+
export { Rating };
|
|
10
17
|
|
|
11
18
|
export const DIRECTIONS = ["en-pl", "pl-en"];
|
|
12
19
|
export const itemKey = (noteId, direction) => `${noteId}:${direction}`;
|
|
@@ -17,10 +24,11 @@ export function newToday(state, now) {
|
|
|
17
24
|
|
|
18
25
|
// A review is waiting for the whole day it falls due, from midnight: a card answered at 17:00 yesterday
|
|
19
26
|
// can be done this morning. But never sooner than half a day after it was answered, so a sitting across
|
|
20
|
-
// midnight doesn't ask it again minutes later. A card just missed
|
|
27
|
+
// midnight doesn't ask it again minutes later. A card still being learned (just missed, or new) comes
|
|
28
|
+
// back at its minute.
|
|
21
29
|
const MIN_GAP = 12 * 60 * MINUTE;
|
|
22
30
|
export function readyAt(entry) {
|
|
23
|
-
if (
|
|
31
|
+
if (entry.phase !== "review") return entry.due;
|
|
24
32
|
const day = new Date(entry.due);
|
|
25
33
|
day.setHours(0, 0, 0, 0);
|
|
26
34
|
return Math.min(entry.due, Math.max(day.getTime(), (entry.last ?? 0) + MIN_GAP));
|
|
@@ -51,8 +59,8 @@ function pickDue(due, now, random) {
|
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
// What to ask next: a due review or a new card (up to the daily cap), mixed at random; null when there
|
|
54
|
-
// is nothing to do right now. Cards are never asked before they're due: answering early would
|
|
55
|
-
//
|
|
62
|
+
// is nothing to do right now. Cards are never asked before they're due: answering early would count
|
|
63
|
+
// as knowing them without the spacing that makes them stick. Never the same note twice in a row while
|
|
56
64
|
// anything else is waiting. A `tour` deck is different: each card is asked once, in deck order, and
|
|
57
65
|
// never comes back as a review. A word's own `directions` (a cloze card's gaps) replace the deck's.
|
|
58
66
|
export function pickNext({ words, state, now = Date.now(), lastNoteId = null, directions = DIRECTIONS, tour = false, random = Math.random }) {
|
|
@@ -92,15 +100,99 @@ export function startOfTomorrow(now) {
|
|
|
92
100
|
return date.getTime();
|
|
93
101
|
}
|
|
94
102
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
// How an answer rates for FSRS: a miss or "didn't know" is Again; right, but with a hint, a typo or
|
|
104
|
+
// "almost" (an article, an umlaut), is Hard; right is Good. Easy isn't used: typing it is the test.
|
|
105
|
+
export const ratingFor = ({ correct, hinted = false, almost = false }) => (!correct ? Rating.Again : hinted || almost ? Rating.Hard : Rating.Good);
|
|
106
|
+
|
|
107
|
+
// a card's progress, as kept in state.json: the answers so far (seen, correct, wrong, streak), when it
|
|
108
|
+
// was last answered and is next due, and FSRS's memory of it
|
|
109
|
+
const PHASES = ["new", "learning", "review", "relearning"]; // FSRS's State, by number
|
|
110
|
+
const round = (value) => Math.round(value * 10_000) / 10_000;
|
|
111
|
+
|
|
112
|
+
function toCard(entry, now) {
|
|
113
|
+
if (!entry) return createEmptyCard(new Date(now));
|
|
114
|
+
return {
|
|
115
|
+
due: new Date(entry.due),
|
|
116
|
+
stability: entry.stability,
|
|
117
|
+
difficulty: entry.difficulty,
|
|
118
|
+
elapsed_days: 0,
|
|
119
|
+
scheduled_days: intervalDays(entry),
|
|
120
|
+
learning_steps: entry.step ?? 0,
|
|
121
|
+
reps: entry.seen,
|
|
122
|
+
lapses: entry.lapses ?? 0,
|
|
123
|
+
state: PHASES.indexOf(entry.phase),
|
|
124
|
+
last_review: new Date(entry.last)
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// → the card's progress after an answer rated `rating` (see ratingFor) at `now`
|
|
129
|
+
export function grade(entry, rating, now = Date.now()) {
|
|
130
|
+
const prev = entry ?? { seen: 0, correct: 0, wrong: 0, streak: 0 };
|
|
131
|
+
// While a card is being learned, Hard repeats the step instead of moving on. Anki leaves that to
|
|
132
|
+
// you, but here a typo or a hint every time would keep the card at 15 minutes all day: the second
|
|
133
|
+
// right answer in a row (streak > 0 while still learning) moves it on, as Good does.
|
|
134
|
+
if (rating === Rating.Hard && entry && entry.phase !== "review" && entry.streak > 0) rating = Rating.Good;
|
|
135
|
+
// a clock set back since the last answer: FSRS can't answer before that, so it's taken as then
|
|
136
|
+
now = Math.max(now, entry?.last ?? now);
|
|
137
|
+
const { card } = scheduler.next(toCard(entry, now), new Date(now), rating);
|
|
138
|
+
const correct = rating !== Rating.Again;
|
|
139
|
+
const phase = PHASES[card.state];
|
|
140
|
+
// a review lands at the same time of day, so a day with a clock change is still one day
|
|
141
|
+
const due = phase === "review" ? daysLater(now, card.scheduled_days) : card.due.getTime();
|
|
142
|
+
return {
|
|
143
|
+
due,
|
|
144
|
+
last: now,
|
|
145
|
+
seen: prev.seen + 1,
|
|
146
|
+
correct: prev.correct + (correct ? 1 : 0),
|
|
147
|
+
wrong: prev.wrong + (correct ? 0 : 1),
|
|
148
|
+
streak: correct ? prev.streak + 1 : 0,
|
|
149
|
+
phase,
|
|
150
|
+
step: card.learning_steps,
|
|
151
|
+
stability: round(card.stability),
|
|
152
|
+
difficulty: round(card.difficulty),
|
|
153
|
+
lapses: card.lapses,
|
|
154
|
+
box: boxFor(phase === "review" ? card.scheduled_days : 0)
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Dracosh 0.5 and older read a Leitner `box` on every card before they look at the file's version, so
|
|
159
|
+
// one is kept, close to the interval: an older Dracosh then says the file is from a newer version
|
|
160
|
+
// instead of calling it damaged. Nothing here reads it.
|
|
161
|
+
const boxFor = (days) => Math.max(1, BOX_DAYS.filter((each) => each <= days).length);
|
|
162
|
+
|
|
163
|
+
// the days between the last answer and the next review (0 while it's still being learned)
|
|
164
|
+
export const intervalDays = (entry) => (entry.phase === "review" ? Math.max(0, Math.round((entry.due - entry.last) / DAY)) : 0);
|
|
165
|
+
export const isMastered = (entry) => intervalDays(entry) >= MASTERED_DAYS;
|
|
166
|
+
|
|
167
|
+
// Progress from Dracosh 0.5 and older, kept in Leitner boxes (1 to 5: 1, 3, 7, 14 and 30 days), as
|
|
168
|
+
// FSRS's memory of it. A box's interval is what the card was last trusted with, so it becomes the
|
|
169
|
+
// stability; the share of misses sets the difficulty, between FSRS's first guess after "Good" and
|
|
170
|
+
// after "Again". A card just missed (streak 0) is still relearning. Its due date stays.
|
|
171
|
+
const BOX_DAYS = [1, 3, 7, 14, 30];
|
|
172
|
+
export function fromBox(entry) {
|
|
173
|
+
const level = Math.min(Math.max(Math.round(entry.box) || 1, 1), BOX_DAYS.length);
|
|
174
|
+
const days = BOX_DAYS[level - 1];
|
|
175
|
+
// a count that isn't a number (a hand-edited file) is taken as none
|
|
176
|
+
const count = (value) => (Number.isFinite(value) && value > 0 ? Math.floor(value) : 0);
|
|
177
|
+
const [seen, correct, wrong, streak] = [count(entry.seen), count(entry.correct), count(entry.wrong), count(entry.streak)];
|
|
178
|
+
const missed = Math.min(wrong / Math.max(seen, 1), 1);
|
|
179
|
+
const [easy, hard] = [scheduler.init_difficulty(Rating.Good), scheduler.init_difficulty(Rating.Again)];
|
|
180
|
+
// never answered after it's due: FSRS counts the days between the two
|
|
181
|
+
const last = Number.isFinite(entry.last) ? Math.min(entry.last, entry.due) : entry.due - days * DAY;
|
|
182
|
+
return {
|
|
183
|
+
...entry,
|
|
184
|
+
seen,
|
|
185
|
+
correct,
|
|
186
|
+
wrong,
|
|
187
|
+
streak,
|
|
188
|
+
last,
|
|
189
|
+
phase: !streak && seen > 0 ? "relearning" : "review",
|
|
190
|
+
step: 0,
|
|
191
|
+
stability: days,
|
|
192
|
+
difficulty: round(easy + (hard - easy) * missed),
|
|
193
|
+
lapses: wrong,
|
|
194
|
+
box: level
|
|
195
|
+
};
|
|
104
196
|
}
|
|
105
197
|
|
|
106
198
|
export function describeDue(entry, now = Date.now()) {
|
package/src/session.js
CHANGED
|
@@ -2,8 +2,8 @@ import { t as say } from "./i18n.js"; // `t` and `text` are taken here (the cloc
|
|
|
2
2
|
import { blankGap, plainFront } from "./cardline.js";
|
|
3
3
|
import { ALMOST, closestCandidate, judge } from "./judge.js";
|
|
4
4
|
import { addVacation, applyAnswer, applyCaughtUp, markWorkWaiting, applyOverrule, calendarMonth, cancelVacations, ensureProgress, markBadgesSeen, missedOn, recordMiss, snapshot, undoMiss, unseenBadges, vacationInfo } from "./progress.js";
|
|
5
|
-
import {
|
|
6
|
-
import { recordAnswer, saveState } from "./store.js";
|
|
5
|
+
import { describeDue, grade, intervalDays, itemKey, nextDueAt, pickNext, Rating, ratingFor, startOfTomorrow } from "./scheduler.js";
|
|
6
|
+
import { recordAnswer, saveState, STATE_VERSION } from "./store.js";
|
|
7
7
|
import { createTipDeck } from "./tips.js";
|
|
8
8
|
import { dayKey } from "./dates.js";
|
|
9
9
|
import { parsePause } from "./pause.js";
|
|
@@ -32,6 +32,14 @@ export function toSpeak(question, answer = null) {
|
|
|
32
32
|
|
|
33
33
|
// Quiz logic without any I/O of its own: words, settings and persistence are injected, the UI only renders what this returns.
|
|
34
34
|
// `loadAllWords` → [{ words, deck }] for every deck of yours: "all done for today" means the whole library.
|
|
35
|
+
// the days until a card comes back (0: minutes away, still being learned), and the days a clean answer
|
|
36
|
+
// would have given it; null when the difference isn't worth a line (a day or two, or under a quarter)
|
|
37
|
+
function heldBack(entry, would) {
|
|
38
|
+
const [days, wouldDays] = [intervalDays(entry), intervalDays(would)];
|
|
39
|
+
const worth = days === 0 ? wouldDays > 0 : wouldDays - days >= 2 && wouldDays >= days * 1.25;
|
|
40
|
+
return worth ? { days, would: wouldDays } : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
export function createSession({ loadWords, loadAllWords, state, getSettings, save = saveState, now = Date.now, tipDeck = createTipDeck({ state }) }) {
|
|
36
44
|
const rules = () => ({ skipWeekends: getSettings().skipWeekends });
|
|
37
45
|
const totals = { asked: 0, correct: 0, combo: 0 };
|
|
@@ -134,7 +142,7 @@ export function createSession({ loadWords, loadAllWords, state, getSettings, sav
|
|
|
134
142
|
// An empty Enter shows the answer and nothing is written yet: you say whether you knew it (selfGrade).
|
|
135
143
|
const reveal = (question) => ({ expected: question.expected, example: question.word.example });
|
|
136
144
|
|
|
137
|
-
// After a reveal. "Knew it" counts exactly like a typed right answer:
|
|
145
|
+
// After a reveal. "Knew it" counts exactly like a typed right answer: scheduling, goal, streak, combo and
|
|
138
146
|
// badges. Long answers can't be typed word for word, and they must be able to earn everything too.
|
|
139
147
|
async function selfGrade(question, knew, { hinted = false } = {}) {
|
|
140
148
|
return { ...(await record(question, { result: knew ? "exact" : "wrong", text: "", hinted })), self: true };
|
|
@@ -146,11 +154,13 @@ export function createSession({ loadWords, loadAllWords, state, getSettings, sav
|
|
|
146
154
|
const t = now();
|
|
147
155
|
const before = state.items[key];
|
|
148
156
|
const comboBefore = totals.combo;
|
|
149
|
-
// almost right (an article left out, an umlaut left plain) counts, but
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
const
|
|
157
|
+
// almost right (an article left out, an umlaut left plain) or a typo counts, but like with a hint
|
|
158
|
+
// the card comes back sooner than after a clean answer: `held` says when, and when it would have
|
|
159
|
+
const almost = ALMOST.includes(result) || result === "typo";
|
|
160
|
+
const rating = ratingFor({ correct, hinted, almost });
|
|
161
|
+
const entry = grade(before, rating, t);
|
|
162
|
+
// a tour card never comes back, so there's nothing to say about when
|
|
163
|
+
const held = rating === Rating.Hard && !question.tour ? heldBack(entry, grade(before, Rating.Good, t)) : null;
|
|
154
164
|
recordAnswer(state, question.word.noteId, question.direction, entry, t, { countNew: !question.tour });
|
|
155
165
|
|
|
156
166
|
totals.asked += 1;
|
|
@@ -179,7 +189,7 @@ export function createSession({ loadWords, loadAllWords, state, getSettings, sav
|
|
|
179
189
|
const { question, text, key, before, comboBefore, hinted, at } = lastWrong;
|
|
180
190
|
lastWrong = null;
|
|
181
191
|
|
|
182
|
-
const entry = grade(before, true,
|
|
192
|
+
const entry = grade(before, ratingFor({ correct: true, hinted }), at);
|
|
183
193
|
state.items[key] = entry;
|
|
184
194
|
undoMiss(state, key, at);
|
|
185
195
|
state.accepted ??= {};
|
|
@@ -264,12 +274,12 @@ export function createSession({ loadWords, loadAllWords, state, getSettings, sav
|
|
|
264
274
|
}
|
|
265
275
|
|
|
266
276
|
// Reset from /settings (the caller makes a backup first). "progress" starts the game over: badges,
|
|
267
|
-
// streak, stats and the dragon's form and element; your cards and
|
|
277
|
+
// streak, stats and the dragon's form and element; your cards and how well you know them stay. "everything"
|
|
268
278
|
// empties the state as on a fresh install, so the egg hatches again.
|
|
269
279
|
async function reset(scope) {
|
|
270
280
|
if (scope === "everything") {
|
|
271
281
|
for (const key of Object.keys(state)) delete state[key];
|
|
272
|
-
Object.assign(state, { version:
|
|
282
|
+
Object.assign(state, { version: STATE_VERSION, items: {}, newToday: { date: "", count: 0 } });
|
|
273
283
|
} else {
|
|
274
284
|
delete state.progress;
|
|
275
285
|
delete state.tips;
|
package/src/store.js
CHANGED
|
@@ -4,7 +4,7 @@ import { homedir } from "node:os";
|
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { dayKey } from "./dates.js";
|
|
6
6
|
import { upgradeLibrary } from "./library.js";
|
|
7
|
-
import { itemKey, newToday } from "./scheduler.js";
|
|
7
|
+
import { fromBox, itemKey, newToday } from "./scheduler.js";
|
|
8
8
|
|
|
9
9
|
export const HOME = process.env.DRACOSH_HOME || join(homedir(), ".dracosh");
|
|
10
10
|
const LIBRARY_FILE = join(HOME, "library.json");
|
|
@@ -13,7 +13,8 @@ const SETTINGS_FILE = join(HOME, "settings.json");
|
|
|
13
13
|
// everything a backup holds, by name
|
|
14
14
|
export const DATA_FILES = { library: LIBRARY_FILE, state: STATE_FILE, settings: SETTINGS_FILE };
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// 1: Leitner boxes (Dracosh 0.5 and older); 2: FSRS
|
|
17
|
+
export const STATE_VERSION = 2;
|
|
17
18
|
const emptyState = () => ({ version: STATE_VERSION, items: {}, newToday: { date: "", count: 0 } });
|
|
18
19
|
|
|
19
20
|
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -57,19 +58,37 @@ export async function loadLibrary() {
|
|
|
57
58
|
}
|
|
58
59
|
export const saveLibrary = (library) => writeJson(LIBRARY_FILE, library);
|
|
59
60
|
|
|
60
|
-
// Progress, checked for the shape the quiz relies on; a file from a newer Dracosh is never overwritten
|
|
61
|
+
// Progress, checked for the shape the quiz relies on; a file from a newer Dracosh is never overwritten.
|
|
62
|
+
// An older one is brought up to date in memory, `upgraded` saying so: it's written with the next save,
|
|
63
|
+
// once a backup holds the file as it was (see upgradeState).
|
|
61
64
|
export async function loadState() {
|
|
62
65
|
const state = await readJson(STATE_FILE, undefined);
|
|
63
66
|
if (state === undefined) return emptyState();
|
|
64
67
|
checkState(state, STATE_FILE);
|
|
65
68
|
if (!isObject(state.newToday)) state.newToday = { date: "", count: 0 };
|
|
69
|
+
return upgradeState(state);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// progress of an older version → this one's (the same object); `upgraded` (not saved) says it changed
|
|
73
|
+
export function upgradeState(state) {
|
|
74
|
+
if ((state.version ?? 1) >= STATE_VERSION) return state;
|
|
75
|
+
for (const [key, entry] of Object.entries(state.items)) if (!("phase" in entry)) state.items[key] = fromBox(entry);
|
|
76
|
+
state.version = STATE_VERSION;
|
|
77
|
+
Object.defineProperty(state, "upgraded", { value: true, enumerable: false });
|
|
66
78
|
return state;
|
|
67
79
|
}
|
|
68
80
|
|
|
81
|
+
// a card's progress: Leitner's box in version 1, FSRS's memory since 2
|
|
82
|
+
const PHASES = new Set(["learning", "review", "relearning"]);
|
|
83
|
+
const fsrsEntry = (entry) => PHASES.has(entry.phase) && entry.stability > 0 && entry.difficulty > 0 && Number.isFinite(entry.last) && Number.isFinite(entry.seen);
|
|
84
|
+
const validEntry = (entry, version) => isObject(entry) && Number.isFinite(entry.due) && (fsrsEntry(entry) || (version < 2 && Number.isFinite(entry.box)));
|
|
85
|
+
|
|
69
86
|
// throws when `state` (read from `file`) isn't progress the quiz can use
|
|
70
87
|
export function checkState(state, file = STATE_FILE) {
|
|
71
88
|
if (!isObject(state) || !isObject(state.items)) throw damaged(file, t("errors.why.noProgress"));
|
|
72
|
-
|
|
89
|
+
// a newer Dracosh's progress may look different: said as that, not as damage
|
|
90
|
+
if (state.version > STATE_VERSION) throw new Error(t("errors.newerState", { file }));
|
|
91
|
+
if (!Object.values(state.items).every((entry) => validEntry(entry, state.version ?? 1))) throw damaged(file, t("errors.why.progressEntry"));
|
|
73
92
|
const { progress } = state;
|
|
74
93
|
const validProgress =
|
|
75
94
|
isObject(progress) &&
|
|
@@ -80,7 +99,6 @@ export function checkState(state, file = STATE_FILE) {
|
|
|
80
99
|
isObject(progress.badges) &&
|
|
81
100
|
(progress.vacations === undefined || Array.isArray(progress.vacations));
|
|
82
101
|
if (progress !== undefined && !validProgress) throw damaged(file, t("errors.why.streak"));
|
|
83
|
-
if (state.version > STATE_VERSION) throw new Error(t("errors.newerState", { file }));
|
|
84
102
|
}
|
|
85
103
|
export const saveState = (state) => writeJson(STATE_FILE, state);
|
|
86
104
|
|
package/src/ui/App.js
CHANGED
|
@@ -75,20 +75,26 @@ function AccentedAnswers({ expected, given, closest }) {
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
// "The card comes back in a few minutes, not in 2 days." Two months and more are said in months.
|
|
79
|
+
const comesBack = (days) => (days < 1 ? t("quiz.almost.soon") : days < 60 ? t("quiz.almost.days", { count: days }) : t("quiz.almost.months", { count: Math.round(days / 30) }));
|
|
80
|
+
const heldText = (held) => (comesBack(held.days) === comesBack(held.would) ? null : t("quiz.almost.held", { now: comesBack(held.days), would: comesBack(held.would) }));
|
|
81
|
+
|
|
78
82
|
function Verdict({ outcome, question }) {
|
|
79
83
|
const wrong = outcome.result === "wrong";
|
|
80
84
|
const showDiff = outcome.closest && outcome.given && !outcome.overruled && (wrong || outcome.result === "typo");
|
|
85
|
+
// a typo, an "almost" or a hint: the card comes back sooner, said on a line of its own
|
|
86
|
+
const held = outcome.held ? heldText(outcome.held) : null;
|
|
81
87
|
return html`
|
|
82
88
|
<${Box} flexDirection="column">
|
|
83
89
|
<${Text} color=${wrong ? theme.bad : theme.good} bold>${wrong ? "✗" : "✓"} ${outcome.result === "accent" || outcome.result === "umlaut" || outcome.result === "article-umlaut" ? html`<${AccentedAnswers} expected=${question.expected} given=${outcome.given} closest=${outcome.closest} />` : question.expected.join(" / ")}${outcome.result === "typo" ? t("quiz.closeEnough") : ""}<//>
|
|
84
|
-
${ALMOST.includes(outcome.result) &&
|
|
85
|
-
html`<${Text} color=${theme.warn}>${t(`quiz.almost.${outcome.result}`)}${outcome.held ? ` ${t("quiz.almost.held", { now: t("quiz.almost.days", { count: outcome.held.days }), would: t("quiz.almost.days", { count: outcome.held.would }) })}` : ""}<//>`}
|
|
90
|
+
${ALMOST.includes(outcome.result) && html`<${Text} color=${theme.warn}>${t(`quiz.almost.${outcome.result}`)}<//>`}
|
|
86
91
|
${showDiff && html`<${AnswerDiff} given=${outcome.given} closest=${outcome.closest} />`}
|
|
87
92
|
${question.word.example && html`<${Box} marginTop=${1}>${question.tour ? html`<${Marked} dimColor text=${question.word.example} />` : html`<${Text} dimColor italic>“${question.word.example}”<//>`}<//>`}
|
|
88
|
-
${(outcome.hinted || outcome.overruled) &&
|
|
93
|
+
${(outcome.hinted || outcome.overruled || held) &&
|
|
89
94
|
html`
|
|
90
95
|
<${Box} marginTop=${1} flexDirection="column">
|
|
91
96
|
${outcome.hinted && html`<${Text} dimColor>${t("quiz.hintUsed")}<//>`}
|
|
97
|
+
${held && html`<${Text} dimColor>${held}<//>`}
|
|
92
98
|
${outcome.overruled && html`<${Text} color=${theme.good}>${t("quiz.countedCorrect")}${question.tour ? "" : t("quiz.acceptedFromNow", { answer: outcome.accepted })}<//>`}
|
|
93
99
|
<//>
|
|
94
100
|
`}
|
package/src/ui/Help.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Fragment } from "react";
|
|
|
2
2
|
import { Box, useInput } from "ink";
|
|
3
3
|
import { t } from "../i18n.js";
|
|
4
4
|
import { MAX_FREEZES } from "../progress.js";
|
|
5
|
-
import { BOX_INTERVALS_DAYS } from "../scheduler.js";
|
|
6
5
|
import { cellWidth, html, KeyHints, Text, theme, usePanelWidth } from "./kit.js";
|
|
7
6
|
|
|
8
7
|
// built at render time, so the texts follow the app language
|
|
@@ -16,7 +15,7 @@ const keys = () => [
|
|
|
16
15
|
];
|
|
17
16
|
|
|
18
17
|
const how = () => [
|
|
19
|
-
t("help.how.
|
|
18
|
+
t("help.how.spacing"),
|
|
20
19
|
t("help.how.typos"),
|
|
21
20
|
t("help.how.cards"),
|
|
22
21
|
t("help.how.streak"),
|
|
@@ -62,7 +61,7 @@ const Section = ({ title, children }) => html`
|
|
|
62
61
|
<//>
|
|
63
62
|
`;
|
|
64
63
|
|
|
65
|
-
// How Dracosh works, on one screen: the keys, the rules behind the
|
|
64
|
+
// How Dracosh works, on one screen: the keys, the rules behind the spacing and the streak,
|
|
66
65
|
// and what you can do from the shell.
|
|
67
66
|
export function Help({ onClose }) {
|
|
68
67
|
const panel = usePanelWidth();
|