store forgetting index as %, fix card sorting

This commit is contained in:
Damien Elmes 2011-12-10 04:10:56 +09:00
parent 0161ebd9f1
commit 78494283c2
3 changed files with 25 additions and 10 deletions

View file

@ -48,7 +48,7 @@ defaultConf = {
'ease4': 1.3,
'fuzz': 0.05,
'minSpace': 1,
'fi': [0.1, 0.1],
'fi': [10, 10],
'order': REV_CARDS_RANDOM,
},
'maxTaken': 60,
@ -220,6 +220,13 @@ class DeckManager(object):
grp['conf'] = id
self.save(grp)
def didsForConf(self, conf):
dids = []
for deck in self.decks:
if deck['conf'] == conf['id']:
dids.append(deck['id'])
return dids
# Deck utils
#############################################################

View file

@ -613,7 +613,7 @@ did = ? and queue = 2 and due <= ? %s limit ?""" % order,
def _ivlForFI(self, conf, ivl):
new, old = conf['rev']['fi']
return ivl * math.log(1-new) / math.log(1-old)
return ivl * math.log(1-new/100.0) / math.log(1-old/100.0)
def _daysLate(self, card):
"Number of days later than scheduled."
@ -875,10 +875,18 @@ and due >= ?""" % scids, now, self.col.usn(), shiftby, low)
self.col.db.executemany(
"update cards set due=:due,mod=:now,usn=:usn where id = :cid""", d)
# fixme: because it's a model property now, these should be done on a
# per-model basis
def randomizeCards(self):
self.sortCards(self.col.db.list("select id from cards"), shuffle=True)
def randomizeCards(self, did):
cids = self.col.db.list("select id from cards where did = ?", did)
self.sortCards(cids, shuffle=True)
def orderCards(self, did):
cids = self.col.db.list("select id from cards where did = ?", did)
self.sortCards(cids)
def resortConf(self, conf):
for did in self.mw.decks.didsForConf(conf):
if conf['new']['order'] == 0:
self.randomizeCards(did)
else:
self.orderCards(did)
def orderCards(self):
self.sortCards(self.col.db.list("select id from cards"))

View file

@ -828,12 +828,12 @@ def test_reorder():
found=False
# 50/50 chance of being reordered
for i in range(20):
d.sched.randomizeCards()
d.sched.randomizeCards(1)
if f.cards()[0].due != f.id:
found=True
break
assert found
d.sched.orderCards()
d.sched.orderCards(1)
assert f.cards()[0].due == 1
# shifting
f3 = d.newNote()