space buttons by at least a day

when a card has a low interval like 1, you can end up with next times of
2,2,3, which some users think is a bug. change the code to yield 2,3,4
instead.
This commit is contained in:
Damien Elmes 2012-07-28 12:47:25 +09:00
parent 153c971db6
commit 875342e141
2 changed files with 31 additions and 9 deletions

View file

@ -820,21 +820,23 @@ did = ? and queue = 2 and due <= ? limit ?""",
delay = self._daysLate(card)
conf = self._revConf(card)
fct = card.factor / 1000.0
ivl2 = self._constrainedIvl((card.ivl + delay/4) * 1.2, conf, card.ivl)
ivl3 = self._constrainedIvl((card.ivl + delay/2) * fct, conf, ivl2)
ivl4 = self._constrainedIvl(
(card.ivl + delay) * fct * conf['ease4'], conf, ivl3)
if ease == 2:
interval = (card.ivl + delay/4) * 1.2
interval = ivl2
elif ease == 3:
interval = (card.ivl + delay/2) * fct
interval = ivl3
elif ease == 4:
interval = (card.ivl + delay) * fct * conf['ease4']
# apply interval factor adjustment
interval = self._ivlWithFactor(conf, interval)
# must be at least one day greater than previous interval; two if easy
interval = max(card.ivl + (2 if ease==4 else 1), int(interval))
interval = ivl4
# interval capped?
return min(interval, conf['maxIvl'])
def _ivlWithFactor(self, conf, ivl):
return ivl * conf.get('ivlFct', 1)
def _constrainedIvl(self, ivl, conf, prev):
"Integer interval after interval factor and prev+1 constraints applied."
new = ivl * conf.get('ivlFct', 1)
return int(max(new, prev+1))
def _daysLate(self, card):
"Number of days later than scheduled."

View file

@ -346,6 +346,26 @@ def test_reviews():
c.load()
assert c.queue == -1
def test_button_spacing():
d = getEmptyDeck()
f = d.newNote()
f['Front'] = u"one"
d.addNote(f)
# 1 day ivl review card due now
c = f.cards()[0]
c.type = 2
c.queue = 2
c.due = d.sched.today
c.reps = 1
c.ivl = 1
c.startTimer()
c.flush()
d.reset()
ni = d.sched.nextIvlStr
assert ni(c, 2) == "2 days"
assert ni(c, 3) == "3 days"
assert ni(c, 4) == "4 days"
def test_overdue_lapse():
# disabled in commit 3069729776990980f34c25be66410e947e9d51a2
return