tworgy-spaced-repetition 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/spaced-repetition/sm2.rb +7 -1
- data/spec/lib/spaced-repetition/sm2_spec.rb +20 -1
- metadata +1 -1
@@ -15,12 +15,14 @@ module SuperMemo
|
|
15
15
|
self.number_repetitions = 0
|
16
16
|
self.quality_of_last_recall = nil
|
17
17
|
self.repetition_interval = nil
|
18
|
-
self.next_repetition =
|
18
|
+
self.next_repetition = nil
|
19
19
|
end
|
20
20
|
|
21
21
|
def process_recall_result(quality_of_recall)
|
22
22
|
DBC.require(quality_of_recall >= 0)
|
23
23
|
DBC.require(quality_of_recall <= 5)
|
24
|
+
DBC.require(easiness_factor)
|
25
|
+
DBC.require(number_repetitions)
|
24
26
|
|
25
27
|
if quality_of_recall < 3
|
26
28
|
self.number_repetitions = 0
|
@@ -43,6 +45,10 @@ module SuperMemo
|
|
43
45
|
self.next_repetition = Date.today + repetition_interval
|
44
46
|
end
|
45
47
|
|
48
|
+
def scheduled_to_recall?
|
49
|
+
!next_repetition.nil? && next_repetition <= Date.today
|
50
|
+
end
|
51
|
+
|
46
52
|
def check_spaced_repetition_methods
|
47
53
|
begin
|
48
54
|
send(:easiness_factor)
|
@@ -53,7 +53,7 @@ describe SuperMemo::SM2 do
|
|
53
53
|
@flash_card.number_repetitions.should == 0
|
54
54
|
@flash_card.repetition_interval.should == nil
|
55
55
|
@flash_card.quality_of_last_recall.should == nil
|
56
|
-
@flash_card.next_repetition.should ==
|
56
|
+
@flash_card.next_repetition.should == nil
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'should schedule next repetition for tomorrow if repetition_interval = 0 and quality_of_last_recall = 4' do
|
@@ -75,6 +75,25 @@ describe SuperMemo::SM2 do
|
|
75
75
|
@flash_card.easiness_factor.should be_close(2.5, 0.01)
|
76
76
|
end
|
77
77
|
|
78
|
+
it 'should report as scheduled to recall (for today)' do
|
79
|
+
@flash_card.next_repetition = Date.today
|
80
|
+
@flash_card.scheduled_to_recall?.should == true
|
81
|
+
|
82
|
+
@flash_card.next_repetition = Date.today - 1
|
83
|
+
@flash_card.scheduled_to_recall?.should == true
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should not be scheduled to recall' do
|
87
|
+
@flash_card.next_repetition = nil
|
88
|
+
@flash_card.scheduled_to_recall?.should == false
|
89
|
+
|
90
|
+
@flash_card.next_repetition = Date.today + 1
|
91
|
+
@flash_card.scheduled_to_recall?.should == false
|
92
|
+
|
93
|
+
@flash_card.next_repetition = Date.today + 99
|
94
|
+
@flash_card.scheduled_to_recall?.should == false
|
95
|
+
end
|
96
|
+
|
78
97
|
end
|
79
98
|
|
80
99
|
|