CARD_TYPE_LRN and QUEUE_TYPE_LRN
This commit is contained in:
parent
a1cc0787d2
commit
69436643fe
@ -16,9 +16,11 @@ NEW_CARDS_DUE = 1
|
|||||||
|
|
||||||
# Queue types
|
# Queue types
|
||||||
QUEUE_TYPE_NEW = 0
|
QUEUE_TYPE_NEW = 0
|
||||||
|
QUEUE_TYPE_LRN = 1
|
||||||
|
|
||||||
# Card types
|
# Card types
|
||||||
CARD_TYPE_NEW = 0
|
CARD_TYPE_NEW = 0
|
||||||
|
CARD_TYPE_LRN = 1
|
||||||
|
|
||||||
# removal types
|
# removal types
|
||||||
REM_CARD = 0
|
REM_CARD = 0
|
||||||
|
@ -273,16 +273,16 @@ select distinct(n.id) from cards c, notes n where c.nid=n.id and """
|
|||||||
elif val == "new":
|
elif val == "new":
|
||||||
n = CARD_TYPE_NEW
|
n = CARD_TYPE_NEW
|
||||||
else:
|
else:
|
||||||
return "queue in (1, 3)"
|
return f"queue in ({QUEUE_TYPE_LRN}, 3)"
|
||||||
return "type = %d" % n
|
return "type = %d" % n
|
||||||
elif val == "suspended":
|
elif val == "suspended":
|
||||||
return "c.queue = -1"
|
return "c.queue = -1"
|
||||||
elif val == "buried":
|
elif val == "buried":
|
||||||
return "c.queue in (-2, -3)"
|
return "c.queue in (-2, -3)"
|
||||||
elif val == "due":
|
elif val == "due":
|
||||||
return """
|
return f"""
|
||||||
(c.queue in (2,3) and c.due <= %d) or
|
(c.queue in (2,3) and c.due <= %d) or
|
||||||
(c.queue = 1 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,
|
||||||
)
|
)
|
||||||
|
@ -357,12 +357,12 @@ class Anki2Importer(Importer):
|
|||||||
card[8] = card[14]
|
card[8] = card[14]
|
||||||
card[14] = 0
|
card[14] = 0
|
||||||
# queue
|
# queue
|
||||||
if card[6] == 1: # type
|
if card[6] == CARD_TYPE_LRN: # type
|
||||||
card[7] = QUEUE_TYPE_NEW
|
card[7] = QUEUE_TYPE_NEW
|
||||||
else:
|
else:
|
||||||
card[7] = card[6]
|
card[7] = card[6]
|
||||||
# type
|
# type
|
||||||
if card[6] == 1:
|
if card[6] == CARD_TYPE_LRN:
|
||||||
card[6] = CARD_TYPE_NEW
|
card[6] = CARD_TYPE_NEW
|
||||||
cards.append(card)
|
cards.append(card)
|
||||||
# we need to import revlog, rewriting card ids and bumping usn
|
# we need to import revlog, rewriting card ids and bumping usn
|
||||||
|
@ -71,10 +71,10 @@ class Scheduler:
|
|||||||
wasNewQ = card.queue == QUEUE_TYPE_NEW
|
wasNewQ = card.queue == QUEUE_TYPE_NEW
|
||||||
if wasNewQ:
|
if wasNewQ:
|
||||||
# came from the new queue, move to learning
|
# came from the new queue, move to learning
|
||||||
card.queue = 1
|
card.queue = QUEUE_TYPE_LRN
|
||||||
# if it was a new card, it's now a learning card
|
# if it was a new card, it's now a learning card
|
||||||
if card.type == CARD_TYPE_NEW:
|
if card.type == CARD_TYPE_NEW:
|
||||||
card.type = 1
|
card.type = CARD_TYPE_LRN
|
||||||
# init reps to graduation
|
# init reps to graduation
|
||||||
card.left = self._startingLeft(card)
|
card.left = self._startingLeft(card)
|
||||||
# dynamic?
|
# dynamic?
|
||||||
@ -84,7 +84,7 @@ class Scheduler:
|
|||||||
card.ivl = self._dynIvlBoost(card)
|
card.ivl = self._dynIvlBoost(card)
|
||||||
card.odue = self.today + card.ivl
|
card.odue = self.today + card.ivl
|
||||||
self._updateStats(card, "new")
|
self._updateStats(card, "new")
|
||||||
if card.queue in (1, 3):
|
if card.queue in (QUEUE_TYPE_LRN, 3):
|
||||||
self._answerLrnCard(card, ease)
|
self._answerLrnCard(card, ease)
|
||||||
if not wasNewQ:
|
if not wasNewQ:
|
||||||
self._updateStats(card, "lrn")
|
self._updateStats(card, "lrn")
|
||||||
@ -142,7 +142,7 @@ order by due"""
|
|||||||
if card.odid and card.queue == 2:
|
if card.odid and card.queue == 2:
|
||||||
return 4
|
return 4
|
||||||
conf = self._lrnConf(card)
|
conf = self._lrnConf(card)
|
||||||
if card.type in (CARD_TYPE_NEW, 1) 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 == 2:
|
||||||
@ -466,9 +466,9 @@ select id from cards where did in %s and queue = {QUEUE_TYPE_NEW} limit ?)"""
|
|||||||
# sub-day
|
# sub-day
|
||||||
self.lrnCount = (
|
self.lrnCount = (
|
||||||
self.col.db.scalar(
|
self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select sum(left/1000) from (select left from cards where
|
select sum(left/1000) from (select left from cards where
|
||||||
did in %s and queue = 1 and due < ? limit %d)"""
|
did in %s and queue = {QUEUE_TYPE_LRN} and due < ? limit %d)"""
|
||||||
% (self._deckLimit(), self.reportLimit),
|
% (self._deckLimit(), self.reportLimit),
|
||||||
self.dayCutoff,
|
self.dayCutoff,
|
||||||
)
|
)
|
||||||
@ -496,9 +496,9 @@ and due <= ? limit %d"""
|
|||||||
if self._lrnQueue:
|
if self._lrnQueue:
|
||||||
return True
|
return True
|
||||||
self._lrnQueue = self.col.db.all(
|
self._lrnQueue = self.col.db.all(
|
||||||
"""
|
f"""
|
||||||
select due, id from cards where
|
select due, id from cards where
|
||||||
did in %s and queue = 1 and due < :lim
|
did in %s and queue = {QUEUE_TYPE_LRN} and due < :lim
|
||||||
limit %d"""
|
limit %d"""
|
||||||
% (self._deckLimit(), self.reportLimit),
|
% (self._deckLimit(), self.reportLimit),
|
||||||
lim=self.dayCutoff,
|
lim=self.dayCutoff,
|
||||||
@ -601,7 +601,7 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
|||||||
# if the queue is not empty and there's nothing else to do, make
|
# if the queue is not empty and there's nothing else to do, make
|
||||||
# sure we don't put it at the head of the queue and end up showing
|
# sure we don't put it at the head of the queue and end up showing
|
||||||
# it twice in a row
|
# it twice in a row
|
||||||
card.queue = 1
|
card.queue = QUEUE_TYPE_LRN
|
||||||
if self._lrnQueue and not self.revCount and not self.newCount:
|
if self._lrnQueue and not self.revCount and not self.newCount:
|
||||||
smallestDue = self._lrnQueue[0][0]
|
smallestDue = self._lrnQueue[0][0]
|
||||||
card.due = max(card.due, smallestDue + 1)
|
card.due = max(card.due, smallestDue + 1)
|
||||||
@ -736,25 +736,25 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
|||||||
extra = " and did in " + ids2str(self.col.decks.allIds())
|
extra = " and did in " + ids2str(self.col.decks.allIds())
|
||||||
# review cards in relearning
|
# review cards in relearning
|
||||||
self.col.db.execute(
|
self.col.db.execute(
|
||||||
"""
|
f"""
|
||||||
update cards set
|
update cards set
|
||||||
due = odue, queue = 2, mod = %d, usn = %d, odue = 0
|
due = odue, queue = 2, mod = %d, usn = %d, odue = 0
|
||||||
where queue in (1,3) and type = 2
|
where queue in ({QUEUE_TYPE_LRN},3) and type = 2
|
||||||
%s
|
%s
|
||||||
"""
|
"""
|
||||||
% (intTime(), self.col.usn(), extra)
|
% (intTime(), self.col.usn(), extra)
|
||||||
)
|
)
|
||||||
# new cards in learning
|
# new cards in learning
|
||||||
self.forgetCards(
|
self.forgetCards(
|
||||||
self.col.db.list("select id from cards where queue in (1,3) %s" % extra)
|
self.col.db.list(f"select id from cards where queue in ({QUEUE_TYPE_LRN},3) %s" % extra)
|
||||||
)
|
)
|
||||||
|
|
||||||
def _lrnForDeck(self, did):
|
def _lrnForDeck(self, did):
|
||||||
cnt = (
|
cnt = (
|
||||||
self.col.db.scalar(
|
self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select sum(left/1000) from
|
select sum(left/1000) from
|
||||||
(select left from cards where did = ? and queue = 1 and due < ? limit ?)""",
|
(select left from cards where did = ? and queue = {QUEUE_TYPE_LRN} and due < ? limit ?)""",
|
||||||
did,
|
did,
|
||||||
intTime() + self.col.conf["collapseTime"],
|
intTime() + self.col.conf["collapseTime"],
|
||||||
self.reportLimit,
|
self.reportLimit,
|
||||||
@ -907,7 +907,7 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)"""
|
|||||||
# queue 1
|
# queue 1
|
||||||
if card.due < self.dayCutoff:
|
if card.due < self.dayCutoff:
|
||||||
self.lrnCount += card.left // 1000
|
self.lrnCount += card.left // 1000
|
||||||
card.queue = 1
|
card.queue = QUEUE_TYPE_LRN
|
||||||
heappush(self._lrnQueue, (card.due, card.id))
|
heappush(self._lrnQueue, (card.due, card.id))
|
||||||
else:
|
else:
|
||||||
# day learn queue
|
# day learn queue
|
||||||
@ -1059,8 +1059,8 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)"""
|
|||||||
# move out of cram queue
|
# move out of cram queue
|
||||||
self.col.db.execute(
|
self.col.db.execute(
|
||||||
f"""
|
f"""
|
||||||
update cards set did = odid, queue = (case when type = 1 then {QUEUE_TYPE_NEW}
|
update cards set did = odid, queue = (case when type = {CARD_TYPE_LRN} then {QUEUE_TYPE_NEW}
|
||||||
else type end), type = (case when type = 1 then {CARD_TYPE_NEW} else type end),
|
else type end), type = (case when type = {CARD_TYPE_LRN} then {CARD_TYPE_NEW} else type end),
|
||||||
due = odue, odue = 0, odid = 0, usn = ? where %s"""
|
due = odue, odue = 0, odid = 0, usn = ? where %s"""
|
||||||
% lim,
|
% lim,
|
||||||
self.col.usn(),
|
self.col.usn(),
|
||||||
@ -1347,7 +1347,7 @@ To study outside of the normal schedule, click the Custom Study button below."""
|
|||||||
|
|
||||||
def nextIvl(self, card, ease):
|
def nextIvl(self, card, ease):
|
||||||
"Return the next interval for CARD, in seconds."
|
"Return the next interval for CARD, in seconds."
|
||||||
if card.queue in (QUEUE_TYPE_NEW, 1, 3):
|
if card.queue in (QUEUE_TYPE_NEW, QUEUE_TYPE_LRN, 3):
|
||||||
return self._nextLrnIvl(card, ease)
|
return self._nextLrnIvl(card, ease)
|
||||||
elif ease == BUTTON_ONE:
|
elif ease == BUTTON_ONE:
|
||||||
# lapsed
|
# lapsed
|
||||||
|
@ -97,14 +97,14 @@ class Scheduler:
|
|||||||
|
|
||||||
if card.queue == QUEUE_TYPE_NEW:
|
if card.queue == QUEUE_TYPE_NEW:
|
||||||
# came from the new queue, move to learning
|
# came from the new queue, move to learning
|
||||||
card.queue = 1
|
card.queue = QUEUE_TYPE_LRN
|
||||||
card.type = 1
|
card.type = CARD_TYPE_LRN
|
||||||
# init reps to graduation
|
# init reps to graduation
|
||||||
card.left = self._startingLeft(card)
|
card.left = self._startingLeft(card)
|
||||||
# update daily limit
|
# update daily limit
|
||||||
self._updateStats(card, "new")
|
self._updateStats(card, "new")
|
||||||
|
|
||||||
if card.queue in (1, 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 == 2:
|
||||||
self._answerRevCard(card, ease)
|
self._answerRevCard(card, ease)
|
||||||
@ -505,8 +505,8 @@ select id from cards where did in %s and queue = {QUEUE_TYPE_NEW} limit ?)"""
|
|||||||
# sub-day
|
# sub-day
|
||||||
self.lrnCount = (
|
self.lrnCount = (
|
||||||
self.col.db.scalar(
|
self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from cards where did in %s and queue = 1
|
select count() from cards where did in %s and queue = {QUEUE_TYPE_LRN}
|
||||||
and due < ?"""
|
and due < ?"""
|
||||||
% (self._deckLimit()),
|
% (self._deckLimit()),
|
||||||
self._lrnCutoff,
|
self._lrnCutoff,
|
||||||
@ -546,7 +546,7 @@ select count() from cards where did in %s and queue = {QUEUE_TYPE_PREVIEW}
|
|||||||
self._lrnQueue = self.col.db.all(
|
self._lrnQueue = self.col.db.all(
|
||||||
f"""
|
f"""
|
||||||
select due, id from cards where
|
select due, id from cards where
|
||||||
did in %s and queue in (1,{QUEUE_TYPE_PREVIEW}) and due < :lim
|
did in %s and queue in ({QUEUE_TYPE_LRN},{QUEUE_TYPE_PREVIEW}) and due < :lim
|
||||||
limit %d"""
|
limit %d"""
|
||||||
% (self._deckLimit(), self.reportLimit),
|
% (self._deckLimit(), self.reportLimit),
|
||||||
lim=cutoff,
|
lim=cutoff,
|
||||||
@ -674,7 +674,7 @@ did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
|
|||||||
maxExtra = min(300, int(delay * 0.25))
|
maxExtra = min(300, int(delay * 0.25))
|
||||||
fuzz = random.randrange(0, maxExtra)
|
fuzz = random.randrange(0, maxExtra)
|
||||||
card.due = min(self.dayCutoff - 1, card.due + fuzz)
|
card.due = min(self.dayCutoff - 1, card.due + fuzz)
|
||||||
card.queue = 1
|
card.queue = QUEUE_TYPE_LRN
|
||||||
if card.due < (intTime() + self.col.conf["collapseTime"]):
|
if card.due < (intTime() + self.col.conf["collapseTime"]):
|
||||||
self.lrnCount += 1
|
self.lrnCount += 1
|
||||||
# if the queue is not empty and there's nothing else to do, make
|
# if the queue is not empty and there's nothing else to do, make
|
||||||
@ -831,9 +831,9 @@ did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
|
|||||||
def _lrnForDeck(self, did: int) -> Any:
|
def _lrnForDeck(self, did: int) -> Any:
|
||||||
cnt = (
|
cnt = (
|
||||||
self.col.db.scalar(
|
self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from
|
select count() from
|
||||||
(select null from cards where did = ? and queue = 1 and due < ? limit ?)""",
|
(select null from cards where did = ? and queue = {QUEUE_TYPE_LRN} and due < ? limit ?)""",
|
||||||
did,
|
did,
|
||||||
intTime() + self.col.conf["collapseTime"],
|
intTime() + self.col.conf["collapseTime"],
|
||||||
self.reportLimit,
|
self.reportLimit,
|
||||||
@ -1261,9 +1261,9 @@ where id = ?
|
|||||||
|
|
||||||
# learning and relearning cards may be seconds-based or day-based;
|
# learning and relearning cards may be seconds-based or day-based;
|
||||||
# other types map directly to queues
|
# other types map directly to queues
|
||||||
if card.type in (1, CARD_TYPE_RELEARNING):
|
if card.type in (CARD_TYPE_LRN, CARD_TYPE_RELEARNING):
|
||||||
if card.odue > 1000000000:
|
if card.odue > 1000000000:
|
||||||
card.queue = 1
|
card.queue = QUEUE_TYPE_LRN
|
||||||
else:
|
else:
|
||||||
card.queue = QUEUE_TYPE_DAY_LEARN_RELEARN
|
card.queue = QUEUE_TYPE_DAY_LEARN_RELEARN
|
||||||
else:
|
else:
|
||||||
@ -1563,7 +1563,7 @@ To study outside of the normal schedule, click the Custom Study button below."""
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
# (re)learning?
|
# (re)learning?
|
||||||
if card.queue in (QUEUE_TYPE_NEW, 1, QUEUE_TYPE_DAY_LEARN_RELEARN):
|
if card.queue in (QUEUE_TYPE_NEW, QUEUE_TYPE_LRN, QUEUE_TYPE_DAY_LEARN_RELEARN):
|
||||||
return self._nextLrnIvl(card, ease)
|
return self._nextLrnIvl(card, ease)
|
||||||
elif ease == BUTTON_ONE:
|
elif ease == BUTTON_ONE:
|
||||||
# lapse
|
# lapse
|
||||||
@ -1605,7 +1605,7 @@ To study outside of the normal schedule, click the Custom Study button below."""
|
|||||||
# learning and relearning cards may be seconds-based or day-based;
|
# learning and relearning cards may be seconds-based or day-based;
|
||||||
# other types map directly to queues
|
# other types map directly to queues
|
||||||
_restoreQueueSnippet = f"""
|
_restoreQueueSnippet = f"""
|
||||||
queue = (case when type in (1,{CARD_TYPE_RELEARNING}) then
|
queue = (case when type in ({CARD_TYPE_LRN},{CARD_TYPE_RELEARNING}) then
|
||||||
(case when (case when odue then odue else due end) > 1000000000 then 1 else
|
(case when (case when odue then odue else due end) > 1000000000 then 1 else
|
||||||
{QUEUE_TYPE_DAY_LEARN_RELEARN} end)
|
{QUEUE_TYPE_DAY_LEARN_RELEARN} end)
|
||||||
else
|
else
|
||||||
@ -1875,10 +1875,10 @@ and due >= ? and queue = {QUEUE_TYPE_NEW}"""
|
|||||||
self.col.db.execute(
|
self.col.db.execute(
|
||||||
f"""
|
f"""
|
||||||
update cards set did = odid, queue = (case
|
update cards set did = odid, queue = (case
|
||||||
when type = 1 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 2
|
||||||
else type end), type = (case
|
else type end), type = (case
|
||||||
when type = 1 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 2
|
||||||
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""",
|
||||||
@ -1892,7 +1892,7 @@ due = odue, odue = 0, odid = 0, usn = ? where odid != 0""",
|
|||||||
f"""
|
f"""
|
||||||
update cards set
|
update cards set
|
||||||
due = odue, queue = 2, type = 2, mod = %d, usn = %d, odue = 0
|
due = odue, queue = 2, type = 2, mod = %d, usn = %d, odue = 0
|
||||||
where queue in (1,{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 (2, {CARD_TYPE_RELEARNING})
|
||||||
"""
|
"""
|
||||||
% (intTime(), self.col.usn())
|
% (intTime(), self.col.usn())
|
||||||
)
|
)
|
||||||
@ -1901,14 +1901,14 @@ due = odue, odue = 0, odid = 0, usn = ? where odid != 0""",
|
|||||||
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 = 2, type = 2, mod = %d, usn = %d, odue = 0
|
||||||
where queue in (1,{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 (2, {CARD_TYPE_RELEARNING})
|
||||||
"""
|
"""
|
||||||
% (self.today, intTime(), self.col.usn())
|
% (self.today, intTime(), self.col.usn())
|
||||||
)
|
)
|
||||||
# remove new cards from learning
|
# remove new cards from learning
|
||||||
self.forgetCards(
|
self.forgetCards(
|
||||||
self.col.db.list(
|
self.col.db.list(
|
||||||
f"select id from cards where queue in (1,{QUEUE_TYPE_DAY_LEARN_RELEARN})"
|
f"select id from cards where queue in ({QUEUE_TYPE_LRN},{QUEUE_TYPE_DAY_LEARN_RELEARN})"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1917,7 +1917,7 @@ due = odue, odue = 0, odid = 0, usn = ? where odid != 0""",
|
|||||||
self.col.db.execute(
|
self.col.db.execute(
|
||||||
f"""
|
f"""
|
||||||
update cards set type = (case
|
update cards set type = (case
|
||||||
when type = 1 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 (2, {CARD_TYPE_RELEARNING}) then 2
|
||||||
else type end),
|
else type end),
|
||||||
due = (case when odue then odue else due end),
|
due = (case when odue then odue else due end),
|
||||||
|
@ -35,7 +35,7 @@ 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 (1, 2):
|
if c.type in (CARD_TYPE_LRN, 2):
|
||||||
if c.odid or c.queue < QUEUE_TYPE_NEW:
|
if c.odid or c.queue < QUEUE_TYPE_NEW:
|
||||||
next = None
|
next = None
|
||||||
else:
|
else:
|
||||||
@ -676,7 +676,7 @@ select count(), avg(ivl), max(ivl) from cards where did in %s and queue = 2"""
|
|||||||
types = ("lrn", "yng", "mtr")
|
types = ("lrn", "yng", "mtr")
|
||||||
eases = self._eases()
|
eases = self._eases()
|
||||||
for (type, ease, cnt) in eases:
|
for (type, ease, cnt) in eases:
|
||||||
if type == 1:
|
if type == CARD_TYPE_LRN:
|
||||||
ease += 5
|
ease += 5
|
||||||
elif type == 2:
|
elif type == 2:
|
||||||
ease += 10
|
ease += 10
|
||||||
@ -944,7 +944,7 @@ from cards where did in %s and queue = 2"""
|
|||||||
f"""
|
f"""
|
||||||
select
|
select
|
||||||
sum(case when queue=2 and ivl >= 21 then 1 else 0 end), -- mtr
|
sum(case when queue=2 and ivl >= 21 then 1 else 0 end), -- mtr
|
||||||
sum(case when queue in (1,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=2 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"""
|
||||||
|
@ -51,8 +51,8 @@ def test_new():
|
|||||||
# if we answer it, it should become a learn card
|
# if we answer it, it should become a learn card
|
||||||
t = intTime()
|
t = intTime()
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 1
|
assert c.type == CARD_TYPE_LRN
|
||||||
assert c.due >= t
|
assert c.due >= t
|
||||||
|
|
||||||
# disabled for now, as the learn fudging makes this randomly fail
|
# disabled for now, as the learn fudging makes this randomly fail
|
||||||
@ -163,8 +163,8 @@ def test_learn():
|
|||||||
assert c.left % 1000 == 1
|
assert c.left % 1000 == 1
|
||||||
assert c.left // 1000 == 1
|
assert c.left // 1000 == 1
|
||||||
# the next pass should graduate the card
|
# the next pass should graduate the card
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 1
|
assert c.type == CARD_TYPE_LRN
|
||||||
d.sched.answerCard(c, 2)
|
d.sched.answerCard(c, 2)
|
||||||
assert c.queue == 2
|
assert c.queue == 2
|
||||||
assert c.type == 2
|
assert c.type == 2
|
||||||
@ -259,7 +259,7 @@ def test_learn_day():
|
|||||||
assert ni(c, 2) == 86400 * 2
|
assert ni(c, 2) == 86400 * 2
|
||||||
# if we fail it, it should be back in the correct queue
|
# if we fail it, it should be back in the correct queue
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
d.undo()
|
d.undo()
|
||||||
d.reset()
|
d.reset()
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
@ -311,7 +311,7 @@ def test_reviews():
|
|||||||
d.reset()
|
d.reset()
|
||||||
d.sched._cardConf(c)["lapse"]["delays"] = [2, 20]
|
d.sched._cardConf(c)["lapse"]["delays"] = [2, 20]
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
# it should be due tomorrow, with an interval of 1
|
# it should be due tomorrow, with an interval of 1
|
||||||
assert c.odue == d.sched.today + 1
|
assert c.odue == d.sched.today + 1
|
||||||
assert c.ivl == 1
|
assert c.ivl == 1
|
||||||
@ -558,7 +558,7 @@ def test_suspend():
|
|||||||
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 == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 2
|
assert c.type == 2
|
||||||
d.sched.suspendCards([c.id])
|
d.sched.suspendCards([c.id])
|
||||||
d.sched.unsuspendCards([c.id])
|
d.sched.unsuspendCards([c.id])
|
||||||
@ -622,7 +622,7 @@ def test_cram():
|
|||||||
# int(75*1.85) = 138
|
# int(75*1.85) = 138
|
||||||
assert c.ivl == 138
|
assert c.ivl == 138
|
||||||
assert c.odue == 138
|
assert c.odue == 138
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
# 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
|
||||||
# check ivls again
|
# check ivls again
|
||||||
@ -702,7 +702,7 @@ def test_cram_rem():
|
|||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
d.sched.answerCard(c, 2)
|
d.sched.answerCard(c, 2)
|
||||||
# answering the card will put it in the learning queue
|
# answering the card will put it in the learning queue
|
||||||
assert c.type == c.queue == 1
|
assert c.type == CARD_TYPE_LRN and c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.due != oldDue
|
assert c.due != oldDue
|
||||||
# if we terminate cramming prematurely it should be set back to new
|
# if we terminate cramming prematurely it should be set back to new
|
||||||
d.sched.emptyDyn(did)
|
d.sched.emptyDyn(did)
|
||||||
@ -950,7 +950,7 @@ def test_timing():
|
|||||||
|
|
||||||
time.time = adjusted_time
|
time.time = adjusted_time
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
time.time = orig_time
|
time.time = orig_time
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ def test_new():
|
|||||||
# if we answer it, it should become a learn card
|
# if we answer it, it should become a learn card
|
||||||
t = intTime()
|
t = intTime()
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 1
|
assert c.type == CARD_TYPE_LRN
|
||||||
assert c.due >= t
|
assert c.due >= t
|
||||||
|
|
||||||
# disabled for now, as the learn fudging makes this randomly fail
|
# disabled for now, as the learn fudging makes this randomly fail
|
||||||
@ -176,8 +176,8 @@ def test_learn():
|
|||||||
assert c.left % 1000 == 1
|
assert c.left % 1000 == 1
|
||||||
assert c.left // 1000 == 1
|
assert c.left // 1000 == 1
|
||||||
# the next pass should graduate the card
|
# the next pass should graduate the card
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 1
|
assert c.type == CARD_TYPE_LRN
|
||||||
d.sched.answerCard(c, 3)
|
d.sched.answerCard(c, 3)
|
||||||
assert c.queue == 2
|
assert c.queue == 2
|
||||||
assert c.type == 2
|
assert c.type == 2
|
||||||
@ -210,7 +210,7 @@ def test_relearn():
|
|||||||
d.reset()
|
d.reset()
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 3
|
assert c.type == 3
|
||||||
assert c.ivl == 1
|
assert c.ivl == 1
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ def test_learn_day():
|
|||||||
assert ni(c, 3) == 86400 * 2
|
assert ni(c, 3) == 86400 * 2
|
||||||
# if we fail it, it should be back in the correct queue
|
# if we fail it, it should be back in the correct queue
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
d.undo()
|
d.undo()
|
||||||
d.reset()
|
d.reset()
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
@ -679,12 +679,12 @@ def test_suspend():
|
|||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.due >= time.time()
|
assert c.due >= time.time()
|
||||||
due = c.due
|
due = c.due
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 3
|
assert c.type == 3
|
||||||
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 == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 3
|
assert c.type == 3
|
||||||
assert c.due == due
|
assert c.due == due
|
||||||
# should cope with cards in cram decks
|
# should cope with cards in cram decks
|
||||||
@ -771,11 +771,11 @@ def test_filt_keep_lrn_state():
|
|||||||
|
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
|
|
||||||
assert c.type == c.queue == 1
|
assert c.type == CARD_TYPE_LRN and c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.left == 3003
|
assert c.left == 3003
|
||||||
|
|
||||||
d.sched.answerCard(c, 3)
|
d.sched.answerCard(c, 3)
|
||||||
assert c.type == c.queue == 1
|
assert c.type == CARD_TYPE_LRN and c.queue == QUEUE_TYPE_LRN
|
||||||
|
|
||||||
# create a dynamic deck and refresh it
|
# create a dynamic deck and refresh it
|
||||||
did = d.decks.newDyn("Cram")
|
did = d.decks.newDyn("Cram")
|
||||||
@ -784,7 +784,7 @@ def test_filt_keep_lrn_state():
|
|||||||
|
|
||||||
# card should still be in learning state
|
# card should still be in learning state
|
||||||
c.load()
|
c.load()
|
||||||
assert c.type == c.queue == 1
|
assert c.type == CARD_TYPE_LRN and c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.left == 2002
|
assert c.left == 2002
|
||||||
|
|
||||||
# should be able to advance learning steps
|
# should be able to advance learning steps
|
||||||
@ -795,7 +795,7 @@ def test_filt_keep_lrn_state():
|
|||||||
# emptying the deck preserves learning state
|
# emptying the deck preserves learning state
|
||||||
d.sched.emptyDyn(did)
|
d.sched.emptyDyn(did)
|
||||||
c.load()
|
c.load()
|
||||||
assert c.type == c.queue == 1
|
assert c.type == CARD_TYPE_LRN and c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.left == 1001
|
assert c.left == 1001
|
||||||
assert c.due - intTime() > 60 * 60
|
assert c.due - intTime() > 60 * 60
|
||||||
|
|
||||||
@ -977,7 +977,7 @@ def test_timing():
|
|||||||
c.flush()
|
c.flush()
|
||||||
d.reset()
|
d.reset()
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
|
|
||||||
|
|
||||||
def test_collapse():
|
def test_collapse():
|
||||||
|
@ -59,7 +59,7 @@ def test_review():
|
|||||||
d.sched.answerCard(c, 3)
|
d.sched.answerCard(c, 3)
|
||||||
assert c.left == 1001
|
assert c.left == 1001
|
||||||
assert d.sched.counts() == (0, 1, 0)
|
assert d.sched.counts() == (0, 1, 0)
|
||||||
assert c.queue == 1
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
# undo
|
# undo
|
||||||
assert d.undoName()
|
assert d.undoName()
|
||||||
d.undo()
|
d.undo()
|
||||||
|
@ -333,7 +333,7 @@ class DataModel(QAbstractTableModel):
|
|||||||
def nextDue(self, c, index):
|
def nextDue(self, c, index):
|
||||||
if c.odid:
|
if c.odid:
|
||||||
return _("(filtered)")
|
return _("(filtered)")
|
||||||
elif c.queue == 1:
|
elif c.queue == QUEUE_TYPE_LRN:
|
||||||
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)
|
||||||
@ -1430,7 +1430,7 @@ border: 1px solid #000; padding: 3px; '>%s</div>"""
|
|||||||
fmt = "<span style='color:%s'>%s</span>"
|
fmt = "<span style='color:%s'>%s</span>"
|
||||||
if type == CARD_TYPE_NEW:
|
if type == CARD_TYPE_NEW:
|
||||||
tstr = fmt % (st.colLearn, tstr)
|
tstr = fmt % (st.colLearn, tstr)
|
||||||
elif type == 1:
|
elif type == CARD_TYPE_LRN:
|
||||||
tstr = fmt % (st.colMature, tstr)
|
tstr = fmt % (st.colMature, tstr)
|
||||||
elif type == 2:
|
elif type == 2:
|
||||||
tstr = fmt % (st.colRelearn, tstr)
|
tstr = fmt % (st.colRelearn, tstr)
|
||||||
|
Loading…
Reference in New Issue
Block a user