diff --git a/anki/sched.py b/anki/sched.py index eda3f74a9..30cf3deee 100644 --- a/anki/sched.py +++ b/anki/sched.py @@ -214,7 +214,7 @@ limit %d""" % self.reportLimit, lim=self.dayCutoff) if self.lrnQueue: cutoff = time.time() if collapse: - cutoff -= self.deck.collapseTime + cutoff += self.deck.qconf['collapseTime'] if self.lrnQueue[0][0] < cutoff: id = heappop(self.lrnQueue)[1] self.lrnCount -= 1 @@ -237,6 +237,7 @@ limit %d""" % self.reportLimit, lim=self.dayCutoff) else: card.grade = 0 card.due = time.time() + self._delayForGrade(conf, card.grade) + heappush(self.lrnQueue, (card.due, card.id)) self._logLrn(card, ease, conf, leaving) def _delayForGrade(self, conf, grade): diff --git a/tests/test_sched.py b/tests/test_sched.py index 7c2e79f1d..3f5d890dd 100644 --- a/tests/test_sched.py +++ b/tests/test_sched.py @@ -575,3 +575,17 @@ def test_timing(): time.sleep(1) c = d.sched.getCard() assert c.queue == 1 + +def test_collapse(): + d = getEmptyDeck() + # add a fact + f = d.newFact() + f['Front'] = u"one" + d.addFact(f) + d.reset() + # test collapsing + c = d.sched.getCard() + d.sched.answerCard(c, 1) + c = d.sched.getCard() + d.sched.answerCard(c, 3) + assert not d.sched.getCard()