when cram deck removed, cards in learning need to be reset

This commit is contained in:
Damien Elmes 2012-05-06 01:55:18 +09:00
parent c2370fe3ef
commit 0e2637a999
2 changed files with 25 additions and 2 deletions

View file

@ -770,9 +770,12 @@ did = ? and queue = 2 and due <= ? limit ?""",
def remDyn(self, did, lim=None):
if not lim:
lim = "did = %s" % did
# move out of cram queue
self.col.db.execute("""
update cards set did = odid, queue = type, due = odue, odue = 0, odid = 0,
usn = ?, mod = ? where %s""" % lim, self.col.usn(), intTime())
update cards set did = odid, queue = (case when type = 1 then 0
else type end), type = (case when type = 1 then 0 else type end),
due = odue, odue = 0, odid = 0, usn = ?, mod = ? where %s""" % lim,
self.col.usn(), intTime())
def remFromDyn(self, cids):
self.remDyn(None, "id in %s and odid" % ids2str(cids))

View file

@ -577,6 +577,26 @@ def test_cram():
# it should have been moved back to the original deck
assert c.did == 1
def test_cram_rem():
d = getEmptyDeck()
f = d.newNote()
f['Front'] = u"one"
d.addNote(f)
oldDue = f.cards()[0].due
did = d.decks.newDyn("Cram")
d.sched.rebuildDyn(did)
d.reset()
c = d.sched.getCard()
d.sched.answerCard(c, 2)
# answering the card will put it in the learning queue
assert c.type == c.queue == 1
assert c.due != oldDue
# if we terminate cramming prematurely it should be set back to new
d.sched.remDyn(did)
c.load()
assert c.type == c.queue == 0
assert c.due == oldDue
def test_adjIvl():
d = getEmptyDeck()
# add two more templates and set second active