mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
remove cards from cram decks and the relearning queue on suspend
This commit is contained in:
parent
3ab91c600b
commit
55812bef86
2 changed files with 25 additions and 2 deletions
|
@ -747,10 +747,15 @@ did = ? and queue = 2 and due <= ? limit ?""",
|
|||
# and change to our new deck
|
||||
self.col.decks.select(did)
|
||||
|
||||
def remDyn(self, did):
|
||||
def remDyn(self, did, lim=None):
|
||||
if not lim:
|
||||
lim = "did = %d" % did
|
||||
self.col.db.execute("""
|
||||
update cards set did = odid, queue = type, due = odue, odue = 0, odid = 0,
|
||||
usn = ?, mod = ? where did = ?""", self.col.usn(), intTime(), did)
|
||||
usn = ?, mod = ? where %s""" % lim, self.col.usn(), intTime())
|
||||
|
||||
def remFromDyn(self, cids):
|
||||
self.remDyn(None, "id in %s and odid" % ids2str(cids))
|
||||
|
||||
def _dynOrder(self, deck):
|
||||
o = deck['order']
|
||||
|
@ -994,6 +999,8 @@ your short-term review workload will become."""))
|
|||
|
||||
def suspendCards(self, ids):
|
||||
"Suspend cards."
|
||||
self.remFromDyn(ids)
|
||||
self.removeFailed(ids)
|
||||
self.col.db.execute(
|
||||
"update cards set queue=-1,mod=?,usn=? where id in "+
|
||||
ids2str(ids), intTime(), self.col.usn())
|
||||
|
@ -1008,6 +1015,9 @@ your short-term review workload will become."""))
|
|||
def buryNote(self, nid):
|
||||
"Bury all cards for note until next session."
|
||||
self.col.setDirty()
|
||||
cids = self.col.db.list("select id from cards where nid = ?", nid)
|
||||
self.remFromDyn(cids)
|
||||
self.removeFailed(cids)
|
||||
self.col.db.execute("update cards set queue = -2 where nid = ?", nid)
|
||||
|
||||
# Resetting
|
||||
|
|
|
@ -450,6 +450,19 @@ def test_suspend():
|
|||
c.load()
|
||||
assert c.queue == 2
|
||||
assert c.type == 2
|
||||
assert c.due == 1
|
||||
# should cope with cards in cram decks
|
||||
c.due = 0
|
||||
c.flush()
|
||||
cram = d.decks.newDyn("tmp")
|
||||
d.sched.rebuildDyn()
|
||||
c.load()
|
||||
assert c.due != 1
|
||||
assert c.did != 1
|
||||
d.sched.suspendCards([c.id])
|
||||
c.load()
|
||||
assert c.due == 1
|
||||
assert c.did == 1
|
||||
|
||||
def test_cram():
|
||||
d = getEmptyDeck()
|
||||
|
|
Loading…
Reference in a new issue