mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
drop streak, make reps log all entries
reps should now be equal to the number of entries in the revlog, and only exists so that we can order by review count in the browser efficiently streak is no longer necessary as we have a learn queue now
This commit is contained in:
parent
946b54185e
commit
7d64036a07
6 changed files with 21 additions and 25 deletions
|
@ -36,7 +36,6 @@ class Card(object):
|
|||
self.ivl = 0
|
||||
self.factor = 0
|
||||
self.reps = 0
|
||||
self.streak = 0
|
||||
self.lapses = 0
|
||||
self.grade = 0
|
||||
self.cycles = 0
|
||||
|
@ -56,7 +55,6 @@ class Card(object):
|
|||
self.ivl,
|
||||
self.factor,
|
||||
self.reps,
|
||||
self.streak,
|
||||
self.lapses,
|
||||
self.grade,
|
||||
self.cycles,
|
||||
|
@ -71,7 +69,7 @@ class Card(object):
|
|||
self.deck.db.execute(
|
||||
"""
|
||||
insert or replace into cards values
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
self.id,
|
||||
self.fid,
|
||||
self.gid,
|
||||
|
@ -84,7 +82,6 @@ insert or replace into cards values
|
|||
self.ivl,
|
||||
self.factor,
|
||||
self.reps,
|
||||
self.streak,
|
||||
self.lapses,
|
||||
self.grade,
|
||||
self.cycles,
|
||||
|
@ -96,9 +93,9 @@ insert or replace into cards values
|
|||
self.deck.db.execute(
|
||||
"""update cards set
|
||||
mod=?, type=?, queue=?, due=?, ivl=?, factor=?, reps=?,
|
||||
streak=?, lapses=?, grade=?, cycles=?, edue=? where id = ?""",
|
||||
lapses=?, grade=?, cycles=?, edue=? where id = ?""",
|
||||
self.mod, self.type, self.queue, self.due, self.ivl,
|
||||
self.factor, self.reps, self.streak, self.lapses,
|
||||
self.factor, self.reps, self.lapses,
|
||||
self.grade, self.cycles, self.edue, self.id)
|
||||
|
||||
def q(self, classes="q", reload=False):
|
||||
|
|
|
@ -234,7 +234,7 @@ qconf=?, conf=?, data=?""",
|
|||
# notice any new tags
|
||||
self.registerTags(fact.tags)
|
||||
# if random mode, determine insertion point
|
||||
if self.qconf['newOrder'] == NEW_CARDS_RANDOM:
|
||||
if self.randomNew():
|
||||
due = random.randrange(0, 1000000)
|
||||
else:
|
||||
due = fact.id
|
||||
|
@ -287,7 +287,7 @@ select id from facts where id not in (select distinct fid from cards)""")
|
|||
"Generate cards for templates if cards not empty. Return cards."
|
||||
cards = []
|
||||
# if random mode, determine insertion point
|
||||
if self.qconf['newOrder'] == NEW_CARDS_RANDOM:
|
||||
if self.randomNew():
|
||||
# if this fact has existing new cards, use their due time
|
||||
due = self.db.scalar(
|
||||
"select due from cards where fid = ? and queue = 0", fact.id)
|
||||
|
@ -335,6 +335,9 @@ select id from facts where id not in (select distinct fid from cards)""")
|
|||
card.flush()
|
||||
return card
|
||||
|
||||
def randomNew(self):
|
||||
return self.qconf['newOrder'] == NEW_CARDS_RANDOM
|
||||
|
||||
# Cards
|
||||
##########################################################################
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ from anki.lang import _, ngettext
|
|||
from anki.consts import *
|
||||
from anki.hooks import runHook
|
||||
|
||||
# fixme: on upgrade cards are ordered but order defaults to random
|
||||
|
||||
# the standard Anki scheduler
|
||||
class Scheduler(object):
|
||||
name = "std"
|
||||
|
@ -37,8 +39,9 @@ class Scheduler(object):
|
|||
self._resetNew()
|
||||
|
||||
def answerCard(self, card, ease):
|
||||
self.deck.markReview(card)
|
||||
assert ease >= 1 and ease <= 4
|
||||
self.deck.markReview(card)
|
||||
card.reps += 1
|
||||
if card.queue == 0:
|
||||
# put it in the learn queue
|
||||
card.queue = 1
|
||||
|
@ -196,7 +199,7 @@ from cards group by gid""", self.today):
|
|||
# New cards
|
||||
##########################################################################
|
||||
|
||||
# need to keep track of reps for timebox and new card introduction
|
||||
# FIXME: need to keep track of reps for timebox and new card introduction
|
||||
|
||||
def _resetNewCount(self):
|
||||
l = self.deck.qconf
|
||||
|
@ -423,7 +426,6 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
|||
##########################################################################
|
||||
|
||||
def _answerRevCard(self, card, ease):
|
||||
card.reps += 1
|
||||
if ease == 1:
|
||||
self._rescheduleLapse(card)
|
||||
else:
|
||||
|
@ -432,7 +434,6 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
|||
|
||||
def _rescheduleLapse(self, card):
|
||||
conf = self._cardConf(card)['lapse']
|
||||
card.streak = 0
|
||||
card.lapses += 1
|
||||
card.lastIvl = card.ivl
|
||||
card.ivl = self._nextLapseIvl(card, conf)
|
||||
|
@ -452,7 +453,6 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
|||
return int(card.ivl*conf['mult']) + 1
|
||||
|
||||
def _rescheduleRev(self, card, ease):
|
||||
card.streak += 1
|
||||
# update interval
|
||||
card.lastIvl = card.ivl
|
||||
self._updateRevIvl(card, ease)
|
||||
|
@ -747,10 +747,9 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
|||
# - should remove all scheduling history so we don't show more new ca
|
||||
def resetCards(self, ids=None):
|
||||
"Reset progress on cards in IDS."
|
||||
print "position in resetCards()"
|
||||
sql = """
|
||||
update cards set mod=:now, position=0, type=2, queue=2, lastInterval=0,
|
||||
interval=0, due=created, factor=2.5, reps=0, successive=0, lapses=0, flags=0"""
|
||||
update cards set mod=%d, due=fid, type=0, queue=0, ivl=0, factor=0, reps=0,
|
||||
lapses=0, grade=0, cycles=0, edue=0, data=''"""
|
||||
sql2 = "delete from revlog"
|
||||
if ids is None:
|
||||
lim = ""
|
||||
|
@ -760,7 +759,7 @@ interval=0, due=created, factor=2.5, reps=0, successive=0, lapses=0, flags=0"""
|
|||
sql2 += " where cardId in "+sids
|
||||
self.deck.db.execute(sql, now=time.time())
|
||||
self.deck.db.execute(sql2)
|
||||
if self.qconf['newOrder'] == NEW_CARDS_RANDOM:
|
||||
if self.deck.randomNew():
|
||||
# we need to re-randomize now
|
||||
self.randomizeNewCards(ids)
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ class CardStats(object):
|
|||
self.addLine(_("Due"), next)
|
||||
self.addLine(_("Interval"), fmt(c.ivl * 86400))
|
||||
self.addLine(_("Ease"), "%d%%" % (c.factor/10.0))
|
||||
if c.reps:
|
||||
self.addLine(_("Reviews"), "%d/%d (s=%d)" % (
|
||||
c.reps-c.lapses, c.reps, c.streak))
|
||||
# if c.reps:
|
||||
# self.addLine(_("Reviews"), "%d/%d (s=%d)" % (
|
||||
# c.reps-c.lapses, c.reps, c.streak))
|
||||
(cnt, total) = self.deck.db.first(
|
||||
"select count(), sum(taken)/1000 from revlog where cid = :id", id=c.id)
|
||||
if cnt:
|
||||
|
|
|
@ -84,7 +84,6 @@ create table if not exists cards (
|
|||
ivl integer not null,
|
||||
factor integer not null,
|
||||
reps integer not null,
|
||||
streak integer not null,
|
||||
lapses integer not null,
|
||||
grade integer not null,
|
||||
cycles integer not null,
|
||||
|
@ -254,7 +253,7 @@ when 1 then 2
|
|||
when 2 then 0
|
||||
else type end),
|
||||
due, cast(interval as int),
|
||||
cast(factor*1000 as int), reps, successive, noCount, 0, 0, 0, "" from cards2
|
||||
cast(factor*1000 as int), reps, noCount, 0, 0, 0, "" from cards2
|
||||
order by created""")
|
||||
db.execute("drop table cards2")
|
||||
|
||||
|
@ -300,7 +299,7 @@ from facts order by created""")
|
|||
row.append(minimizeHTML("\x1f".join([x[1] for x in sorted(fields[oldid])])))
|
||||
data.append(row)
|
||||
# use the new order to rewrite fact ids in cards table
|
||||
_insertWithIdChange(db, map, 1, "cards", 18)
|
||||
_insertWithIdChange(db, map, 1, "cards", 17)
|
||||
# and put the facts into the new table
|
||||
db.execute("drop table facts")
|
||||
_addSchema(db, False)
|
||||
|
|
|
@ -167,7 +167,6 @@ def test_reviews():
|
|||
# factor should have been decremented
|
||||
assert c.factor == 2300
|
||||
# check counters
|
||||
assert c.streak == 0
|
||||
assert c.lapses == 2
|
||||
assert c.reps == 4
|
||||
# try again with an ease of 2 instead
|
||||
|
@ -182,7 +181,6 @@ def test_reviews():
|
|||
# factor should have been decremented
|
||||
assert c.factor == 2350
|
||||
# check counters
|
||||
assert c.streak == 3
|
||||
assert c.lapses == 1
|
||||
assert c.reps == 4
|
||||
# ease 3
|
||||
|
|
Loading…
Reference in a new issue