fix interval calculation for lapsed cards in learning queue

This commit is contained in:
Damien Elmes 2011-03-23 10:17:39 +09:00
parent 4d0e4836fe
commit e407697fb9
2 changed files with 12 additions and 1 deletions

View file

@ -245,6 +245,9 @@ limit %d""" % self.reportLimit, lim=self.dayCutoff)
card.type = 2 card.type = 2
def _graduatingIvl(self, card, conf, early): def _graduatingIvl(self, card, conf, early):
if card.type == 2:
# lapsed card being relearnt
return card.ivl
if not early: if not early:
# graduate # graduate
ideal = conf['ints'][0] ideal = conf['ints'][0]
@ -557,7 +560,6 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
def nextIvl(self, card, ease): def nextIvl(self, card, ease):
"Return the next interval for CARD, in seconds." "Return the next interval for CARD, in seconds."
if card.queue in (0,1): if card.queue in (0,1):
# in learning
return self._nextLrnIvl(card, ease) return self._nextLrnIvl(card, ease)
elif ease == 1: elif ease == 1:
# lapsed # lapsed

View file

@ -256,6 +256,14 @@ def test_nextIvl():
# normal graduation is tomorrow # normal graduation is tomorrow
assert ni(c, 2) == 1*86400 assert ni(c, 2) == 1*86400
assert ni(c, 3) == 4*86400 assert ni(c, 3) == 4*86400
# lapsed cards
##################################################
c.type = 2
c.ivl = 100
c.factor = 2500
assert ni(c, 1) == 30
assert ni(c, 2) == 100*86400
assert ni(c, 3) == 100*86400
# review cards # review cards
################################################## ##################################################
c.queue = 2 c.queue = 2
@ -356,6 +364,7 @@ def test_cram():
d.sched.answerCard(c, 1) d.sched.answerCard(c, 1)
# graduating the card will keep the same interval, but shift the card # graduating the card will keep the same interval, but shift the card
# forward the number of days it had been waiting (75) # forward the number of days it had been waiting (75)
print d.sched.nextIvl(c, 3)
assert d.sched.nextIvl(c, 3) == 75*86400 assert d.sched.nextIvl(c, 3) == 75*86400
d.sched.answerCard(c, 3) d.sched.answerCard(c, 3)
assert c.ivl == 100 assert c.ivl == 100