QUEUE and TYPE day learn, relearn
This commit is contained in:
parent
7b7b71c0e1
commit
957f0c8e8b
@ -21,12 +21,14 @@ QUEUE_TYPE_SUSPENDED = -1
|
|||||||
QUEUE_TYPE_NEW = 0
|
QUEUE_TYPE_NEW = 0
|
||||||
QUEUE_TYPE_LRN = 1
|
QUEUE_TYPE_LRN = 1
|
||||||
QUEUE_TYPE_REV = 2
|
QUEUE_TYPE_REV = 2
|
||||||
|
QUEUE_TYPE_DAY_LEARN_RELEARN = 3
|
||||||
QUEUE_TYPE_PREVIEW = 4
|
QUEUE_TYPE_PREVIEW = 4
|
||||||
|
|
||||||
# Card types
|
# Card types
|
||||||
CARD_TYPE_NEW = 0
|
CARD_TYPE_NEW = 0
|
||||||
CARD_TYPE_LRN = 1
|
CARD_TYPE_LRN = 1
|
||||||
CARD_TYPE_REV = 2
|
CARD_TYPE_REV = 2
|
||||||
|
CARD_TYPE_RELEARNING = 3
|
||||||
|
|
||||||
# removal types
|
# removal types
|
||||||
REM_CARD = 0
|
REM_CARD = 0
|
||||||
|
@ -273,7 +273,7 @@ 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 f"queue in ({QUEUE_TYPE_LRN}, 3)"
|
return f"queue in ({QUEUE_TYPE_LRN}, {QUEUE_TYPE_DAY_LEARN_RELEARN})"
|
||||||
return "type = %d" % n
|
return "type = %d" % n
|
||||||
elif val == "suspended":
|
elif val == "suspended":
|
||||||
return "c.queue = -1"
|
return "c.queue = -1"
|
||||||
@ -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 ({QUEUE_TYPE_REV},3) and c.due <= %d) or
|
(c.queue in ({QUEUE_TYPE_REV},{QUEUE_TYPE_DAY_LEARN_RELEARN}) 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(f"(c.queue in ({QUEUE_TYPE_REV},3))")
|
q.append(f"(c.queue in ({QUEUE_TYPE_REV},{QUEUE_TYPE_DAY_LEARN_RELEARN}))")
|
||||||
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 (QUEUE_TYPE_REV, 3) or card[6] == CARD_TYPE_REV:
|
if card[7] in (QUEUE_TYPE_REV, QUEUE_TYPE_DAY_LEARN_RELEARN) 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]:
|
||||||
|
@ -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 (QUEUE_TYPE_LRN, 3):
|
if card.queue in (QUEUE_TYPE_LRN, QUEUE_TYPE_DAY_LEARN_RELEARN):
|
||||||
self._answerLrnCard(card, ease)
|
self._answerLrnCard(card, ease)
|
||||||
if not wasNewQ:
|
if not wasNewQ:
|
||||||
self._updateStats(card, "lrn")
|
self._updateStats(card, "lrn")
|
||||||
@ -132,7 +132,7 @@ order by due"""
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
def countIdx(self, card):
|
def countIdx(self, card):
|
||||||
if card.queue == 3:
|
if card.queue == QUEUE_TYPE_DAY_LEARN_RELEARN:
|
||||||
return 1
|
return 1
|
||||||
return card.queue
|
return card.queue
|
||||||
|
|
||||||
@ -476,8 +476,8 @@ did in %s and queue = {QUEUE_TYPE_LRN} and due < ? limit %d)"""
|
|||||||
)
|
)
|
||||||
# day
|
# day
|
||||||
self.lrnCount += self.col.db.scalar(
|
self.lrnCount += self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from cards where did in %s and queue = 3
|
select count() from cards where did in %s and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN}
|
||||||
and due <= ? limit %d"""
|
and due <= ? limit %d"""
|
||||||
% (self._deckLimit(), self.reportLimit),
|
% (self._deckLimit(), self.reportLimit),
|
||||||
self.today,
|
self.today,
|
||||||
@ -528,9 +528,9 @@ limit %d"""
|
|||||||
did = self._lrnDids[0]
|
did = self._lrnDids[0]
|
||||||
# fill the queue with the current did
|
# fill the queue with the current did
|
||||||
self._lrnDayQueue = self.col.db.list(
|
self._lrnDayQueue = self.col.db.list(
|
||||||
"""
|
f"""
|
||||||
select id from cards where
|
select id from cards where
|
||||||
did = ? and queue = 3 and due <= ? limit ?""",
|
did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
|
||||||
did,
|
did,
|
||||||
self.today,
|
self.today,
|
||||||
self.queueLimit,
|
self.queueLimit,
|
||||||
@ -611,7 +611,7 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
|||||||
# day learn queue
|
# day learn queue
|
||||||
ahead = ((card.due - self.dayCutoff) // 86400) + 1
|
ahead = ((card.due - self.dayCutoff) // 86400) + 1
|
||||||
card.due = self.today + ahead
|
card.due = self.today + ahead
|
||||||
card.queue = 3
|
card.queue = QUEUE_TYPE_DAY_LEARN_RELEARN
|
||||||
self._logLrn(card, ease, conf, leaving, type, lastLeft)
|
self._logLrn(card, ease, conf, leaving, type, lastLeft)
|
||||||
|
|
||||||
def _delayForGrade(self, conf, left):
|
def _delayForGrade(self, conf, left):
|
||||||
@ -739,14 +739,14 @@ did = ? and queue = 3 and due <= ? limit ?""",
|
|||||||
f"""
|
f"""
|
||||||
update cards set
|
update cards set
|
||||||
due = odue, queue = {QUEUE_TYPE_REV}, 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 = {CARD_TYPE_REV}
|
where queue in ({QUEUE_TYPE_LRN},{QUEUE_TYPE_DAY_LEARN_RELEARN}) and type = {CARD_TYPE_REV}
|
||||||
%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(f"select id from cards where queue in ({QUEUE_TYPE_LRN},3) %s" % extra)
|
self.col.db.list(f"select id from cards where queue in ({QUEUE_TYPE_LRN},{QUEUE_TYPE_DAY_LEARN_RELEARN}) %s" % extra)
|
||||||
)
|
)
|
||||||
|
|
||||||
def _lrnForDeck(self, did):
|
def _lrnForDeck(self, did):
|
||||||
@ -762,9 +762,9 @@ select sum(left/1000) from
|
|||||||
or 0
|
or 0
|
||||||
)
|
)
|
||||||
return cnt + self.col.db.scalar(
|
return cnt + self.col.db.scalar(
|
||||||
"""
|
f"""
|
||||||
select count() from
|
select count() from
|
||||||
(select 1 from cards where did = ? and queue = 3
|
(select 1 from cards where did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN}
|
||||||
and due <= ? limit ?)""",
|
and due <= ? limit ?)""",
|
||||||
did,
|
did,
|
||||||
self.today,
|
self.today,
|
||||||
@ -913,7 +913,7 @@ select id from cards where did in %s and queue = {QUEUE_TYPE_REV} and due <= ? l
|
|||||||
# day learn queue
|
# day learn queue
|
||||||
ahead = ((card.due - self.dayCutoff) // 86400) + 1
|
ahead = ((card.due - self.dayCutoff) // 86400) + 1
|
||||||
card.due = self.today + ahead
|
card.due = self.today + ahead
|
||||||
card.queue = 3
|
card.queue = QUEUE_TYPE_DAY_LEARN_RELEARN
|
||||||
return delay
|
return delay
|
||||||
|
|
||||||
def _nextLapseIvl(self, card, conf):
|
def _nextLapseIvl(self, card, conf):
|
||||||
@ -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, QUEUE_TYPE_LRN, 3):
|
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:
|
||||||
# lapsed
|
# lapsed
|
||||||
|
@ -22,10 +22,8 @@ from anki.rsbackend import SchedTimingToday
|
|||||||
from anki.utils import fmtTimeSpan, ids2str, intTime
|
from anki.utils import fmtTimeSpan, ids2str, intTime
|
||||||
|
|
||||||
# card types: 0=new, 1=lrn, 2=rev, 3=relrn
|
# card types: 0=new, 1=lrn, 2=rev, 3=relrn
|
||||||
CARD_TYPE_RELEARNING = 3
|
|
||||||
# queue types: 0=new, 1=(re)lrn, 2=rev, 3=day (re)lrn,
|
# queue types: 0=new, 1=(re)lrn, 2=rev, 3=day (re)lrn,
|
||||||
# 4=preview, -1=suspended, -2=sibling buried, -3=manually buried
|
# 4=preview, -1=suspended, -2=sibling buried, -3=manually buried
|
||||||
QUEUE_TYPE_DAY_LEARN_RELEARN = 3
|
|
||||||
|
|
||||||
# revlog types: 0=lrn, 1=rev, 2=relrn, 3=early review
|
# revlog types: 0=lrn, 1=rev, 2=relrn, 3=early review
|
||||||
# positive revlog intervals are in days (rev), negative in seconds (lrn)
|
# positive revlog intervals are in days (rev), negative in seconds (lrn)
|
||||||
|
@ -39,7 +39,7 @@ class CardStats:
|
|||||||
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 (QUEUE_TYPE_REV, 3):
|
if c.queue in (QUEUE_TYPE_REV, QUEUE_TYPE_DAY_LEARN_RELEARN):
|
||||||
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
|
||||||
@ -285,7 +285,7 @@ from revlog where id > ? """
|
|||||||
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"""
|
f"""
|
||||||
select count() from cards where did in %s and queue in ({QUEUE_TYPE_REV},3)
|
select count() from cards where did in %s and queue in ({QUEUE_TYPE_REV},{QUEUE_TYPE_DAY_LEARN_RELEARN})
|
||||||
and due = ?"""
|
and due = ?"""
|
||||||
% self._limit(),
|
% self._limit(),
|
||||||
self.col.sched.today + 1,
|
self.col.sched.today + 1,
|
||||||
@ -306,7 +306,7 @@ 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 ({QUEUE_TYPE_REV},3)
|
where did in %s and queue in ({QUEUE_TYPE_REV},{QUEUE_TYPE_DAY_LEARN_RELEARN})
|
||||||
%s
|
%s
|
||||||
group by day order by day"""
|
group by day order by day"""
|
||||||
% (self._limit(), lim),
|
% (self._limit(), lim),
|
||||||
@ -944,7 +944,7 @@ from cards where did in %s and queue = {QUEUE_TYPE_REV}"""
|
|||||||
f"""
|
f"""
|
||||||
select
|
select
|
||||||
sum(case when queue={QUEUE_TYPE_REV} 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={QUEUE_TYPE_REV} and ivl < 21) then 1 else 0 end), -- yng/lrn
|
sum(case when queue in ({QUEUE_TYPE_LRN},{QUEUE_TYPE_DAY_LEARN_RELEARN}) 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"""
|
||||||
|
@ -247,7 +247,7 @@ def test_learn_day():
|
|||||||
# answering it will place it in queue 3
|
# answering it will place it in queue 3
|
||||||
d.sched.answerCard(c, 2)
|
d.sched.answerCard(c, 2)
|
||||||
assert c.due == d.sched.today + 1
|
assert c.due == d.sched.today + 1
|
||||||
assert c.queue == 3
|
assert c.queue == CARD_TYPE_RELEARNING
|
||||||
assert not d.sched.getCard()
|
assert not d.sched.getCard()
|
||||||
# for testing, move it back a day
|
# for testing, move it back a day
|
||||||
c.due -= 1
|
c.due -= 1
|
||||||
@ -281,7 +281,7 @@ def test_learn_day():
|
|||||||
d.sched._cardConf(c)["lapse"]["delays"] = [1440]
|
d.sched._cardConf(c)["lapse"]["delays"] = [1440]
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.queue == 3
|
assert c.queue == CARD_TYPE_RELEARNING
|
||||||
assert d.sched.counts() == (0, 0, 0)
|
assert d.sched.counts() == (0, 0, 0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ def test_relearn():
|
|||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.queue == QUEUE_TYPE_LRN
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 3
|
assert c.type == CARD_TYPE_RELEARNING
|
||||||
assert c.ivl == 1
|
assert c.ivl == 1
|
||||||
|
|
||||||
# immediately graduate it
|
# immediately graduate it
|
||||||
@ -293,7 +293,7 @@ def test_learn_day():
|
|||||||
# answering it will place it in queue 3
|
# answering it will place it in queue 3
|
||||||
d.sched.answerCard(c, 3)
|
d.sched.answerCard(c, 3)
|
||||||
assert c.due == d.sched.today + 1
|
assert c.due == d.sched.today + 1
|
||||||
assert c.queue == 3
|
assert c.queue == QUEUE_TYPE_DAY_LEARN_RELEARN
|
||||||
assert not d.sched.getCard()
|
assert not d.sched.getCard()
|
||||||
# for testing, move it back a day
|
# for testing, move it back a day
|
||||||
c.due -= 1
|
c.due -= 1
|
||||||
@ -327,7 +327,7 @@ def test_learn_day():
|
|||||||
d.sched._cardConf(c)["lapse"]["delays"] = [1440]
|
d.sched._cardConf(c)["lapse"]["delays"] = [1440]
|
||||||
c = d.sched.getCard()
|
c = d.sched.getCard()
|
||||||
d.sched.answerCard(c, 1)
|
d.sched.answerCard(c, 1)
|
||||||
assert c.queue == 3
|
assert c.queue == QUEUE_TYPE_DAY_LEARN_RELEARN
|
||||||
assert d.sched.counts() == (0, 0, 0)
|
assert d.sched.counts() == (0, 0, 0)
|
||||||
|
|
||||||
|
|
||||||
@ -683,12 +683,12 @@ def test_suspend():
|
|||||||
assert c.due >= time.time()
|
assert c.due >= time.time()
|
||||||
due = c.due
|
due = c.due
|
||||||
assert c.queue == QUEUE_TYPE_LRN
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 3
|
assert c.type == CARD_TYPE_RELEARNING
|
||||||
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 == QUEUE_TYPE_LRN
|
assert c.queue == QUEUE_TYPE_LRN
|
||||||
assert c.type == 3
|
assert c.type == CARD_TYPE_RELEARNING
|
||||||
assert c.due == due
|
assert c.due == due
|
||||||
# should cope with cards in cram decks
|
# should cope with cards in cram decks
|
||||||
c.due = 1
|
c.due = 1
|
||||||
|
@ -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 (QUEUE_TYPE_REV, 3) or (c.type == CARD_TYPE_REV and c.queue < 0):
|
elif c.queue in (QUEUE_TYPE_REV, QUEUE_TYPE_DAY_LEARN_RELEARN) 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