mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
shuffle after importing when random on (#576)
This commit is contained in:
parent
2ac2619527
commit
403a53cebf
3 changed files with 13 additions and 2 deletions
|
@ -358,9 +358,10 @@ insert or ignore into revlog values (?,?,?,?,?,?,?,?,?)""", revlog)
|
|||
|
||||
# Post-import cleanup
|
||||
######################################################################
|
||||
# fixme: we could be handling new card order more elegantly on import
|
||||
|
||||
def _postImport(self):
|
||||
for did in self._decks.values():
|
||||
self.col.sched.maybeRandomizeDeck(did)
|
||||
# make sure new position is correct
|
||||
self.dst.conf['nextPos'] = self.dst.db.scalar(
|
||||
"select max(due)+1 from cards where type = 0") or 0
|
||||
|
|
|
@ -165,6 +165,7 @@ class NoteImporter(Importer):
|
|||
firsts[fld0] = True
|
||||
self.addNew(new)
|
||||
self.addUpdates(updates)
|
||||
# make sure to update sflds, etc
|
||||
self.col.updateFieldCache(self._ids)
|
||||
# generate cards
|
||||
if self.col.genCards(self._ids):
|
||||
|
@ -172,7 +173,7 @@ class NoteImporter(Importer):
|
|||
"Empty cards found. Please run Tools>Empty Cards."))
|
||||
# apply scheduling updates
|
||||
self.updateCards()
|
||||
# make sure to update sflds, etc
|
||||
self.col.sched.maybeRandomizeDeck()
|
||||
part1 = ngettext("%d note added", "%d notes added", len(new)) % len(new)
|
||||
part2 = ngettext("%d note updated", "%d notes updated", self.updateCount) % self.updateCount
|
||||
self.log.append("%s, %s." % (part1, part2))
|
||||
|
|
|
@ -1348,3 +1348,12 @@ and due >= ? and queue = 0""" % scids, now, self.col.usn(), shiftby, low)
|
|||
self.randomizeCards(did)
|
||||
else:
|
||||
self.orderCards(did)
|
||||
|
||||
# for post-import
|
||||
def maybeRandomizeDeck(self, did=None):
|
||||
if not did:
|
||||
did = self.col.decks.selected()
|
||||
conf = self.col.decks.confForDid(did)
|
||||
# in order due?
|
||||
if conf['new']['order'] == NEW_CARDS_RANDOM:
|
||||
self.col.sched.randomizeCards(did)
|
||||
|
|
Loading…
Reference in a new issue