update rescheduling

like forgetCards(), we no longer adjust the stats or revlog for the card
This commit is contained in:
Damien Elmes 2011-04-21 12:21:50 +09:00
parent 8a9174fd4d
commit 88c4f010d3
2 changed files with 32 additions and 29 deletions

View file

@ -747,38 +747,26 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
##########################################################################
def forgetCards(self, ids):
"Put cards back in the new queue."
sql = """
update cards set type=0, queue=0, ivl=0, data=''"""
sids = ids2str(ids)
sql += " where id in "+sids
self.deck.db.execute(sql)
"Put cards at the end of the new queue."
self.deck.db.execute(
"update cards set type=0, queue=0, ivl=0 where id in "+ids2str(ids))
pmax = self.deck.db.scalar("select max(due) from cards where type=0")
self.sortCards(ids, start=pmax+1, shuffle=self.deck.randomNew())
def rescheduleCards(self, ids, min, max):
"Reset cards and schedule with new interval in days (min, max)."
self.resetCards(ids)
vals = []
def reschedCards(self, ids, min, max):
"Put cards in review queue with a new interval in days (min, max)."
self.deck.db.execute(
"update cards set type=2, queue=2 where id in "+ids2str(ids))
d = []
t = self.today
mod = intTime()
for id in ids:
r = random.uniform(min*86400, max*86400)
vals.append({
'id': id,
'due': r + time.time(),
'int': r / 86400.0,
't': time.time(),
})
self.deck.db.executemany("""
update cards set
interval = :int,
due = :due,
reps = 1,
successive = 1,
yesCount = 1,
firstAnswered = :t,
queue = 1,
type = 1,
where id = :id""", vals)
r = random.randint(min, max)
d.append(dict(id=id, due=r+t, ivl=r, mod=mod))
self.deck.db.executemany(
"update cards set type=2,queue=2,ivl=:ivl,due=:due where id=:id",
d)
# Repositioning new cards
##########################################################################

View file

@ -726,7 +726,6 @@ def test_reorder():
def test_forget():
d = getEmptyDeck()
# add a fact with default group
f = d.newFact()
f['Front'] = u"one"
d.addFact(f)
@ -738,3 +737,19 @@ def test_forget():
d.sched.forgetCards([c.id])
d.reset()
assert d.sched.counts() == (1, 0, 0)
def test_resched():
d = getEmptyDeck()
f = d.newFact()
f['Front'] = u"one"
d.addFact(f)
c = f.cards()[0]
d.sched.reschedCards([c.id], 0, 0)
c.load()
assert c.due == d.sched.today
assert c.ivl == 0
assert c.queue == c.type == 2
d.sched.reschedCards([c.id], 1, 1)
c.load()
assert c.due == d.sched.today+1
assert c.ivl == +1