mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
more cram orderings, clear out before rebuild
This commit is contained in:
parent
81f2a5318f
commit
acd0316a14
3 changed files with 32 additions and 13 deletions
|
@ -29,6 +29,12 @@ MEDIA_REM = 1
|
|||
# dynamic deck order
|
||||
DYN_OLDEST = 0
|
||||
DYN_RANDOM = 1
|
||||
DYN_SMALLINT = 2
|
||||
DYN_BIGINT = 3
|
||||
DYN_LAPSES = 4
|
||||
DYN_FAILED = 5
|
||||
DYN_ADDED = 6
|
||||
DYN_DUE = 7
|
||||
|
||||
# deck schema & syncing vars
|
||||
SCHEMA_VERSION = 3
|
||||
|
@ -66,9 +72,14 @@ def alignmentLabels():
|
|||
2: _("Right"),
|
||||
}
|
||||
|
||||
# todo: expand
|
||||
def dynOrderLabels():
|
||||
return {
|
||||
0: _("Oldest seen first"),
|
||||
1: _("Random"),
|
||||
2: _("Increasing intervals"),
|
||||
3: _("Decreasing intervals"),
|
||||
4: _("Most lapses"),
|
||||
5: _("Failed today"),
|
||||
6: _("Order added"),
|
||||
7: _("Order due"),
|
||||
}
|
||||
|
|
|
@ -136,7 +136,6 @@ class DeckManager(object):
|
|||
if not str(did) in self.decks:
|
||||
return
|
||||
deck = self.get(did)
|
||||
print "fixme: add dyn to old decks"
|
||||
if deck['dyn']:
|
||||
# deleting a cramming deck returns cards to their previous deck
|
||||
# rather than deleting the cards
|
||||
|
|
|
@ -728,10 +728,15 @@ did = ? and queue = 2 and due <= ? limit ?""",
|
|||
did = did or self.col.decks.selected()
|
||||
deck = self.col.decks.get(did)
|
||||
assert deck['dyn']
|
||||
# move any existing cards back first
|
||||
self.remDyn(did)
|
||||
# gather card ids and sort
|
||||
order = self._dynOrder(deck)
|
||||
limit = " limit %d" % deck['limit']
|
||||
ids = self.col.findCards(deck['search'], order=order+limit)
|
||||
try:
|
||||
ids = self.col.findCards(deck['search'], order=order+limit)
|
||||
except:
|
||||
ids = []
|
||||
# move the cards over
|
||||
self._moveToDyn(did, ids)
|
||||
# and change to our new deck
|
||||
|
@ -748,16 +753,20 @@ usn = ?, mod = ? where did = ?""", self.col.usn(), intTime(), did)
|
|||
return "order by c.mod"
|
||||
elif o == DYN_RANDOM:
|
||||
return "order by random()"
|
||||
# elif o == "added":
|
||||
# return "order by n.id"
|
||||
# elif o == "random":
|
||||
# return ""
|
||||
# elif o == "relative":
|
||||
# pass
|
||||
# elif o == "lapses":
|
||||
# return "order by lapses desc"
|
||||
# elif o == "failed":
|
||||
# pass
|
||||
elif o == DYN_SMALLINT:
|
||||
return "order by ivl"
|
||||
elif o == DYN_BIGINT:
|
||||
return "order by ivl desc"
|
||||
elif o == DYN_LAPSES:
|
||||
return "order by lapses desc"
|
||||
elif o == DYN_FAILED:
|
||||
return """
|
||||
and c.id in (select cid from revlog where ease = 1 and time > %d)
|
||||
order by c.mod""" % ((self.dayCutoff-86400)*1000)
|
||||
elif o == DYN_ADDED:
|
||||
return "order by n.id"
|
||||
elif o == DYN_DUE:
|
||||
return "order by c.due"
|
||||
|
||||
def _moveToDyn(self, did, ids):
|
||||
deck = self.col.decks.get(did)
|
||||
|
|
Loading…
Reference in a new issue