mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
make sure we reset odue when rescheduling as new
if we fail to do this for a relearning card, it sticks around until it causes problems later
This commit is contained in:
parent
4bf63b6ad0
commit
ae8074ec01
4 changed files with 20 additions and 13 deletions
|
@ -4,19 +4,10 @@
|
|||
import pprint
|
||||
|
||||
import time
|
||||
from anki.hooks import runHook
|
||||
from anki.utils import intTime, timestampID, joinFields
|
||||
from anki.consts import *
|
||||
|
||||
# temporary
|
||||
_warned = False
|
||||
def warn():
|
||||
global _warned
|
||||
if _warned:
|
||||
return
|
||||
import sys
|
||||
sys.stderr.write("Ignore the above, please download the fix assertion addon.")
|
||||
_warned = True
|
||||
|
||||
# Cards
|
||||
##########################################################################
|
||||
|
||||
|
@ -83,7 +74,7 @@ class Card(object):
|
|||
self.usn = self.col.usn()
|
||||
# bug check
|
||||
if self.queue == 2 and self.odue and not self.col.decks.isDyn(self.did):
|
||||
warn()
|
||||
runHook("odueInvalid")
|
||||
assert self.due < 4294967296
|
||||
self.col.db.execute(
|
||||
"""
|
||||
|
@ -114,7 +105,7 @@ insert or replace into cards values
|
|||
self.usn = self.col.usn()
|
||||
# bug checks
|
||||
if self.queue == 2 and self.odue and not self.col.decks.isDyn(self.did):
|
||||
warn()
|
||||
runHook("odueInvalid")
|
||||
assert self.due < 4294967296
|
||||
self.col.db.execute(
|
||||
"""update cards set
|
||||
|
|
|
@ -741,6 +741,16 @@ select id from cards where nid not in (select id from notes)""")
|
|||
ngettext("Deleted %d card with missing note.",
|
||||
"Deleted %d cards with missing note.", cnt) % cnt)
|
||||
self.remCards(ids)
|
||||
# cards with odue set when it shouldn't be
|
||||
ids = self.db.list("""
|
||||
select id from cards where odue > 0 and (type=1 or queue=2) and not odid""")
|
||||
if ids:
|
||||
cnt = len(ids)
|
||||
problems.append(
|
||||
ngettext("Fixed %d card with invalid properties.",
|
||||
"Fixed %d cards with invalid properties.", cnt) % cnt)
|
||||
self.db.execute("update cards set odue=0 where id in "+
|
||||
ids2str(ids))
|
||||
# tags
|
||||
self.tags.registerNotes()
|
||||
# field cache
|
||||
|
|
|
@ -1334,7 +1334,7 @@ and (queue=0 or (queue=2 and due<=?))""",
|
|||
def forgetCards(self, ids):
|
||||
"Put cards at the end of the new queue."
|
||||
self.col.db.execute(
|
||||
"update cards set type=0,queue=0,ivl=0,due=0,factor=? where odid=0 "
|
||||
"update cards set type=0,queue=0,ivl=0,due=0,odue=0,factor=? where odid=0 "
|
||||
"and queue >= 0 and id in "+ids2str(ids), 2500)
|
||||
pmax = self.col.db.scalar(
|
||||
"select max(due) from cards where type=0") or 0
|
||||
|
|
|
@ -863,6 +863,12 @@ Difference to correct time: %s.""") % diffText
|
|||
def setupHooks(self):
|
||||
addHook("modSchema", self.onSchemaMod)
|
||||
addHook("remNotes", self.onRemNotes)
|
||||
addHook("odueInvalid", self.onOdueInvalid)
|
||||
|
||||
def onOdueInvalid(self):
|
||||
showWarning(_("""\
|
||||
Invalid property found on card. Please use Tools>Check Database, \
|
||||
and if the problem comes up again, please ask on the support site."""))
|
||||
|
||||
# Log note deletion
|
||||
##########################################################################
|
||||
|
|
Loading…
Reference in a new issue