fix no relearn steps case in v2 sched

This commit is contained in:
Damien Elmes 2018-02-02 14:30:53 +10:00
parent ebe420b440
commit 0b42787ffc
2 changed files with 34 additions and 10 deletions

View File

@ -551,20 +551,16 @@ did = ? and queue = 3 and due <= ? limit ?""",
self._logLrn(card, ease, conf, leaving, type, lastLeft)
def _updateRevIvlOnFail(self, card, conf):
card.lastIvl = card.ivl
card.ivl = self._lapseIvl(card, conf)
def _moveToFirstStep(self, card, conf):
card.left = self._startingLeft(card)
card.lastIvl = card.ivl
# relearning card?
if card.type in (2,3):
card.ivl = self._lapseIvl(card, self._lrnConf(card))
# moving from review queue?
if card.type == 2:
card.type = 3
card.lapses += 1
card.factor = max(1300, card.factor-200)
if card.type == 3:
self._updateRevIvlOnFail(card, conf)
return self._rescheduleLrnCard(card, conf)
@ -831,11 +827,18 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)"""
def _rescheduleLapse(self, card):
conf = self._lapseConf(card)
card.lapses += 1
card.factor = max(1300, card.factor-200)
if conf['delays']:
card.type = 3
delay = self._moveToFirstStep(card, conf)
else:
# no relearning steps
self._updateRevIvlOnFail(card, conf)
self._rescheduleAsRev(card, conf, early=False)
delay = 0
# if suspended as a leech, nothing to do
if self._checkLeech(card, conf) and card.queue == -1:

View File

@ -194,6 +194,27 @@ def test_relearn():
assert c.ivl == 1
assert c.due == d.sched.today + c.ivl
def test_relearn_no_steps():
d = getEmptyCol()
f = d.newNote()
f['Front'] = "one"
d.addNote(f)
c = f.cards()[0]
c.ivl = 100
c.due = d.sched.today
c.type = c.queue = 2
c.flush()
conf = d.decks.confForDid(1)
conf['lapse']['delays'] = []
d.decks.save(conf)
# fail the card
d.reset()
c = d.sched.getCard()
d.sched.answerCard(c, 1)
assert c.type == c.queue == 2
def test_learn_collapsed():
d = getEmptyCol()
# add 2 notes