mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
when rescheduling off, graduating cards get reset to new
This commit is contained in:
parent
d88c307758
commit
455796f189
2 changed files with 40 additions and 3 deletions
|
@ -62,7 +62,7 @@ class Scheduler(object):
|
||||||
card.left = self._startingLeft(card)
|
card.left = self._startingLeft(card)
|
||||||
# dynamic?
|
# dynamic?
|
||||||
if card.odid and card.type == 2:
|
if card.odid and card.type == 2:
|
||||||
if self._cardConf(card)['resched']:
|
if self._resched(card):
|
||||||
# reviews get their ivl boosted on first sight
|
# reviews get their ivl boosted on first sight
|
||||||
card.ivl = self._dynIvlBoost(card)
|
card.ivl = self._dynIvlBoost(card)
|
||||||
card.odue = self.today + card.ivl
|
card.odue = self.today + card.ivl
|
||||||
|
@ -560,10 +560,15 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
||||||
card.queue = 2
|
card.queue = 2
|
||||||
card.type = 2
|
card.type = 2
|
||||||
# if we were dynamic, graduating means moving back to the old deck
|
# if we were dynamic, graduating means moving back to the old deck
|
||||||
|
resched = self._resched(card)
|
||||||
if card.odid:
|
if card.odid:
|
||||||
card.did = card.odid
|
card.did = card.odid
|
||||||
card.odue = 0
|
card.odue = 0
|
||||||
card.odid = 0
|
card.odid = 0
|
||||||
|
# if rescheduling is off, it needs to be set back to a new card
|
||||||
|
if not resched:
|
||||||
|
card.queue = card.type = 0
|
||||||
|
card.due = self.col.nextID("pos")
|
||||||
|
|
||||||
def _startingLeft(self, card):
|
def _startingLeft(self, card):
|
||||||
conf = self._lrnConf(card)
|
conf = self._lrnConf(card)
|
||||||
|
@ -1017,6 +1022,12 @@ did = ?, queue = %s, due = ?, mod = ?, usn = ? where id = ?""" % queue, data)
|
||||||
def _deckLimit(self):
|
def _deckLimit(self):
|
||||||
return ids2str(self.col.decks.active())
|
return ids2str(self.col.decks.active())
|
||||||
|
|
||||||
|
def _resched(self, card):
|
||||||
|
conf = self._cardConf(card)
|
||||||
|
if not conf['dyn']:
|
||||||
|
return True
|
||||||
|
return conf['resched']
|
||||||
|
|
||||||
# Daily cutoff
|
# Daily cutoff
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
@ -1081,8 +1092,10 @@ your short-term review workload will become."""))
|
||||||
|
|
||||||
def nextIvlStr(self, card, ease, short=False):
|
def nextIvlStr(self, card, ease, short=False):
|
||||||
"Return the next interval for CARD as a string."
|
"Return the next interval for CARD as a string."
|
||||||
return fmtTimeSpan(
|
ivl = self.nextIvl(card, ease)
|
||||||
self.nextIvl(card, ease), short=short)
|
if not ivl:
|
||||||
|
return ""
|
||||||
|
return fmtTimeSpan(ivl, short=short)
|
||||||
|
|
||||||
def nextIvl(self, card, ease):
|
def nextIvl(self, card, ease):
|
||||||
"Return the next interval for CARD, in seconds."
|
"Return the next interval for CARD, in seconds."
|
||||||
|
@ -1108,6 +1121,8 @@ your short-term review workload will become."""))
|
||||||
return self._delayForGrade(conf, len(conf['delays']))
|
return self._delayForGrade(conf, len(conf['delays']))
|
||||||
elif ease == 3:
|
elif ease == 3:
|
||||||
# early removal
|
# early removal
|
||||||
|
if not self._resched(card):
|
||||||
|
return 0
|
||||||
return self._graduatingIvl(card, conf, True, adj=False) * 86400
|
return self._graduatingIvl(card, conf, True, adj=False) * 86400
|
||||||
else:
|
else:
|
||||||
left = card.left%1000 - 1
|
left = card.left%1000 - 1
|
||||||
|
|
|
@ -629,6 +629,28 @@ def test_cram_rem():
|
||||||
assert c.type == c.queue == 0
|
assert c.type == c.queue == 0
|
||||||
assert c.due == oldDue
|
assert c.due == oldDue
|
||||||
|
|
||||||
|
def test_cram_resched():
|
||||||
|
# add card
|
||||||
|
d = getEmptyDeck()
|
||||||
|
f = d.newNote()
|
||||||
|
f['Front'] = u"one"
|
||||||
|
d.addNote(f)
|
||||||
|
# cram deck
|
||||||
|
did = d.decks.newDyn("Cram")
|
||||||
|
cram = d.decks.get(did)
|
||||||
|
cram['resched'] = False
|
||||||
|
d.sched.rebuildDyn(did)
|
||||||
|
d.reset()
|
||||||
|
# graduate should return it to new
|
||||||
|
c = d.sched.getCard()
|
||||||
|
ni = d.sched.nextIvl
|
||||||
|
assert ni(c, 1) == 60
|
||||||
|
assert ni(c, 2) == 600
|
||||||
|
assert ni(c, 3) == 0
|
||||||
|
assert d.sched.nextIvlStr(c, 3) == ""
|
||||||
|
d.sched.answerCard(c, 3)
|
||||||
|
assert c.queue == c.type == 0
|
||||||
|
|
||||||
def test_adjIvl():
|
def test_adjIvl():
|
||||||
d = getEmptyDeck()
|
d = getEmptyDeck()
|
||||||
# add two more templates and set second active
|
# add two more templates and set second active
|
||||||
|
|
Loading…
Reference in a new issue