mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 00:12:25 -04:00
when suspending leeches, make sure we don't put the card back in the queue
This commit is contained in:
parent
4aedfd868b
commit
f3965f4c09
2 changed files with 12 additions and 3 deletions
|
@ -45,7 +45,7 @@ class Scheduler(object):
|
|||
self.deck.markReview(card)
|
||||
self.reps += 1
|
||||
card.reps += 1
|
||||
wasNew = card.queue == 0
|
||||
wasNew = (card.queue == 0) and card.type != 2
|
||||
if wasNew:
|
||||
# put it in the learn queue
|
||||
card.queue = 1
|
||||
|
@ -483,9 +483,9 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
|||
card.due = int(self._delayForGrade(conf, 0) + time.time())
|
||||
card.queue = 1
|
||||
self.lrnCount += 1
|
||||
heappush(self.lrnQueue, (card.due, card.id))
|
||||
# leech?
|
||||
self._checkLeech(card, conf)
|
||||
if not self._checkLeech(card, conf) and conf['relearn']:
|
||||
heappush(self.lrnQueue, (card.due, card.id))
|
||||
|
||||
def _nextLapseIvl(self, card, conf):
|
||||
return int(card.ivl*conf['mult']) + 1
|
||||
|
@ -586,6 +586,7 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
|||
card.queue = -1
|
||||
# notify UI
|
||||
runHook("leech", card)
|
||||
return True
|
||||
|
||||
# Tools
|
||||
##########################################################################
|
||||
|
|
|
@ -192,6 +192,8 @@ def test_reviews():
|
|||
cardcopy = copy.copy(c)
|
||||
# failing it should put it in the learn queue with the default options
|
||||
##################################################
|
||||
# different delay to new
|
||||
d.sched._cardConf(c)['lapse']['delays'] = [2, 20]
|
||||
d.sched.answerCard(c, 1)
|
||||
assert c.queue == 1
|
||||
# it should be due tomorrow, with an interval of 1
|
||||
|
@ -200,11 +202,16 @@ def test_reviews():
|
|||
# but because it's in the learn queue, its current due time should be in
|
||||
# the future
|
||||
assert c.due >= time.time()
|
||||
assert (c.due - time.time()) > 119
|
||||
# factor should have been decremented
|
||||
assert c.factor == 2300
|
||||
# check counters
|
||||
assert c.lapses == 2
|
||||
assert c.reps == 4
|
||||
# check ests.
|
||||
ni = d.sched.nextIvl
|
||||
assert ni(c, 1) == 120
|
||||
assert ni(c, 2) == 20*60
|
||||
# try again with an ease of 2 instead
|
||||
##################################################
|
||||
c = copy.copy(cardcopy)
|
||||
|
@ -581,6 +588,7 @@ def test_ordcycle():
|
|||
|
||||
def test_counts_up():
|
||||
d = getEmptyDeck()
|
||||
d.conf['counts'] = COUNT_ANSWERED
|
||||
# for each card type
|
||||
for type in range(3):
|
||||
# create a new fact
|
||||
|
|
Loading…
Reference in a new issue