diff --git a/anki/importing/supermemo_xml.py b/anki/importing/supermemo_xml.py index 9a00438ce..ee1b3da7f 100644 --- a/anki/importing/supermemo_xml.py +++ b/anki/importing/supermemo_xml.py @@ -142,6 +142,28 @@ class SupermemoXmlImporter(NoteImporter): return unicode(btflsoup(s, selfClosingTags=['br','hr','img','wbr'], convertEntities=btflsoup.HTML_ENTITIES)) + def _afactor2efactor(self, af): + # Adapted from + + # Ranges for A-factors and E-factors + af_min = 1.2 + af_max = 6.9 + ef_min = 1.3 + ef_max = 3.3 + + # Sanity checks for the A-factor + if af < af_min: + af = af_min + elif af > af_max: + af = af_max + + # Scale af to the range 0..1 + af_scaled = (af - af_min) / (af_max - af_min) + # Rescale to the interval ef_min..ef_max + ef = ef_min + af_scaled * (ef_max - ef_min) + + return ef + ## DEFAULT IMPORTER METHODS def foreignNotes(self): @@ -191,7 +213,7 @@ class SupermemoXmlImporter(NoteImporter): nextDue = tLastrep + (float(item.Interval) * 86400.0) remDays = int((nextDue - time.time())/86400) card.due = self.col.sched.today+remDays - card.factor = int(float(item.AFactor.replace(',','.'))*1000) + card.factor = int(self._afactor2efactor(float(item.AFactor.replace(',','.')))*1000) note.cards[0] = card # categories & tags