make sure the failed card count reflects the cutoff

This commit is contained in:
Damien Elmes 2011-04-14 05:11:38 +09:00
parent 8b747c3aac
commit e8d6714130
3 changed files with 25 additions and 3 deletions

View file

@ -34,8 +34,6 @@ class CramScheduler(Scheduler):
if card.queue == 2:
card.queue = 1
card.edue = card.due
if ease < 3:
self.lrnCount += 1
if card.queue == 1:
self._answerLrnCard(card, ease)
else:

View file

@ -43,7 +43,6 @@ class Scheduler(object):
if card.queue == 0:
# put it in the learn queue
card.queue = 1
self.lrnCount += 1
if card.queue == 1:
self._answerLrnCard(card, ease)
elif card.queue == 2:
@ -309,6 +308,9 @@ limit %d""" % self.reportLimit, lim=self.dayCutoff)
delay *= random.uniform(1, 1.25)
card.due = time.time() + delay
heappush(self.lrnQueue, (card.due, card.id))
# if it's due within the cutoff, increment count
if delay <= self.deck.qconf['collapseTime']:
self.lrnCount += 1
self._logLrn(card, ease, conf, leaving, type)
def _delayForGrade(self, conf, grade):

View file

@ -549,6 +549,28 @@ def test_counts():
assert d.sched.selCounts() == (1,2,1)
assert d.sched.allCounts() == (2,2,2)
def test_counts2():
d = getEmptyDeck()
f = d.newFact()
f['Front'] = u"one"; f['Back'] = u"two"
d.addFact(f)
d.reset()
assert d.sched.counts() == (1, 0, 0)
c = d.sched.getCard()
# counter's been decremented but idx indicates 1
assert d.sched.counts() == (0, 0, 0)
assert d.sched.countIdx(c) == 0
# answer to move to learn queue
d.sched.answerCard(c, 1)
assert d.sched.counts() == (0, 1, 0)
# fetching again will decrement the count
c = d.sched.getCard()
assert d.sched.counts() == (0, 0, 0)
assert d.sched.countIdx(c) == 1
# answering should add it back again
d.sched.answerCard(c, 1)
assert d.sched.counts() == (0, 1, 0)
def test_timing():
d = getEmptyDeck()
# add a few review cards, due today