mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
new review early handling so that we can recover on load
This commit is contained in:
parent
c89d75b01c
commit
33c59a3006
1 changed files with 10 additions and 8 deletions
18
anki/deck.py
18
anki/deck.py
|
@ -132,7 +132,6 @@ class Deck(object):
|
||||||
self.sessionStartReps = 0
|
self.sessionStartReps = 0
|
||||||
self.sessionStartTime = 0
|
self.sessionStartTime = 0
|
||||||
self.lastSessionStart = 0
|
self.lastSessionStart = 0
|
||||||
self.reviewedAheadCards = []
|
|
||||||
self.extraNewCards = 0
|
self.extraNewCards = 0
|
||||||
self.reviewEarly = False
|
self.reviewEarly = False
|
||||||
|
|
||||||
|
@ -392,8 +391,7 @@ where id != :id and factId = :factId""",
|
||||||
# temp suspend if learning ahead
|
# temp suspend if learning ahead
|
||||||
if self.reviewEarly and lastDelay < 0:
|
if self.reviewEarly and lastDelay < 0:
|
||||||
if oldSuc or lastDelaySecs > self.delay0 or not self._showFailedLast():
|
if oldSuc or lastDelaySecs > self.delay0 or not self._showFailedLast():
|
||||||
card.priority = 0
|
card.priority = -1
|
||||||
self.reviewedAheadCards.append(card.id)
|
|
||||||
# card stats
|
# card stats
|
||||||
anki.cards.Card.updateStats(card, ease, oldState)
|
anki.cards.Card.updateStats(card, ease, oldState)
|
||||||
card.toDB(self.s)
|
card.toDB(self.s)
|
||||||
|
@ -661,9 +659,9 @@ type = 0 and isDue = 1 and combinedDue <= :now""", now=time.time())
|
||||||
self._dailyStats = dailyStats(self)
|
self._dailyStats = dailyStats(self)
|
||||||
|
|
||||||
def resetAfterReviewEarly(self):
|
def resetAfterReviewEarly(self):
|
||||||
if self.reviewedAheadCards:
|
ids = self.s.column0("select id from cards where priority = -1")
|
||||||
self.updatePriorities(self.reviewedAheadCards)
|
if ids:
|
||||||
self.reviewedAheadCards = []
|
self.updatePriorities(ids)
|
||||||
self.reviewEarly = False
|
self.reviewEarly = False
|
||||||
self.flushMod()
|
self.flushMod()
|
||||||
self.checkDue()
|
self.checkDue()
|
||||||
|
@ -2560,12 +2558,16 @@ class DeckStorage(object):
|
||||||
deck.currentModel = deck.models[0]
|
deck.currentModel = deck.models[0]
|
||||||
# ensure the necessary indices are available
|
# ensure the necessary indices are available
|
||||||
deck.updateDynamicIndices()
|
deck.updateDynamicIndices()
|
||||||
# check counts
|
# save counts to determine if we should save deck after check
|
||||||
oldc = deck.failedSoonCount + deck.revCount + deck.newCount
|
oldc = deck.failedSoonCount + deck.revCount + deck.newCount
|
||||||
|
# update counts & unsuspend reviewed early cards
|
||||||
deck.rebuildQueue()
|
deck.rebuildQueue()
|
||||||
|
deck.resetAfterReviewEarly()
|
||||||
if ((oldc != deck.failedSoonCount + deck.revCount + deck.newCount) or
|
if ((oldc != deck.failedSoonCount + deck.revCount + deck.newCount) or
|
||||||
deck.modifiedSinceSave()):
|
deck.modifiedSinceSave()):
|
||||||
# save
|
# we don't want the deck marked as modified, but we don't want to
|
||||||
|
# bump the mod time either
|
||||||
|
deck.modified = deck.lastLoaded
|
||||||
deck.s.commit()
|
deck.s.commit()
|
||||||
return deck
|
return deck
|
||||||
Deck = staticmethod(Deck)
|
Deck = staticmethod(Deck)
|
||||||
|
|
Loading…
Reference in a new issue