support customizing hard factor

This commit is contained in:
Damien Elmes 2018-07-11 21:23:22 +10:00
parent c60e22fd60
commit 1a617e6d60
5 changed files with 90 additions and 11 deletions

View File

@ -76,6 +76,7 @@ defaultConf = {
'maxIvl': 36500,
# may not be set on old decks
'bury': False,
'hardFactor': 1.2,
},
'maxTaken': 60,
'timer': 0,

View File

@ -898,7 +898,12 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)"""
delay = self._daysLate(card)
conf = self._revConf(card)
fct = card.factor / 1000
ivl2 = self._constrainedIvl(card.ivl * 1.2, conf, card.ivl, fuzz)
hardFactor = conf.get("hardFactor", 1.2)
if hardFactor > 1:
hardMin = card.ivl
else:
hardMin = 0
ivl2 = self._constrainedIvl(card.ivl * hardFactor, conf, hardMin, fuzz)
if ease == 2:
return ivl2
@ -963,9 +968,10 @@ select id from cards where did in %s and queue = 2 and due <= ? limit ?)"""
minNewIvl = 1
if ease == 2:
factor = 1.2
factor = conf.get("hardFactor", 1.2)
# hard cards shouldn't have their interval decreased by more than 50%
minNewIvl = 0.5
# of the normal factor
minNewIvl = factor / 2
elif ease == 3:
factor = card.factor / 1000
else: # ease == 4:

View File

@ -185,6 +185,10 @@ class DeckConf(QDialog):
f.maxIvl.setValue(c['maxIvl'])
f.revplim.setText(self.parentLimText('rev'))
f.buryRev.setChecked(c.get("bury", True))
f.hardFactor.setValue(int(c.get("hardFactor", 1.2)*100))
if self.mw.col.schedVer() == 1:
f.hardFactor.setVisible(False)
f.hardFactorLabel.setVisible(False)
# lapse
c = self.conf['lapse']
f.lapSteps.setText(self.listToUser(c['delays']))
@ -267,6 +271,7 @@ class DeckConf(QDialog):
c['ivlFct'] = f.fi1.value()/100.0
c['maxIvl'] = f.maxIvl.value()
c['bury'] = f.buryRev.isChecked()
c['hardFactor'] = f.hardFactor.value()/100.0
# lapse
c = self.conf['lapse']
self.updateList(c, 'delays', f.lapSteps, minSize=0)

View File

@ -77,7 +77,16 @@
<string>New Cards</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
@ -227,7 +236,16 @@
<string>Reviews</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
@ -343,13 +361,30 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="buryRev">
<property name="text">
<string>Bury related reviews until the next day</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="hardFactorLabel">
<property name="text">
<string>Hard interval</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="hardFactor">
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>120</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -372,7 +407,16 @@
<string>Lapses</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
@ -521,7 +565,16 @@
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="margin">
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
@ -605,7 +658,16 @@
<property name="spacing">
<number>12</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
@ -649,6 +711,7 @@
<tabstop>easyBonus</tabstop>
<tabstop>fi1</tabstop>
<tabstop>maxIvl</tabstop>
<tabstop>hardFactor</tabstop>
<tabstop>buryRev</tabstop>
<tabstop>lapSteps</tabstop>
<tabstop>lapMult</tabstop>
@ -659,7 +722,6 @@
<tabstop>showTimer</tabstop>
<tabstop>autoplaySounds</tabstop>
<tabstop>replayQuestion</tabstop>
<tabstop>buttonBox</tabstop>
<tabstop>desc</tabstop>
</tabstops>
<resources>

View File

@ -451,6 +451,11 @@ def test_button_spacing():
assert ni(c, 3) == "3 days"
assert ni(c, 4) == "4 days"
# if hard factor is <= 1, then hard may not increase
conf = d.decks.confForDid(1)
conf['rev']['hardFactor'] = 1
assert ni(c, 2) == "1 day"
def test_overdue_lapse():
# disabled in commit 3069729776990980f34c25be66410e947e9d51a2
return
@ -695,7 +700,7 @@ def test_filt_reviewing_early_normal():
d.reset()
c = d.sched.getCard()
assert d.sched.nextIvl(c, 2) == 50*86400
assert d.sched.nextIvl(c, 2) == 60*86400
assert d.sched.nextIvl(c, 3) == 100*86400
assert d.sched.nextIvl(c, 4) == 101*86400