mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
fix collapsing; make sure learning cards are put back on the heap
This commit is contained in:
parent
e53ae3f2b0
commit
3c40854583
2 changed files with 16 additions and 1 deletions
|
@ -214,7 +214,7 @@ limit %d""" % self.reportLimit, lim=self.dayCutoff)
|
||||||
if self.lrnQueue:
|
if self.lrnQueue:
|
||||||
cutoff = time.time()
|
cutoff = time.time()
|
||||||
if collapse:
|
if collapse:
|
||||||
cutoff -= self.deck.collapseTime
|
cutoff += self.deck.qconf['collapseTime']
|
||||||
if self.lrnQueue[0][0] < cutoff:
|
if self.lrnQueue[0][0] < cutoff:
|
||||||
id = heappop(self.lrnQueue)[1]
|
id = heappop(self.lrnQueue)[1]
|
||||||
self.lrnCount -= 1
|
self.lrnCount -= 1
|
||||||
|
@ -237,6 +237,7 @@ limit %d""" % self.reportLimit, lim=self.dayCutoff)
|
||||||
else:
|
else:
|
||||||
card.grade = 0
|
card.grade = 0
|
||||||
card.due = time.time() + self._delayForGrade(conf, card.grade)
|
card.due = time.time() + self._delayForGrade(conf, card.grade)
|
||||||
|
heappush(self.lrnQueue, (card.due, card.id))
|
||||||
self._logLrn(card, ease, conf, leaving)
|
self._logLrn(card, ease, conf, leaving)
|
||||||
|
|
||||||
def _delayForGrade(self, conf, grade):
|
def _delayForGrade(self, conf, grade):
|
||||||
|
|
|
@ -575,3 +575,17 @@ def test_timing():
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
assert c.queue == 1
|
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()
|
||||||
|
|
Loading…
Reference in a new issue