syncretizm-fsrsendpoint.web.val.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const timeZone = "Asia/Singapore";
const State = {
New: 0,
Learning: 1,
Review: 2,
Relearning: 3,
};
const Rating = {
Again: 1,
Hard: 2,
Good: 3,
Easy: 4,
};
class ReviewLog {
rating;
elapsed_days;
scheduled_days;
review;
state;
constructor(rating, elapsed_days, scheduled_days, review, state) {
this.rating = rating;
this.elapsed_days = elapsed_days;
this.scheduled_days = Math.abs(scheduled_days);
this.review = review;
this.state = state;
}
}
class Card {
due;
stability;
difficulty;
elapsed_days;
scheduled_days;
reps;
lapses;
state;
last_review;
constructor() {
this.due = new Date();
this.stability = 0;
this.difficulty = 0;
this.elapsed_days = 0;
this.scheduled_days = 0;
this.reps = 0;
this.lapses = 0;
this.state = State.New;
this.last_review = new Date();
}
}
class SchedulingInfo {
card;
review_log;
constructor(card, review_log) {
this.card = card;
this.review_log = review_log;
}
}
class SchedulingCards {
again;
hard;
good;
easy;
constructor(card) {
this.again = { ...card };
this.hard = { ...card };
this.good = { ...card };
this.easy = { ...card };
}
update_state(state) {
if (state == State.New) {
this.again.state = State.Learning;
this.hard.state = State.Learning;
this.good.state = State.Learning;
this.easy.state = State.Review;
this.again.lapses += 1;
} else if (state == State.Learning || state == State.Relearning) {
this.again.state = state;
this.hard.state = state;
this.good.state = State.Review;
this.easy.state = State.Review;
} else if (state == State.Review) {
this.again.state = State.Relearning;
this.hard.state = State.Review;
this.good.state = State.Review;
this.easy.state = State.Review;
this.again.lapses += 1;
}
}
schedule(now, hard_interval, good_interval, easy_interval) {
this.again.scheduled_days = 0;
this.hard.scheduled_days = hard_interval;
this.good.scheduled_days = good_interval;
this.easy.scheduled_days = easy_interval;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
November 25, 2023