diff --git a/anki/cram.py b/anki/cram.py index b24956121..8a9a78298 100644 --- a/anki/cram.py +++ b/anki/cram.py @@ -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: diff --git a/anki/sched.py b/anki/sched.py index 77e6c2a47..e8ea87f3a 100644 --- a/anki/sched.py +++ b/anki/sched.py @@ -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): diff --git a/tests/test_sched.py b/tests/test_sched.py index ff8c7dbc0..e6d35c292 100644 --- a/tests/test_sched.py +++ b/tests/test_sched.py @@ -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