QUEUE_TYPE_REV and CARD_TYPE_REV
This commit is contained in:
parent
7d4506afdb
commit
45bf763238
@ -88,7 +88,7 @@ class Card:
|
|||||||
self.mod = intTime()
|
self.mod = intTime()
|
||||||
self.usn = self.col.usn()
|
self.usn = self.col.usn()
|
||||||
# bug check
|
# bug check
|
||||||
if self.queue == 2 and self.odue and not self.col.decks.isDyn(self.did):
|
if self.queue == QUEUE_TYPE_REV and self.odue and not self.col.decks.isDyn(self.did):
|
||||||
hooks.card_odue_was_invalid()
|
hooks.card_odue_was_invalid()
|
||||||
assert self.due < 4294967296
|
assert self.due < 4294967296
|
||||||
self.col.db.execute(
|
self.col.db.execute(
|
||||||
@ -120,7 +120,7 @@ insert or replace into cards values
|
|||||||
self.mod = intTime()
|
self.mod = intTime()
|
||||||
self.usn = self.col.usn()
|
self.usn = self.col.usn()
|
||||||
# bug checks
|
# bug checks
|
||||||
if self.queue == 2 and self.odue and not self.col.decks.isDyn(self.did):
|
if self.queue == QUEUE_TYPE_REV and self.odue and not self.col.decks.isDyn(self.did):
|
||||||
hooks.card_odue_was_invalid()
|
hooks.card_odue_was_invalid()
|
||||||
assert self.due < 4294967296
|
assert self.due < 4294967296
|
||||||
self.col.db.execute(
|
self.col.db.execute(
|
||||||
|
@ -20,10 +20,12 @@ QUEUE_TYPE_SIBLING_BURIED = -2
|
|||||||
QUEUE_TYPE_SUSPENDED = -1
|
QUEUE_TYPE_SUSPENDED = -1
|
||||||
QUEUE_TYPE_NEW = 0
|
QUEUE_TYPE_NEW = 0
|
||||||
QUEUE_TYPE_LRN = 1
|
QUEUE_TYPE_LRN = 1
|
||||||
|
QUEUE_TYPE_REV = 2
|
||||||
|
|
||||||
# Card types
|
# Card types
|
||||||
CARD_TYPE_NEW = 0
|
CARD_TYPE_NEW = 0
|
||||||
CARD_TYPE_LRN = 1
|
CARD_TYPE_LRN = 1
|
||||||
|
CARD_TYPE_REV = 2
|
||||||
|
|
||||||
# removal types
|
# removal types
|
||||||
REM_CARD = 0
|
REM_CARD = 0
|
||||||
|
@ -281,7 +281,7 @@ select distinct(n.id) from cards c, notes n where c.nid=n.id and """
|
|||||||
return f"c.queue in ({QUEUE_TYPE_SIBLING_BURIED}, {QUEUE_TYPE_MANUALLY_BURIED})"
|
return f"c.queue in ({QUEUE_TYPE_SIBLING_BURIED}, {QUEUE_TYPE_MANUALLY_BURIED})"
|
||||||
elif val == "due":
|
elif val == "due":
|
||||||
return f"""
|
return f"""
|
||||||
(c.queue in (2,3) and c.due <= %d) or
|
(c.queue in ({QUEUE_TYPE_REV},3) and c.due <= %d) or
|
||||||
(c.queue = {QUEUE_TYPE_LRN} and c.due <= %d)""" % (
|
(c.queue = {QUEUE_TYPE_LRN} and c.due <= %d)""" % (
|
||||||
self.col.sched.today,
|
self.col.sched.today,
|
||||||
self.col.sched.dayCutoff,
|
self.col.sched.dayCutoff,
|
||||||
@ -349,7 +349,7 @@ select distinct(n.id) from cards c, notes n where c.nid=n.id and """
|
|||||||
if prop == "due":
|
if prop == "due":
|
||||||
val += self.col.sched.today
|
val += self.col.sched.today
|
||||||
# only valid for review/daily learning
|
# only valid for review/daily learning
|
||||||
q.append("(c.queue in (2,3))")
|
q.append(f"(c.queue in ({QUEUE_TYPE_REV},3))")
|
||||||
elif prop == "ease":
|
elif prop == "ease":
|
||||||
prop = "factor"
|
prop = "factor"
|
||||||
val = int(val * 1000)
|
val = int(val * 1000)
|
||||||
|
@ -344,7 +344,7 @@ class Anki2Importer(Importer):
|
|||||||
card[4] = intTime()
|
card[4] = intTime()
|
||||||
card[5] = usn
|
card[5] = usn
|
||||||
# review cards have a due date relative to collection
|
# review cards have a due date relative to collection
|
||||||
if card[7] in (2, 3) or card[6] == 2:
|
if card[7] in (QUEUE_TYPE_REV, 3) or card[6] == CARD_TYPE_REV:
|
||||||
card[8] -= aheadBy
|
card[8] -= aheadBy
|
||||||
# odue needs updating too
|
# odue needs updating too
|
||||||
if card[14]:
|
if card[14]:
|
||||||
|
@ -78,7 +78,7 @@ class Scheduler:
|
|||||||
# init reps to graduation
|
# init reps to graduation
|
||||||
card.left = self._startingLeft(card)
|
card.left = self._startingLeft(card)
|
||||||
# dynamic?
|
# dynamic?
|
||||||
if card.odid and card.type == 2:
|
if card.odid and card.type == CARD_TYPE_REV:
|
||||||
if self._resched(card):
|
if self._resched(card):
|
||||||
# reviews get their ivl boosted on first sight
|
# reviews get their ivl boosted on first sight
|
||||||
card.ivl = self._dynIvlBoost(card)
|
card.ivl = self._dynIvlBoost(card)
|
||||||
@ -88,7 +88,7 @@ class Scheduler:
|
|||||||
self._answerLrnCard(card, ease)
|
self._answerLrnCard(card, ease)
|
||||||
if not wasNewQ:
|
if not wasNewQ:
|
||||||
self._updateStats(card, "lrn")
|
self._updateStats(card, "lrn")
|
||||||
elif card.queue == 2:
|
elif card.queue == QUEUE_TYPE_REV:
|
||||||
self._answerRevCard(card, ease)
|
self._answerRevCard(card, ease)
|
||||||
self._updateStats(card, "rev")
|
self._updateStats(card, "rev")
|
||||||
else:
|
else:
|
||||||
@ -112,9 +112,9 @@ class Scheduler:
|
|||||||
"Return counts over next DAYS. Includes today."
|
"Return counts over next DAYS. Includes today."
|
||||||
daysd = dict(
|
daysd = dict(
|
||||||
self.col.db.all(
|
self.col.db.all(
|
||||||
"""
|
f"""
|
||||||
select due, count() from cards
|
select due, count() from cards
|
||||||
where did in %s and queue = 2
|
where did in %s and queue = {QUEUE_TYPE_REV}
|
||||||
and due between ? and ?
|
and due between ? and ?
|
||||||
group by due
|
group by due
|
||||||
order by due"""
|
order by due"""
|
||||||
@ -139,13 +139,13 @@ order by due"""
|
|||||||
def answerButtons(self, card):
|
def answerButtons(self, card):
|
||||||
if card.odue:
|
if card.odue:
|
||||||
# normal review in dyn deck?
|
# normal review in dyn deck?
|
||||||
if card.odid and card.queue == 2:
|
if card.odid and card.queue == QUEUE_TYPE_REV:
|
||||||
return 4
|
return 4
|
||||||
conf = self._lrnConf(card)
|
conf = self._lrnConf(card)
|
||||||
if card.type in (CARD_TYPE_NEW, CARD_TYPE_LRN) or len(conf["delays"]) > 1:
|
if card.type in (CARD_TYPE_NEW, CARD_TYPE_LRN) or len(conf["delays"]) > 1:
|
||||||
return 3
|
return 3
|
||||||
return 2
|
return 2
|
||||||
elif card.queue == 2:
|
elif card.queue == QUEUE_TYPE_REV:
|
||||||
return 4
|
return 4
|
||||||
else:
|
else:
|
||||||
return 3
|
return 3
|
||||||
@ -557,7 +557,7 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
|||||||
conf = self._lrnConf(card)
|
conf = self._lrnConf(card)
|
||||||
if card.odid and not card.wasNew:
|
if card.odid and not card.wasNew:
|
||||||
type = REVLOG_CRAM
|
type = REVLOG_CRAM
|
||||||
elif card.type == 2:
|
elif card.type == CARD_TYPE_REV:
|
||||||
type = REVLOG_RELRN
|
type = REVLOG_RELRN
|
||||||
else:
|
else:
|
||||||
type = REVLOG_LRN
|
type = REVLOG_LRN
|
||||||
@ -627,13 +627,13 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
|||||||
return delay * 60
|
return delay * 60
|
||||||
|
|
||||||
def _lrnConf(self, card):
|
def _lrnConf(self, card):
|
||||||
if card.type == 2:
|
if card.type == CARD_TYPE_REV:
|
||||||
return self._lapseConf(card)
|
return self._lapseConf(card)
|
||||||
else:
|
else:
|
||||||
return self._newConf(card)
|
return self._newConf(card)
|
||||||
|
|
||||||
def _rescheduleAsRev(self, card, conf, early):
|
def _rescheduleAsRev(self, card, conf, early):
|
||||||
lapse = card.type == 2
|
lapse = card.type == CARD_TYPE_REV
|
||||||
if lapse:
|
if lapse:
|
||||||
if self._resched(card):
|
if self._resched(card):
|
||||||
card.due = max(self.today + 1, card.odue)
|
card.due = max(self.today + 1, card.odue)
|
||||||
@ -642,8 +642,8 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
|||||||
card.odue = 0
|
card.odue = 0
|
||||||
else:
|
else:
|
||||||
self._rescheduleNew(card, conf, early)
|
self._rescheduleNew(card, conf, early)
|
||||||
card.queue = 2
|
card.queue = QUEUE_TYPE_REV
|
||||||
card.type = 2
|
card.type = CARD_TYPE_REV
|
||||||
# if we were dynamic, graduating means moving back to the old deck
|
# if we were dynamic, graduating means moving back to the old deck
|
||||||
resched = self._resched(card)
|
resched = self._resched(card)
|
||||||
if card.odid:
|
if card.odid:
|
||||||
@ -656,7 +656,7 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
|||||||
card.due = self.col.nextID("pos")
|
card.due = self.col.nextID("pos")
|
||||||
|
|
||||||
def _startingLeft(self, card):
|
def _startingLeft(self, card):
|
||||||
if card.type == 2:
|
if card.type == CARD_TYPE_REV:
|
||||||
conf = self._lapseConf(card)
|
conf = self._lapseConf(card)
|
||||||
else:
|
else:
|
||||||
conf = self._lrnConf(card)
|
conf = self._lrnConf(card)
|
||||||
@ -678,7 +678,7 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
|||||||
return ok + 1
|
return ok + 1
|
||||||
|
|
||||||
def _graduatingIvl(self, card, conf, early, adj=True):
|
def _graduatingIvl(self, card, conf, early, adj=True):
|
||||||
if card.type == 2:
|
if card.type == CARD_TYPE_REV:
|
||||||
# lapsed card being relearnt
|
# lapsed card being relearnt
|
||||||
if card.odid:
|
if card.odid:
|
||||||
if conf["resched"]:
|
if conf["resched"]:
|
||||||
@ -738,8 +738,8 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
|||||||
self.col.db.execute(
|
self.col.db.execute(
|
||||||
f"""
|
f"""
|
||||||
update cards set
|
update cards set
|
||||||
due = odue, queue = 2, mod = %d, usn = %d, odue = 0
|
due = odue, queue = {QUEUE_TYPE_REV}, mod = %d, usn = %d, odue = 0
|
||||||
where queue in ({QUEUE_TYPE_LRN},3) and type = 2
|
where queue in ({QUEUE_TYPE_LRN},3) and type = {CARD_TYPE_REV}
|
||||||
%s
|
%s
|
||||||
"""
|
"""
|
||||||
% (intTime(), self.col.usn(), extra)
|
% (intTime(), self.col.usn(), extra)
|
||||||
@ -786,9 +786,9 @@ and due <= ? limit ?)""",
|
|||||||
def _revForDeck(self, did, lim):
|
def _revForDeck(self, did, lim):
|
||||||
lim = min(lim, self.reportLimit)
|
lim = min(lim, self.reportLimit)
|
||||||
return self.col.db.scalar(
|
return self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from
|
select count() from
|
||||||
(select 1 from cards where did = ? and queue = 2
|
(select 1 from cards where did = ? and queue = {QUEUE_TYPE_REV}
|
||||||
and due <= ? limit ?)""",
|
and due <= ? limit ?)""",
|
||||||
did,
|
did,
|
||||||
self.today,
|
self.today,
|
||||||
@ -798,9 +798,9 @@ and due <= ? limit ?)""",
|
|||||||
def _resetRevCount(self):
|
def _resetRevCount(self):
|
||||||
def cntFn(did, lim):
|
def cntFn(did, lim):
|
||||||
return self.col.db.scalar(
|
return self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from (select id from cards where
|
select count() from (select id from cards where
|
||||||
did = ? and queue = 2 and due <= ? limit %d)"""
|
did = ? and queue = {QUEUE_TYPE_REV} and due <= ? limit %d)"""
|
||||||
% lim,
|
% lim,
|
||||||
did,
|
did,
|
||||||
self.today,
|
self.today,
|
||||||
@ -824,9 +824,9 @@ did = ? and queue = 2 and due <= ? limit %d)"""
|
|||||||
if lim:
|
if lim:
|
||||||
# fill the queue with the current did
|
# fill the queue with the current did
|
||||||
self._revQueue = self.col.db.list(
|
self._revQueue = self.col.db.list(
|
||||||
"""
|
f"""
|
||||||
select id from cards where
|
select id from cards where
|
||||||
did = ? and queue = 2 and due <= ? limit ?""",
|
did = ? and queue = {QUEUE_TYPE_REV} and due <= ? limit ?""",
|
||||||
did,
|
did,
|
||||||
self.today,
|
self.today,
|
||||||
lim,
|
lim,
|
||||||
@ -861,9 +861,9 @@ did = ? and queue = 2 and due <= ? limit ?""",
|
|||||||
|
|
||||||
def totalRevForCurrentDeck(self):
|
def totalRevForCurrentDeck(self):
|
||||||
return self.col.db.scalar(
|
return self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from cards where id in (
|
select count() from cards where id in (
|
||||||
select id from cards where did in %s and queue = 2 and due <= ? limit ?)"""
|
select id from cards where did in %s and queue = {QUEUE_TYPE_REV} and due <= ? limit ?)"""
|
||||||
% ids2str(self.col.decks.active()),
|
% ids2str(self.col.decks.active()),
|
||||||
self.today,
|
self.today,
|
||||||
self.reportLimit,
|
self.reportLimit,
|
||||||
@ -1088,7 +1088,7 @@ due = odue, odue = 0, odid = 0, usn = ? where %s"""
|
|||||||
t = "c.due"
|
t = "c.due"
|
||||||
elif o == DYN_DUEPRIORITY:
|
elif o == DYN_DUEPRIORITY:
|
||||||
t = (
|
t = (
|
||||||
"(case when queue=2 and due <= %d then (ivl / cast(%d-due+0.001 as real)) else 100000+due end)"
|
f"(case when queue={QUEUE_TYPE_REV} and due <= %d then (ivl / cast(%d-due+0.001 as real)) else 100000+due end)"
|
||||||
% (self.today, self.today)
|
% (self.today, self.today)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@ -1107,8 +1107,8 @@ due = odue, odue = 0, odid = 0, usn = ? where %s"""
|
|||||||
# due reviews stay in the review queue. careful: can't use
|
# due reviews stay in the review queue. careful: can't use
|
||||||
# "odid or did", as sqlite converts to boolean
|
# "odid or did", as sqlite converts to boolean
|
||||||
queue = f"""
|
queue = f"""
|
||||||
(case when type=2 and (case when odue then odue <= %d else due <= %d end)
|
(case when type={CARD_TYPE_REV} and (case when odue then odue <= %d else due <= %d end)
|
||||||
then 2 else {QUEUE_TYPE_NEW} end)"""
|
then {QUEUE_TYPE_REV} else {QUEUE_TYPE_NEW} end)"""
|
||||||
queue %= (self.today, self.today)
|
queue %= (self.today, self.today)
|
||||||
self.col.db.executemany(
|
self.col.db.executemany(
|
||||||
"""
|
"""
|
||||||
@ -1121,7 +1121,7 @@ did = ?, queue = %s, due = ?, usn = ? where id = ?"""
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _dynIvlBoost(self, card):
|
def _dynIvlBoost(self, card):
|
||||||
assert card.odid and card.type == 2
|
assert card.odid and card.type == CARD_TYPE_REV
|
||||||
assert card.factor
|
assert card.factor
|
||||||
elapsed = card.ivl - (card.odue - self.today)
|
elapsed = card.ivl - (card.odue - self.today)
|
||||||
factor = ((card.factor / 1000) + 1.2) / 2
|
factor = ((card.factor / 1000) + 1.2) / 2
|
||||||
@ -1311,7 +1311,7 @@ To study outside of the normal schedule, click the Custom Study button below."""
|
|||||||
"True if there are any rev cards due."
|
"True if there are any rev cards due."
|
||||||
return self.col.db.scalar(
|
return self.col.db.scalar(
|
||||||
(
|
(
|
||||||
"select 1 from cards where did in %s and queue = 2 "
|
f"select 1 from cards where did in %s and queue = {QUEUE_TYPE_REV} "
|
||||||
"and due <= ? limit 1"
|
"and due <= ? limit 1"
|
||||||
)
|
)
|
||||||
% self._deckLimit(),
|
% self._deckLimit(),
|
||||||
@ -1438,12 +1438,12 @@ update cards set queue={QUEUE_TYPE_SIBLING_BURIED},mod=?,usn=? where id in """
|
|||||||
for cid, queue in self.col.db.execute(
|
for cid, queue in self.col.db.execute(
|
||||||
f"""
|
f"""
|
||||||
select id, queue from cards where nid=? and id!=?
|
select id, queue from cards where nid=? and id!=?
|
||||||
and (queue={QUEUE_TYPE_NEW} or (queue=2 and due<=?))""",
|
and (queue={QUEUE_TYPE_NEW} or (queue={QUEUE_TYPE_REV} and due<=?))""",
|
||||||
card.nid,
|
card.nid,
|
||||||
card.id,
|
card.id,
|
||||||
self.today,
|
self.today,
|
||||||
):
|
):
|
||||||
if queue == 2:
|
if queue == QUEUE_TYPE_REV:
|
||||||
if buryRev:
|
if buryRev:
|
||||||
toBury.append(cid)
|
toBury.append(cid)
|
||||||
# if bury disabled, we still discard to give same-day spacing
|
# if bury disabled, we still discard to give same-day spacing
|
||||||
@ -1503,8 +1503,8 @@ and (queue={QUEUE_TYPE_NEW} or (queue=2 and due<=?))""",
|
|||||||
)
|
)
|
||||||
self.remFromDyn(ids)
|
self.remFromDyn(ids)
|
||||||
self.col.db.executemany(
|
self.col.db.executemany(
|
||||||
"""
|
f"""
|
||||||
update cards set type=2,queue=2,ivl=:ivl,due=:due,odue=0,
|
update cards set type={CARD_TYPE_REV},queue={QUEUE_TYPE_REV},ivl=:ivl,due=:due,odue=0,
|
||||||
usn=:usn,mod=:mod,factor=:fact where id=:id""",
|
usn=:usn,mod=:mod,factor=:fact where id=:id""",
|
||||||
d,
|
d,
|
||||||
)
|
)
|
||||||
|
@ -105,7 +105,7 @@ class Scheduler:
|
|||||||
|
|
||||||
if card.queue in (QUEUE_TYPE_LRN, QUEUE_TYPE_DAY_LEARN_RELEARN):
|
if card.queue in (QUEUE_TYPE_LRN, QUEUE_TYPE_DAY_LEARN_RELEARN):
|
||||||
self._answerLrnCard(card, ease)
|
self._answerLrnCard(card, ease)
|
||||||
elif card.queue == 2:
|
elif card.queue == QUEUE_TYPE_REV:
|
||||||
self._answerRevCard(card, ease)
|
self._answerRevCard(card, ease)
|
||||||
# update daily limit
|
# update daily limit
|
||||||
self._updateStats(card, "rev")
|
self._updateStats(card, "rev")
|
||||||
@ -142,9 +142,9 @@ class Scheduler:
|
|||||||
"Return counts over next DAYS. Includes today."
|
"Return counts over next DAYS. Includes today."
|
||||||
daysd = dict(
|
daysd = dict(
|
||||||
self.col.db.all(
|
self.col.db.all(
|
||||||
"""
|
f"""
|
||||||
select due, count() from cards
|
select due, count() from cards
|
||||||
where did in %s and queue = 2
|
where did in %s and queue = {QUEUE_TYPE_REV}
|
||||||
and due between ? and ?
|
and due between ? and ?
|
||||||
group by due
|
group by due
|
||||||
order by due"""
|
order by due"""
|
||||||
@ -606,7 +606,7 @@ did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
|
|||||||
|
|
||||||
def _answerLrnCard(self, card: Card, ease: int) -> None:
|
def _answerLrnCard(self, card: Card, ease: int) -> None:
|
||||||
conf = self._lrnConf(card)
|
conf = self._lrnConf(card)
|
||||||
if card.type in (2, CARD_TYPE_RELEARNING):
|
if card.type in (CARD_TYPE_REV, CARD_TYPE_RELEARNING):
|
||||||
type = REVLOG_RELRN
|
type = REVLOG_RELRN
|
||||||
else:
|
else:
|
||||||
type = REVLOG_LRN
|
type = REVLOG_LRN
|
||||||
@ -714,13 +714,13 @@ did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
|
|||||||
return avg
|
return avg
|
||||||
|
|
||||||
def _lrnConf(self, card: Card) -> Any:
|
def _lrnConf(self, card: Card) -> Any:
|
||||||
if card.type in (2, CARD_TYPE_RELEARNING):
|
if card.type in (CARD_TYPE_REV, CARD_TYPE_RELEARNING):
|
||||||
return self._lapseConf(card)
|
return self._lapseConf(card)
|
||||||
else:
|
else:
|
||||||
return self._newConf(card)
|
return self._newConf(card)
|
||||||
|
|
||||||
def _rescheduleAsRev(self, card: Card, conf: Dict[str, Any], early: bool) -> None:
|
def _rescheduleAsRev(self, card: Card, conf: Dict[str, Any], early: bool) -> None:
|
||||||
lapse = card.type in (2, CARD_TYPE_RELEARNING)
|
lapse = card.type in (CARD_TYPE_REV, CARD_TYPE_RELEARNING)
|
||||||
|
|
||||||
if lapse:
|
if lapse:
|
||||||
self._rescheduleGraduatingLapse(card, early)
|
self._rescheduleGraduatingLapse(card, early)
|
||||||
@ -735,8 +735,8 @@ did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
|
|||||||
if early:
|
if early:
|
||||||
card.ivl += 1
|
card.ivl += 1
|
||||||
card.due = self.today + card.ivl
|
card.due = self.today + card.ivl
|
||||||
card.queue = 2
|
card.queue = QUEUE_TYPE_REV
|
||||||
card.type = 2
|
card.type = CARD_TYPE_REV
|
||||||
|
|
||||||
def _startingLeft(self, card: Card) -> int:
|
def _startingLeft(self, card: Card) -> int:
|
||||||
if card.type == CARD_TYPE_RELEARNING:
|
if card.type == CARD_TYPE_RELEARNING:
|
||||||
@ -768,7 +768,7 @@ did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
|
|||||||
def _graduatingIvl(
|
def _graduatingIvl(
|
||||||
self, card: Card, conf: Dict[str, Any], early: bool, fuzz: bool = True
|
self, card: Card, conf: Dict[str, Any], early: bool, fuzz: bool = True
|
||||||
) -> Any:
|
) -> Any:
|
||||||
if card.type in (2, CARD_TYPE_RELEARNING):
|
if card.type in (CARD_TYPE_REV, CARD_TYPE_RELEARNING):
|
||||||
bonus = early and 1 or 0
|
bonus = early and 1 or 0
|
||||||
return card.ivl + bonus
|
return card.ivl + bonus
|
||||||
if not early:
|
if not early:
|
||||||
@ -786,7 +786,7 @@ did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
|
|||||||
card.ivl = self._graduatingIvl(card, conf, early)
|
card.ivl = self._graduatingIvl(card, conf, early)
|
||||||
card.due = self.today + card.ivl
|
card.due = self.today + card.ivl
|
||||||
card.factor = conf["initialFactor"]
|
card.factor = conf["initialFactor"]
|
||||||
card.type = card.queue = 2
|
card.type = card.queue = QUEUE_TYPE_REV
|
||||||
|
|
||||||
def _logLrn(
|
def _logLrn(
|
||||||
self,
|
self,
|
||||||
@ -883,9 +883,9 @@ and due <= ? limit ?)""",
|
|||||||
dids = [did] + self.col.decks.childDids(did, childMap)
|
dids = [did] + self.col.decks.childDids(did, childMap)
|
||||||
lim = min(lim, self.reportLimit)
|
lim = min(lim, self.reportLimit)
|
||||||
return self.col.db.scalar(
|
return self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from
|
select count() from
|
||||||
(select 1 from cards where did in %s and queue = 2
|
(select 1 from cards where did in %s and queue = {QUEUE_TYPE_REV}
|
||||||
and due <= ? limit ?)"""
|
and due <= ? limit ?)"""
|
||||||
% ids2str(dids),
|
% ids2str(dids),
|
||||||
self.today,
|
self.today,
|
||||||
@ -895,9 +895,9 @@ and due <= ? limit ?)"""
|
|||||||
def _resetRevCount(self) -> None:
|
def _resetRevCount(self) -> None:
|
||||||
lim = self._currentRevLimit()
|
lim = self._currentRevLimit()
|
||||||
self.revCount = self.col.db.scalar(
|
self.revCount = self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from (select id from cards where
|
select count() from (select id from cards where
|
||||||
did in %s and queue = 2 and due <= ? limit ?)"""
|
did in %s and queue = {QUEUE_TYPE_REV} and due <= ? limit ?)"""
|
||||||
% self._deckLimit(),
|
% self._deckLimit(),
|
||||||
self.today,
|
self.today,
|
||||||
lim,
|
lim,
|
||||||
@ -916,9 +916,9 @@ did in %s and queue = 2 and due <= ? limit ?)"""
|
|||||||
lim = min(self.queueLimit, self._currentRevLimit())
|
lim = min(self.queueLimit, self._currentRevLimit())
|
||||||
if lim:
|
if lim:
|
||||||
self._revQueue = self.col.db.list(
|
self._revQueue = self.col.db.list(
|
||||||
"""
|
f"""
|
||||||
select id from cards where
|
select id from cards where
|
||||||
did in %s and queue = 2 and due <= ?
|
did in %s and queue = {QUEUE_TYPE_REV} and due <= ?
|
||||||
order by due, random()
|
order by due, random()
|
||||||
limit ?"""
|
limit ?"""
|
||||||
% self._deckLimit(),
|
% self._deckLimit(),
|
||||||
@ -946,9 +946,9 @@ limit ?"""
|
|||||||
|
|
||||||
def totalRevForCurrentDeck(self) -> int:
|
def totalRevForCurrentDeck(self) -> int:
|
||||||
return self.col.db.scalar(
|
return self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from cards where id in (
|
select count() from cards where id in (
|
||||||
select id from cards where did in %s and queue = 2 and due <= ? limit ?)"""
|
select id from cards where did in %s and queue = {QUEUE_TYPE_REV} and due <= ? limit ?)"""
|
||||||
% self._deckLimit(),
|
% self._deckLimit(),
|
||||||
self.today,
|
self.today,
|
||||||
self.reportLimit,
|
self.reportLimit,
|
||||||
@ -1101,7 +1101,7 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)"""
|
|||||||
|
|
||||||
# next interval for card when answered early+correctly
|
# next interval for card when answered early+correctly
|
||||||
def _earlyReviewIvl(self, card: Card, ease: int) -> int:
|
def _earlyReviewIvl(self, card: Card, ease: int) -> int:
|
||||||
assert card.odid and card.type == 2
|
assert card.odid and card.type == CARD_TYPE_REV
|
||||||
assert card.factor
|
assert card.factor
|
||||||
assert ease > 1
|
assert ease > 1
|
||||||
|
|
||||||
@ -1213,7 +1213,7 @@ due = (case when odue>0 then odue else due end), odue = 0, odid = 0, usn = ? whe
|
|||||||
t = "n.id desc"
|
t = "n.id desc"
|
||||||
elif o == DYN_DUEPRIORITY:
|
elif o == DYN_DUEPRIORITY:
|
||||||
t = (
|
t = (
|
||||||
"(case when queue=2 and due <= %d then (ivl / cast(%d-due+0.001 as real)) else 100000+due end)"
|
f"(case when queue={QUEUE_TYPE_REV} and due <= %d then (ivl / cast(%d-due+0.001 as real)) else 100000+due end)"
|
||||||
% (self.today, self.today)
|
% (self.today, self.today)
|
||||||
)
|
)
|
||||||
else: # DYN_DUE or unknown
|
else: # DYN_DUE or unknown
|
||||||
@ -1231,7 +1231,7 @@ due = (case when odue>0 then odue else due end), odue = 0, odid = 0, usn = ? whe
|
|||||||
|
|
||||||
queue = ""
|
queue = ""
|
||||||
if not deck["resched"]:
|
if not deck["resched"]:
|
||||||
queue = ",queue=2"
|
queue = f",queue={QUEUE_TYPE_REV}"
|
||||||
|
|
||||||
query = (
|
query = (
|
||||||
"""
|
"""
|
||||||
@ -1509,7 +1509,7 @@ To study outside of the normal schedule, click the Custom Study button below."""
|
|||||||
"True if there are any rev cards due."
|
"True if there are any rev cards due."
|
||||||
return self.col.db.scalar(
|
return self.col.db.scalar(
|
||||||
(
|
(
|
||||||
"select 1 from cards where did in %s and queue = 2 "
|
f"select 1 from cards where did in %s and queue = {QUEUE_TYPE_REV} "
|
||||||
"and due <= ? limit 1"
|
"and due <= ? limit 1"
|
||||||
)
|
)
|
||||||
% self._deckLimit(),
|
% self._deckLimit(),
|
||||||
@ -1700,12 +1700,12 @@ update cards set queue=?,mod=?,usn=? where id in """
|
|||||||
for cid, queue in self.col.db.execute(
|
for cid, queue in self.col.db.execute(
|
||||||
f"""
|
f"""
|
||||||
select id, queue from cards where nid=? and id!=?
|
select id, queue from cards where nid=? and id!=?
|
||||||
and (queue={QUEUE_TYPE_NEW} or (queue=2 and due<=?))""",
|
and (queue={QUEUE_TYPE_NEW} or (queue={QUEUE_TYPE_REV} and due<=?))""",
|
||||||
card.nid,
|
card.nid,
|
||||||
card.id,
|
card.id,
|
||||||
self.today,
|
self.today,
|
||||||
):
|
):
|
||||||
if queue == 2:
|
if queue == QUEUE_TYPE_REV:
|
||||||
if buryRev:
|
if buryRev:
|
||||||
toBury.append(cid)
|
toBury.append(cid)
|
||||||
# if bury disabled, we still discard to give same-day spacing
|
# if bury disabled, we still discard to give same-day spacing
|
||||||
@ -1760,8 +1760,8 @@ and (queue={QUEUE_TYPE_NEW} or (queue=2 and due<=?))""",
|
|||||||
)
|
)
|
||||||
self.remFromDyn(ids)
|
self.remFromDyn(ids)
|
||||||
self.col.db.executemany(
|
self.col.db.executemany(
|
||||||
"""
|
f"""
|
||||||
update cards set type=2,queue=2,ivl=:ivl,due=:due,odue=0,
|
update cards set type={CARD_TYPE_REV},queue={QUEUE_TYPE_REV},ivl=:ivl,due=:due,odue=0,
|
||||||
usn=:usn,mod=:mod,factor=:fact where id=:id""",
|
usn=:usn,mod=:mod,factor=:fact where id=:id""",
|
||||||
d,
|
d,
|
||||||
)
|
)
|
||||||
@ -1875,10 +1875,10 @@ and due >= ? and queue = {QUEUE_TYPE_NEW}"""
|
|||||||
f"""
|
f"""
|
||||||
update cards set did = odid, queue = (case
|
update cards set did = odid, queue = (case
|
||||||
when type = {CARD_TYPE_LRN} then {QUEUE_TYPE_NEW}
|
when type = {CARD_TYPE_LRN} then {QUEUE_TYPE_NEW}
|
||||||
when type = {CARD_TYPE_RELEARNING} then 2
|
when type = {CARD_TYPE_RELEARNING} then {QUEUE_TYPE_REV}
|
||||||
else type end), type = (case
|
else type end), type = (case
|
||||||
when type = {CARD_TYPE_LRN} then {CARD_TYPE_NEW}
|
when type = {CARD_TYPE_LRN} then {CARD_TYPE_NEW}
|
||||||
when type = {CARD_TYPE_RELEARNING} then 2
|
when type = {CARD_TYPE_RELEARNING} then {CARD_TYPE_REV}
|
||||||
else type end),
|
else type end),
|
||||||
due = odue, odue = 0, odid = 0, usn = ? where odid != 0""",
|
due = odue, odue = 0, odid = 0, usn = ? where odid != 0""",
|
||||||
self.col.usn(),
|
self.col.usn(),
|
||||||
@ -1890,8 +1890,8 @@ due = odue, odue = 0, odid = 0, usn = ? where odid != 0""",
|
|||||||
self.col.db.execute(
|
self.col.db.execute(
|
||||||
f"""
|
f"""
|
||||||
update cards set
|
update cards set
|
||||||
due = odue, queue = 2, type = 2, mod = %d, usn = %d, odue = 0
|
due = odue, queue = {QUEUE_TYPE_REV}, type = {CARD_TYPE_REV}, mod = %d, usn = %d, odue = 0
|
||||||
where queue in ({QUEUE_TYPE_LRN},{QUEUE_TYPE_DAY_LEARN_RELEARN}) and type in (2, {CARD_TYPE_RELEARNING})
|
where queue in ({QUEUE_TYPE_LRN},{QUEUE_TYPE_DAY_LEARN_RELEARN}) and type in ({CARD_TYPE_REV}, {CARD_TYPE_RELEARNING})
|
||||||
"""
|
"""
|
||||||
% (intTime(), self.col.usn())
|
% (intTime(), self.col.usn())
|
||||||
)
|
)
|
||||||
@ -1899,8 +1899,8 @@ due = odue, odue = 0, odid = 0, usn = ? where odid != 0""",
|
|||||||
self.col.db.execute(
|
self.col.db.execute(
|
||||||
f"""
|
f"""
|
||||||
update cards set
|
update cards set
|
||||||
due = %d+ivl, queue = 2, type = 2, mod = %d, usn = %d, odue = 0
|
due = %d+ivl, queue = {QUEUE_TYPE_REV}, type = {CARD_TYPE_REV}, mod = %d, usn = %d, odue = 0
|
||||||
where queue in ({QUEUE_TYPE_LRN},{QUEUE_TYPE_DAY_LEARN_RELEARN}) and type in (2, {CARD_TYPE_RELEARNING})
|
where queue in ({QUEUE_TYPE_LRN},{QUEUE_TYPE_DAY_LEARN_RELEARN}) and type in ({CARD_TYPE_REV}, {CARD_TYPE_RELEARNING})
|
||||||
"""
|
"""
|
||||||
% (self.today, intTime(), self.col.usn())
|
% (self.today, intTime(), self.col.usn())
|
||||||
)
|
)
|
||||||
@ -1917,7 +1917,7 @@ due = odue, odue = 0, odid = 0, usn = ? where odid != 0""",
|
|||||||
f"""
|
f"""
|
||||||
update cards set type = (case
|
update cards set type = (case
|
||||||
when type = {CARD_TYPE_LRN} then {CARD_TYPE_NEW}
|
when type = {CARD_TYPE_LRN} then {CARD_TYPE_NEW}
|
||||||
when type in (2, {CARD_TYPE_RELEARNING}) then 2
|
when type in ({CARD_TYPE_REV}, {CARD_TYPE_RELEARNING}) then {CARD_TYPE_REV}
|
||||||
else type end),
|
else type end),
|
||||||
due = (case when odue then odue else due end),
|
due = (case when odue then odue else due end),
|
||||||
odue = 0,
|
odue = 0,
|
||||||
@ -1936,7 +1936,7 @@ where queue < {QUEUE_TYPE_NEW}"""
|
|||||||
# adding 'hard' in v2 scheduler means old ease entries need shifting
|
# adding 'hard' in v2 scheduler means old ease entries need shifting
|
||||||
# up or down
|
# up or down
|
||||||
def _remapLearningAnswers(self, sql: str) -> None:
|
def _remapLearningAnswers(self, sql: str) -> None:
|
||||||
self.col.db.execute(f"update revlog set %s and type in ({CARD_TYPE_NEW},2)" % sql)
|
self.col.db.execute(f"update revlog set %s and type in ({CARD_TYPE_NEW},{CARD_TYPE_REV})" % sql)
|
||||||
|
|
||||||
def moveToV1(self) -> None:
|
def moveToV1(self) -> None:
|
||||||
self._emptyAllFiltered()
|
self._emptyAllFiltered()
|
||||||
|
@ -35,18 +35,18 @@ class CardStats:
|
|||||||
if first:
|
if first:
|
||||||
self.addLine(_("First Review"), self.date(first / 1000))
|
self.addLine(_("First Review"), self.date(first / 1000))
|
||||||
self.addLine(_("Latest Review"), self.date(last / 1000))
|
self.addLine(_("Latest Review"), self.date(last / 1000))
|
||||||
if c.type in (CARD_TYPE_LRN, 2):
|
if c.type in (CARD_TYPE_LRN, CARD_TYPE_REV):
|
||||||
if c.odid or c.queue < QUEUE_TYPE_NEW:
|
if c.odid or c.queue < QUEUE_TYPE_NEW:
|
||||||
next = None
|
next = None
|
||||||
else:
|
else:
|
||||||
if c.queue in (2, 3):
|
if c.queue in (QUEUE_TYPE_REV, 3):
|
||||||
next = time.time() + ((c.due - self.col.sched.today) * 86400)
|
next = time.time() + ((c.due - self.col.sched.today) * 86400)
|
||||||
else:
|
else:
|
||||||
next = c.due
|
next = c.due
|
||||||
next = self.date(next)
|
next = self.date(next)
|
||||||
if next:
|
if next:
|
||||||
self.addLine(_("Due"), next)
|
self.addLine(_("Due"), next)
|
||||||
if c.queue == 2:
|
if c.queue == QUEUE_TYPE_REV:
|
||||||
self.addLine(_("Interval"), fmt(c.ivl * 86400))
|
self.addLine(_("Interval"), fmt(c.ivl * 86400))
|
||||||
self.addLine(_("Ease"), "%d%%" % (c.factor / 10.0))
|
self.addLine(_("Ease"), "%d%%" % (c.factor / 10.0))
|
||||||
self.addLine(_("Reviews"), "%d" % c.reps)
|
self.addLine(_("Reviews"), "%d" % c.reps)
|
||||||
@ -284,8 +284,8 @@ from revlog where id > ? """
|
|||||||
self._line(i, _("Total"), ngettext("%d review", "%d reviews", tot) % tot)
|
self._line(i, _("Total"), ngettext("%d review", "%d reviews", tot) % tot)
|
||||||
self._line(i, _("Average"), self._avgDay(tot, num, _("reviews")))
|
self._line(i, _("Average"), self._avgDay(tot, num, _("reviews")))
|
||||||
tomorrow = self.col.db.scalar(
|
tomorrow = self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from cards where did in %s and queue in (2,3)
|
select count() from cards where did in %s and queue in ({QUEUE_TYPE_REV},3)
|
||||||
and due = ?"""
|
and due = ?"""
|
||||||
% self._limit(),
|
% self._limit(),
|
||||||
self.col.sched.today + 1,
|
self.col.sched.today + 1,
|
||||||
@ -301,12 +301,12 @@ and due = ?"""
|
|||||||
if end is not None:
|
if end is not None:
|
||||||
lim += " and day < %d" % end
|
lim += " and day < %d" % end
|
||||||
return self.col.db.all(
|
return self.col.db.all(
|
||||||
"""
|
f"""
|
||||||
select (due-:today)/:chunk as day,
|
select (due-:today)/:chunk as day,
|
||||||
sum(case when ivl < 21 then 1 else 0 end), -- yng
|
sum(case when ivl < 21 then 1 else 0 end), -- yng
|
||||||
sum(case when ivl >= 21 then 1 else 0 end) -- mtr
|
sum(case when ivl >= 21 then 1 else 0 end) -- mtr
|
||||||
from cards
|
from cards
|
||||||
where did in %s and queue in (2,3)
|
where did in %s and queue in ({QUEUE_TYPE_REV},3)
|
||||||
%s
|
%s
|
||||||
group by day order by day"""
|
group by day order by day"""
|
||||||
% (self._limit(), lim),
|
% (self._limit(), lim),
|
||||||
@ -644,9 +644,9 @@ group by day order by day)"""
|
|||||||
lim = "and grp <= %d" % end if end else ""
|
lim = "and grp <= %d" % end if end else ""
|
||||||
data = [
|
data = [
|
||||||
self.col.db.all(
|
self.col.db.all(
|
||||||
"""
|
f"""
|
||||||
select ivl / :chunk as grp, count() from cards
|
select ivl / :chunk as grp, count() from cards
|
||||||
where did in %s and queue = 2 %s
|
where did in %s and queue = {QUEUE_TYPE_REV} %s
|
||||||
group by grp
|
group by grp
|
||||||
order by grp"""
|
order by grp"""
|
||||||
% (self._limit(), lim),
|
% (self._limit(), lim),
|
||||||
@ -657,8 +657,8 @@ order by grp"""
|
|||||||
data
|
data
|
||||||
+ list(
|
+ list(
|
||||||
self.col.db.first(
|
self.col.db.first(
|
||||||
"""
|
f"""
|
||||||
select count(), avg(ivl), max(ivl) from cards where did in %s and queue = 2"""
|
select count(), avg(ivl), max(ivl) from cards where did in %s and queue = {QUEUE_TYPE_REV}"""
|
||||||
% self._limit()
|
% self._limit()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -678,7 +678,7 @@ select count(), avg(ivl), max(ivl) from cards where did in %s and queue = 2"""
|
|||||||
for (type, ease, cnt) in eases:
|
for (type, ease, cnt) in eases:
|
||||||
if type == CARD_TYPE_LRN:
|
if type == CARD_TYPE_LRN:
|
||||||
ease += 5
|
ease += 5
|
||||||
elif type == 2:
|
elif type == CARD_TYPE_REV:
|
||||||
ease += 10
|
ease += 10
|
||||||
n = types[type]
|
n = types[type]
|
||||||
d[n].append((ease, cnt))
|
d[n].append((ease, cnt))
|
||||||
@ -930,12 +930,12 @@ when you answer "good" on a review."""
|
|||||||
|
|
||||||
def _factors(self) -> Any:
|
def _factors(self) -> Any:
|
||||||
return self.col.db.first(
|
return self.col.db.first(
|
||||||
"""
|
f"""
|
||||||
select
|
select
|
||||||
min(factor) / 10.0,
|
min(factor) / 10.0,
|
||||||
avg(factor) / 10.0,
|
avg(factor) / 10.0,
|
||||||
max(factor) / 10.0
|
max(factor) / 10.0
|
||||||
from cards where did in %s and queue = 2"""
|
from cards where did in %s and queue = {QUEUE_TYPE_REV}"""
|
||||||
% self._limit()
|
% self._limit()
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -943,8 +943,8 @@ from cards where did in %s and queue = 2"""
|
|||||||
return self.col.db.first(
|
return self.col.db.first(
|
||||||
f"""
|
f"""
|
||||||
select
|
select
|
||||||
sum(case when queue=2 and ivl >= 21 then 1 else 0 end), -- mtr
|
sum(case when queue={QUEUE_TYPE_REV} and ivl >= 21 then 1 else 0 end), -- mtr
|
||||||
sum(case when queue in ({QUEUE_TYPE_LRN},3) or (queue=2 and ivl < 21) then 1 else 0 end), -- yng/lrn
|
sum(case when queue in ({QUEUE_TYPE_LRN},3) or (queue={QUEUE_TYPE_REV} and ivl < 21) then 1 else 0 end), -- yng/lrn
|
||||||
sum(case when queue={QUEUE_TYPE_NEW} then 1 else 0 end), -- new
|
sum(case when queue={QUEUE_TYPE_NEW} then 1 else 0 end), -- new
|
||||||
sum(case when queue<{QUEUE_TYPE_NEW} then 1 else 0 end) -- susp
|
sum(case when queue<{QUEUE_TYPE_NEW} then 1 else 0 end) -- susp
|
||||||
from cards where did in %s"""
|
from cards where did in %s"""
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from anki.consts import *
|
||||||
from anki.find import Finder
|
from anki.find import Finder
|
||||||
from tests.shared import getEmptyCol
|
from tests.shared import getEmptyCol
|
||||||
|
|
||||||
@ -91,13 +92,13 @@ def test_findCards():
|
|||||||
assert len(deck.findCards('"goats are"')) == 1
|
assert len(deck.findCards('"goats are"')) == 1
|
||||||
# card states
|
# card states
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.queue = c.type = 2
|
c.queue = c.type = CARD_TYPE_REV
|
||||||
assert deck.findCards("is:review") == []
|
assert deck.findCards("is:review") == []
|
||||||
c.flush()
|
c.flush()
|
||||||
assert deck.findCards("is:review") == [c.id]
|
assert deck.findCards("is:review") == [c.id]
|
||||||
assert deck.findCards("is:due") == []
|
assert deck.findCards("is:due") == []
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.flush()
|
c.flush()
|
||||||
assert deck.findCards("is:due") == [c.id]
|
assert deck.findCards("is:due") == [c.id]
|
||||||
assert len(deck.findCards("-is:due")) == 4
|
assert len(deck.findCards("-is:due")) == 4
|
||||||
|
@ -166,8 +166,8 @@ def test_learn():
|
|||||||
assert c.queue == QUEUE_TYPE_LRN
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == CARD_TYPE_LRN
|
assert c.type == CARD_TYPE_LRN
|
||||||
d.sched.answerCard(c, 2)
|
d.sched.answerCard(c, 2)
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
assert c.type == 2
|
assert c.type == CARD_TYPE_REV
|
||||||
# should be due tomorrow, with an interval of 1
|
# should be due tomorrow, with an interval of 1
|
||||||
assert c.due == d.sched.today + 1
|
assert c.due == d.sched.today + 1
|
||||||
assert c.ivl == 1
|
assert c.ivl == 1
|
||||||
@ -175,27 +175,27 @@ def test_learn():
|
|||||||
c.type = 0
|
c.type = 0
|
||||||
c.queue = 1
|
c.queue = 1
|
||||||
d.sched.answerCard(c, 3)
|
d.sched.answerCard(c, 3)
|
||||||
assert c.type == 2
|
assert c.type == CARD_TYPE_REV
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
assert checkRevIvl(d, c, 4)
|
assert checkRevIvl(d, c, 4)
|
||||||
# revlog should have been updated each time
|
# revlog should have been updated each time
|
||||||
assert d.db.scalar("select count() from revlog where type = 0") == 5
|
assert d.db.scalar("select count() from revlog where type = 0") == 5
|
||||||
# now failed card handling
|
# now failed card handling
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 1
|
c.queue = 1
|
||||||
c.odue = 123
|
c.odue = 123
|
||||||
d.sched.answerCard(c, 3)
|
d.sched.answerCard(c, 3)
|
||||||
assert c.due == 123
|
assert c.due == 123
|
||||||
assert c.type == 2
|
assert c.type == CARD_TYPE_REV
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
# we should be able to remove manually, too
|
# we should be able to remove manually, too
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 1
|
c.queue = 1
|
||||||
c.odue = 321
|
c.odue = 321
|
||||||
c.flush()
|
c.flush()
|
||||||
d.sched.removeLrn()
|
d.sched.removeLrn()
|
||||||
c.load()
|
c.load()
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
assert c.due == 321
|
assert c.due == 321
|
||||||
|
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ def test_learn_day():
|
|||||||
# the last pass should graduate it into a review card
|
# the last pass should graduate it into a review card
|
||||||
assert ni(c, 2) == 86400
|
assert ni(c, 2) == 86400
|
||||||
d.sched.answerCard(c, 2)
|
d.sched.answerCard(c, 2)
|
||||||
assert c.queue == c.type == 2
|
assert c.queue == CARD_TYPE_REV and c.type == QUEUE_TYPE_REV
|
||||||
# if the lapse step is tomorrow, failing it should handle the counts
|
# if the lapse step is tomorrow, failing it should handle the counts
|
||||||
# correctly
|
# correctly
|
||||||
c.due = 0
|
c.due = 0
|
||||||
@ -294,8 +294,8 @@ def test_reviews():
|
|||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
# set the card up as a review card, due 8 days ago
|
# set the card up as a review card, due 8 days ago
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = d.sched.today - 8
|
c.due = d.sched.today - 8
|
||||||
c.factor = STARTING_FACTOR
|
c.factor = STARTING_FACTOR
|
||||||
c.reps = 3
|
c.reps = 3
|
||||||
@ -333,7 +333,7 @@ def test_reviews():
|
|||||||
c = copy.copy(cardcopy)
|
c = copy.copy(cardcopy)
|
||||||
c.flush()
|
c.flush()
|
||||||
d.sched.answerCard(c, 2)
|
d.sched.answerCard(c, 2)
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
# the new interval should be (100 + 8/4) * 1.2 = 122
|
# the new interval should be (100 + 8/4) * 1.2 = 122
|
||||||
assert checkRevIvl(d, c, 122)
|
assert checkRevIvl(d, c, 122)
|
||||||
assert c.due == d.sched.today + c.ivl
|
assert c.due == d.sched.today + c.ivl
|
||||||
@ -388,8 +388,8 @@ def test_button_spacing():
|
|||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
# 1 day ivl review card due now
|
# 1 day ivl review card due now
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = d.sched.today
|
c.due = d.sched.today
|
||||||
c.reps = 1
|
c.reps = 1
|
||||||
c.ivl = 1
|
c.ivl = 1
|
||||||
@ -412,7 +412,7 @@ def test_overdue_lapse():
|
|||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
# simulate a review that was lapsed and is now due for its normal review
|
# simulate a review that was lapsed and is now due for its normal review
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 1
|
c.queue = 1
|
||||||
c.due = -1
|
c.due = -1
|
||||||
c.odue = -1
|
c.odue = -1
|
||||||
@ -492,7 +492,7 @@ def test_nextIvl():
|
|||||||
assert ni(c, 3) == 4 * 86400
|
assert ni(c, 3) == 4 * 86400
|
||||||
# lapsed cards
|
# lapsed cards
|
||||||
##################################################
|
##################################################
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.factor = STARTING_FACTOR
|
c.factor = STARTING_FACTOR
|
||||||
assert ni(c, 1) == 60
|
assert ni(c, 1) == 60
|
||||||
@ -500,7 +500,7 @@ def test_nextIvl():
|
|||||||
assert ni(c, 3) == 100 * 86400
|
assert ni(c, 3) == 100 * 86400
|
||||||
# review cards
|
# review cards
|
||||||
##################################################
|
##################################################
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.factor = STARTING_FACTOR
|
c.factor = STARTING_FACTOR
|
||||||
# failing it should put it at 60s
|
# failing it should put it at 60s
|
||||||
@ -551,20 +551,20 @@ def test_suspend():
|
|||||||
# should cope with rev cards being relearnt
|
# should cope with rev cards being relearnt
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.flush()
|
c.flush()
|
||||||
d.reset()
|
d.reset()
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.due >= time.time()
|
assert c.due >= time.time()
|
||||||
assert c.queue == QUEUE_TYPE_LRN
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 2
|
assert c.type == CARD_TYPE_REV
|
||||||
d.sched.suspendCards([c.id])
|
d.sched.suspendCards([c.id])
|
||||||
d.sched.unsuspendCards([c.id])
|
d.sched.unsuspendCards([c.id])
|
||||||
c.load()
|
c.load()
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
assert c.type == 2
|
assert c.type == CARD_TYPE_REV
|
||||||
assert c.due == 1
|
assert c.due == 1
|
||||||
# should cope with cards in cram decks
|
# should cope with cards in cram decks
|
||||||
c.due = 1
|
c.due = 1
|
||||||
@ -587,7 +587,8 @@ def test_cram():
|
|||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.type = c.queue = 2
|
c.queue = CARD_TYPE_REV
|
||||||
|
c.type = QUEUE_TYPE_REV
|
||||||
# due in 25 days, so it's been waiting 75 days
|
# due in 25 days, so it's been waiting 75 days
|
||||||
c.due = d.sched.today + 25
|
c.due = d.sched.today + 25
|
||||||
c.mod = 1
|
c.mod = 1
|
||||||
@ -634,7 +635,7 @@ def test_cram():
|
|||||||
d.sched.answerCard(c, 2)
|
d.sched.answerCard(c, 2)
|
||||||
assert c.ivl == 138
|
assert c.ivl == 138
|
||||||
assert c.due == 138
|
assert c.due == 138
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
# and it will have moved back to the previous deck
|
# and it will have moved back to the previous deck
|
||||||
assert c.did == 1
|
assert c.did == 1
|
||||||
# cram the deck again
|
# cram the deck again
|
||||||
@ -734,7 +735,8 @@ def test_cram_resched():
|
|||||||
assert c.type == CARD_TYPE_NEW and c.queue == QUEUE_TYPE_NEW
|
assert c.type == CARD_TYPE_NEW and c.queue == QUEUE_TYPE_NEW
|
||||||
# undue reviews should also be unaffected
|
# undue reviews should also be unaffected
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.type = c.queue = 2
|
c.queue = CARD_TYPE_REV
|
||||||
|
c.type = QUEUE_TYPE_REV
|
||||||
c.due = d.sched.today + 25
|
c.due = d.sched.today + 25
|
||||||
c.factor = STARTING_FACTOR
|
c.factor = STARTING_FACTOR
|
||||||
c.flush()
|
c.flush()
|
||||||
@ -911,8 +913,8 @@ def test_repCounts():
|
|||||||
f["Front"] = "three"
|
f["Front"] = "three"
|
||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = d.sched.today
|
c.due = d.sched.today
|
||||||
c.flush()
|
c.flush()
|
||||||
d.reset()
|
d.reset()
|
||||||
@ -929,8 +931,8 @@ def test_timing():
|
|||||||
f["Front"] = "num" + str(i)
|
f["Front"] = "num" + str(i)
|
||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.flush()
|
c.flush()
|
||||||
# fail the first one
|
# fail the first one
|
||||||
@ -941,7 +943,7 @@ def test_timing():
|
|||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
# the next card should be another review
|
# the next card should be another review
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
# but if we wait for a second, the failed card should come back
|
# but if we wait for a second, the failed card should come back
|
||||||
orig_time = time.time
|
orig_time = time.time
|
||||||
|
|
||||||
@ -982,7 +984,7 @@ def test_deckDue():
|
|||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
# make it a review card
|
# make it a review card
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.flush()
|
c.flush()
|
||||||
# add one more with a new deck
|
# add one more with a new deck
|
||||||
@ -1100,8 +1102,8 @@ def test_forget():
|
|||||||
f["Front"] = "one"
|
f["Front"] = "one"
|
||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.flush()
|
c.flush()
|
||||||
@ -1122,7 +1124,7 @@ def test_resched():
|
|||||||
c.load()
|
c.load()
|
||||||
assert c.due == d.sched.today
|
assert c.due == d.sched.today
|
||||||
assert c.ivl == 1
|
assert c.ivl == 1
|
||||||
assert c.queue == c.type == 2
|
assert c.queue == CARD_TYPE_REV and c.type == QUEUE_TYPE_REV
|
||||||
d.sched.reschedCards([c.id], 1, 1)
|
d.sched.reschedCards([c.id], 1, 1)
|
||||||
c.load()
|
c.load()
|
||||||
assert c.due == d.sched.today + 1
|
assert c.due == d.sched.today + 1
|
||||||
@ -1136,8 +1138,8 @@ def test_norelearn():
|
|||||||
f["Front"] = "one"
|
f["Front"] = "one"
|
||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.factor = STARTING_FACTOR
|
c.factor = STARTING_FACTOR
|
||||||
c.reps = 3
|
c.reps = 3
|
||||||
@ -1158,8 +1160,8 @@ def test_failmult():
|
|||||||
f["Back"] = "two"
|
f["Back"] = "two"
|
||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.due = d.sched.today - c.ivl
|
c.due = d.sched.today - c.ivl
|
||||||
c.factor = STARTING_FACTOR
|
c.factor = STARTING_FACTOR
|
||||||
|
@ -179,8 +179,8 @@ def test_learn():
|
|||||||
assert c.queue == QUEUE_TYPE_LRN
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == CARD_TYPE_LRN
|
assert c.type == CARD_TYPE_LRN
|
||||||
d.sched.answerCard(c, 3)
|
d.sched.answerCard(c, 3)
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
assert c.type == 2
|
assert c.type == CARD_TYPE_REV
|
||||||
# should be due tomorrow, with an interval of 1
|
# should be due tomorrow, with an interval of 1
|
||||||
assert c.due == d.sched.today + 1
|
assert c.due == d.sched.today + 1
|
||||||
assert c.ivl == 1
|
assert c.ivl == 1
|
||||||
@ -188,8 +188,8 @@ def test_learn():
|
|||||||
c.type = 0
|
c.type = 0
|
||||||
c.queue = 1
|
c.queue = 1
|
||||||
d.sched.answerCard(c, 4)
|
d.sched.answerCard(c, 4)
|
||||||
assert c.type == 2
|
assert c.type == CARD_TYPE_REV
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
assert checkRevIvl(d, c, 4)
|
assert checkRevIvl(d, c, 4)
|
||||||
# revlog should have been updated each time
|
# revlog should have been updated each time
|
||||||
assert d.db.scalar("select count() from revlog where type = 0") == 5
|
assert d.db.scalar("select count() from revlog where type = 0") == 5
|
||||||
@ -203,7 +203,8 @@ def test_relearn():
|
|||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.due = d.sched.today
|
c.due = d.sched.today
|
||||||
c.type = c.queue = 2
|
c.queue = CARD_TYPE_REV
|
||||||
|
c.type = QUEUE_TYPE_REV
|
||||||
c.flush()
|
c.flush()
|
||||||
|
|
||||||
# fail the card
|
# fail the card
|
||||||
@ -216,7 +217,7 @@ def test_relearn():
|
|||||||
|
|
||||||
# immediately graduate it
|
# immediately graduate it
|
||||||
d.sched.answerCard(c, 4)
|
d.sched.answerCard(c, 4)
|
||||||
assert c.queue == c.type == 2
|
assert c.queue == CARD_TYPE_REV and c.type == QUEUE_TYPE_REV
|
||||||
assert c.ivl == 2
|
assert c.ivl == 2
|
||||||
assert c.due == d.sched.today + c.ivl
|
assert c.due == d.sched.today + c.ivl
|
||||||
|
|
||||||
@ -229,7 +230,8 @@ def test_relearn_no_steps():
|
|||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.due = d.sched.today
|
c.due = d.sched.today
|
||||||
c.type = c.queue = 2
|
c.queue = CARD_TYPE_REV
|
||||||
|
c.type = QUEUE_TYPE_REV
|
||||||
c.flush()
|
c.flush()
|
||||||
|
|
||||||
conf = d.decks.confForDid(1)
|
conf = d.decks.confForDid(1)
|
||||||
@ -240,7 +242,7 @@ def test_relearn_no_steps():
|
|||||||
d.reset()
|
d.reset()
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.type == c.queue == 2
|
assert c.queue == CARD_TYPE_REV and c.type == QUEUE_TYPE_REV
|
||||||
|
|
||||||
|
|
||||||
def test_learn_collapsed():
|
def test_learn_collapsed():
|
||||||
@ -315,7 +317,7 @@ def test_learn_day():
|
|||||||
# the last pass should graduate it into a review card
|
# the last pass should graduate it into a review card
|
||||||
assert ni(c, 3) == 86400
|
assert ni(c, 3) == 86400
|
||||||
d.sched.answerCard(c, 3)
|
d.sched.answerCard(c, 3)
|
||||||
assert c.queue == c.type == 2
|
assert c.queue == CARD_TYPE_REV and c.type == QUEUE_TYPE_REV
|
||||||
# if the lapse step is tomorrow, failing it should handle the counts
|
# if the lapse step is tomorrow, failing it should handle the counts
|
||||||
# correctly
|
# correctly
|
||||||
c.due = 0
|
c.due = 0
|
||||||
@ -338,8 +340,8 @@ def test_reviews():
|
|||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
# set the card up as a review card, due 8 days ago
|
# set the card up as a review card, due 8 days ago
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = d.sched.today - 8
|
c.due = d.sched.today - 8
|
||||||
c.factor = STARTING_FACTOR
|
c.factor = STARTING_FACTOR
|
||||||
c.reps = 3
|
c.reps = 3
|
||||||
@ -355,7 +357,7 @@ def test_reviews():
|
|||||||
c.flush()
|
c.flush()
|
||||||
d.reset()
|
d.reset()
|
||||||
d.sched.answerCard(c, 2)
|
d.sched.answerCard(c, 2)
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
# the new interval should be (100) * 1.2 = 120
|
# the new interval should be (100) * 1.2 = 120
|
||||||
assert checkRevIvl(d, c, 120)
|
assert checkRevIvl(d, c, 120)
|
||||||
assert c.due == d.sched.today + c.ivl
|
assert c.due == d.sched.today + c.ivl
|
||||||
@ -432,7 +434,8 @@ def test_review_limits():
|
|||||||
|
|
||||||
# make them reviews
|
# make them reviews
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.queue = c.type = 2
|
c.queue = CARD_TYPE_REV
|
||||||
|
c.type = QUEUE_TYPE_REV
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.flush()
|
c.flush()
|
||||||
|
|
||||||
@ -474,8 +477,8 @@ def test_button_spacing():
|
|||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
# 1 day ivl review card due now
|
# 1 day ivl review card due now
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = d.sched.today
|
c.due = d.sched.today
|
||||||
c.reps = 1
|
c.reps = 1
|
||||||
c.ivl = 1
|
c.ivl = 1
|
||||||
@ -503,7 +506,7 @@ def test_overdue_lapse():
|
|||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
# simulate a review that was lapsed and is now due for its normal review
|
# simulate a review that was lapsed and is now due for its normal review
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 1
|
c.queue = 1
|
||||||
c.due = -1
|
c.due = -1
|
||||||
c.odue = -1
|
c.odue = -1
|
||||||
@ -586,7 +589,7 @@ def test_nextIvl():
|
|||||||
assert ni(c, 4) == 4 * 86400
|
assert ni(c, 4) == 4 * 86400
|
||||||
# lapsed cards
|
# lapsed cards
|
||||||
##################################################
|
##################################################
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.factor = STARTING_FACTOR
|
c.factor = STARTING_FACTOR
|
||||||
assert ni(c, 1) == 60
|
assert ni(c, 1) == 60
|
||||||
@ -594,7 +597,7 @@ def test_nextIvl():
|
|||||||
assert ni(c, 4) == 101 * 86400
|
assert ni(c, 4) == 101 * 86400
|
||||||
# review cards
|
# review cards
|
||||||
##################################################
|
##################################################
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.factor = STARTING_FACTOR
|
c.factor = STARTING_FACTOR
|
||||||
# failing it should put it at 60s
|
# failing it should put it at 60s
|
||||||
@ -671,8 +674,8 @@ def test_suspend():
|
|||||||
# should cope with rev cards being relearnt
|
# should cope with rev cards being relearnt
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.flush()
|
c.flush()
|
||||||
d.reset()
|
d.reset()
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
@ -709,7 +712,8 @@ def test_filt_reviewing_early_normal():
|
|||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.type = c.queue = 2
|
c.queue = CARD_TYPE_REV
|
||||||
|
c.type = QUEUE_TYPE_REV
|
||||||
# due in 25 days, so it's been waiting 75 days
|
# due in 25 days, so it's been waiting 75 days
|
||||||
c.due = d.sched.today + 25
|
c.due = d.sched.today + 25
|
||||||
c.mod = 1
|
c.mod = 1
|
||||||
@ -740,7 +744,7 @@ def test_filt_reviewing_early_normal():
|
|||||||
assert c.due == d.sched.today + c.ivl
|
assert c.due == d.sched.today + c.ivl
|
||||||
assert not c.odue
|
assert not c.odue
|
||||||
# should not be in learning
|
# should not be in learning
|
||||||
assert c.queue == 2
|
assert c.queue == QUEUE_TYPE_REV
|
||||||
# should be logged as a cram rep
|
# should be logged as a cram rep
|
||||||
assert d.db.scalar("select type from revlog order by id desc limit 1") == 3
|
assert d.db.scalar("select type from revlog order by id desc limit 1") == 3
|
||||||
|
|
||||||
@ -943,8 +947,8 @@ def test_repCounts():
|
|||||||
f["Front"] = "three"
|
f["Front"] = "three"
|
||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = d.sched.today
|
c.due = d.sched.today
|
||||||
c.flush()
|
c.flush()
|
||||||
d.reset()
|
d.reset()
|
||||||
@ -961,8 +965,8 @@ def test_timing():
|
|||||||
f["Front"] = "num" + str(i)
|
f["Front"] = "num" + str(i)
|
||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.flush()
|
c.flush()
|
||||||
# fail the first one
|
# fail the first one
|
||||||
@ -971,7 +975,7 @@ def test_timing():
|
|||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
# the next card should be another review
|
# the next card should be another review
|
||||||
c2 = d.sched.getCard()
|
c2 = d.sched.getCard()
|
||||||
assert c2.queue == 2
|
assert c2.queue == QUEUE_TYPE_REV
|
||||||
# if the failed card becomes due, it should show first
|
# if the failed card becomes due, it should show first
|
||||||
c.due = time.time() - 1
|
c.due = time.time() - 1
|
||||||
c.flush()
|
c.flush()
|
||||||
@ -1008,7 +1012,7 @@ def test_deckDue():
|
|||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
# make it a review card
|
# make it a review card
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.flush()
|
c.flush()
|
||||||
# add one more with a new deck
|
# add one more with a new deck
|
||||||
@ -1126,8 +1130,8 @@ def test_forget():
|
|||||||
f["Front"] = "one"
|
f["Front"] = "one"
|
||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.flush()
|
c.flush()
|
||||||
@ -1148,7 +1152,7 @@ def test_resched():
|
|||||||
c.load()
|
c.load()
|
||||||
assert c.due == d.sched.today
|
assert c.due == d.sched.today
|
||||||
assert c.ivl == 1
|
assert c.ivl == 1
|
||||||
assert c.queue == c.type == 2
|
assert c.queue == QUEUE_TYPE_REV and c.type == CARD_TYPE_REV
|
||||||
d.sched.reschedCards([c.id], 1, 1)
|
d.sched.reschedCards([c.id], 1, 1)
|
||||||
c.load()
|
c.load()
|
||||||
assert c.due == d.sched.today + 1
|
assert c.due == d.sched.today + 1
|
||||||
@ -1162,8 +1166,8 @@ def test_norelearn():
|
|||||||
f["Front"] = "one"
|
f["Front"] = "one"
|
||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.due = 0
|
c.due = 0
|
||||||
c.factor = STARTING_FACTOR
|
c.factor = STARTING_FACTOR
|
||||||
c.reps = 3
|
c.reps = 3
|
||||||
@ -1184,8 +1188,8 @@ def test_failmult():
|
|||||||
f["Back"] = "two"
|
f["Back"] = "two"
|
||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.type = 2
|
c.type = CARD_TYPE_REV
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.ivl = 100
|
c.ivl = 100
|
||||||
c.due = d.sched.today - c.ivl
|
c.due = d.sched.today - c.ivl
|
||||||
c.factor = STARTING_FACTOR
|
c.factor = STARTING_FACTOR
|
||||||
@ -1269,7 +1273,7 @@ def test_negativeDueFilter():
|
|||||||
d.addNote(f)
|
d.addNote(f)
|
||||||
c = f.cards()[0]
|
c = f.cards()[0]
|
||||||
c.due = -5
|
c.due = -5
|
||||||
c.queue = 2
|
c.queue = QUEUE_TYPE_REV
|
||||||
c.ivl = 5
|
c.ivl = 5
|
||||||
c.flush()
|
c.flush()
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ class DataModel(QAbstractTableModel):
|
|||||||
date = c.due
|
date = c.due
|
||||||
elif c.queue == QUEUE_TYPE_NEW or c.type == CARD_TYPE_NEW:
|
elif c.queue == QUEUE_TYPE_NEW or c.type == CARD_TYPE_NEW:
|
||||||
return str(c.due)
|
return str(c.due)
|
||||||
elif c.queue in (2, 3) or (c.type == 2 and c.queue < 0):
|
elif c.queue in (QUEUE_TYPE_REV, 3) or (c.type == CARD_TYPE_REV and c.queue < 0):
|
||||||
date = time.time() + ((c.due - self.col.sched.today) * 86400)
|
date = time.time() + ((c.due - self.col.sched.today) * 86400)
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
Loading…
Reference in New Issue
Block a user