mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -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.deck.markReview(card)
|
||||||
self.reps += 1
|
self.reps += 1
|
||||||
card.reps += 1
|
card.reps += 1
|
||||||
wasNew = card.queue == 0
|
wasNew = (card.queue == 0) and card.type != 2
|
||||||
if wasNew:
|
if wasNew:
|
||||||
# put it in the learn queue
|
# put it in the learn queue
|
||||||
card.queue = 1
|
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.due = int(self._delayForGrade(conf, 0) + time.time())
|
||||||
card.queue = 1
|
card.queue = 1
|
||||||
self.lrnCount += 1
|
self.lrnCount += 1
|
||||||
heappush(self.lrnQueue, (card.due, card.id))
|
|
||||||
# leech?
|
# 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):
|
def _nextLapseIvl(self, card, conf):
|
||||||
return int(card.ivl*conf['mult']) + 1
|
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
|
card.queue = -1
|
||||||
# notify UI
|
# notify UI
|
||||||
runHook("leech", card)
|
runHook("leech", card)
|
||||||
|
return True
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
@ -192,6 +192,8 @@ def test_reviews():
|
||||||
cardcopy = copy.copy(c)
|
cardcopy = copy.copy(c)
|
||||||
# failing it should put it in the learn queue with the default options
|
# 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)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.queue == 1
|
assert c.queue == 1
|
||||||
# it should be due tomorrow, with an interval of 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
|
# but because it's in the learn queue, its current due time should be in
|
||||||
# the future
|
# the future
|
||||||
assert c.due >= time.time()
|
assert c.due >= time.time()
|
||||||
|
assert (c.due - time.time()) > 119
|
||||||
# factor should have been decremented
|
# factor should have been decremented
|
||||||
assert c.factor == 2300
|
assert c.factor == 2300
|
||||||
# check counters
|
# check counters
|
||||||
assert c.lapses == 2
|
assert c.lapses == 2
|
||||||
assert c.reps == 4
|
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
|
# try again with an ease of 2 instead
|
||||||
##################################################
|
##################################################
|
||||||
c = copy.copy(cardcopy)
|
c = copy.copy(cardcopy)
|
||||||
|
@ -581,6 +588,7 @@ def test_ordcycle():
|
||||||
|
|
||||||
def test_counts_up():
|
def test_counts_up():
|
||||||
d = getEmptyDeck()
|
d = getEmptyDeck()
|
||||||
|
d.conf['counts'] = COUNT_ANSWERED
|
||||||
# for each card type
|
# for each card type
|
||||||
for type in range(3):
|
for type in range(3):
|
||||||
# create a new fact
|
# create a new fact
|
||||||
|
|
Loading…
Reference in a new issue