mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Use locale decimal point
This commit is contained in:
parent
7bbbc3bd65
commit
57ca74ce34
1 changed files with 50 additions and 47 deletions
|
@ -260,6 +260,7 @@ class CardStats(object):
|
|||
def report(self):
|
||||
c = self.card
|
||||
fmt = anki.utils.fmtTimeSpan
|
||||
fmtFloat = anki.utils.fmtFloat
|
||||
self.txt = "<table>"
|
||||
self.addLine(_("Added"), self.strTime(c.created))
|
||||
if c.firstAnswered:
|
||||
|
@ -272,21 +273,21 @@ class CardStats(object):
|
|||
next = _("in %s") % fmt(abs(next))
|
||||
self.addLine(_("Due"), next)
|
||||
self.addLine(_("Interval"), fmt(c.interval * 86400))
|
||||
self.addLine(_("Ease"), "%0.2f" % c.factor)
|
||||
self.addLine(_("Ease"), fmtFloat(c.factor, point=2))
|
||||
if c.lastDue:
|
||||
last = _("%s ago") % fmt(time.time() - c.lastDue)
|
||||
self.addLine(_("Last Due"), last)
|
||||
if c.interval != c.lastInterval:
|
||||
# don't show the last interval if it hasn't been updated yet
|
||||
self.addLine(_("Last Interval"), fmt(c.lastInterval * 86400))
|
||||
self.addLine(_("Last Ease"), "%0.2f" % c.lastFactor)
|
||||
self.addLine(_("Last Ease"), fmtFloat(c.lastFactor, point=2))
|
||||
if c.reps:
|
||||
self.addLine(_("Reviews"), "%d/%d (s=%d)" % (
|
||||
c.yesCount, c.reps, c.successive))
|
||||
self.addLine(_("Average Time"), _("%0.1f seconds") %
|
||||
c.averageTime)
|
||||
self.addLine(_("Total Time"), _("%0.1f seconds") %
|
||||
c.reviewTime)
|
||||
avg = fmt(c.averageTime, point=2)
|
||||
self.addLine(_("Average Time"),avg)
|
||||
total = fmt(c.reviewTime, point=2)
|
||||
self.addLine(_("Total Time"), total)
|
||||
self.addLine(_("Model Tags"), c.fact.model.tags)
|
||||
self.addLine(_("Card Template") + " "*5, c.cardModel.name)
|
||||
self.txt += "</table>"
|
||||
|
@ -309,8 +310,10 @@ class DeckStats(object):
|
|||
|
||||
def report(self):
|
||||
"Return an HTML string with a report."
|
||||
fmtPerc = anki.utils.fmtPercentage
|
||||
fmtFloat = anki.utils.fmtFloat
|
||||
if self.deck.isEmpty():
|
||||
return _("Please add some cards first.<p/>")
|
||||
return _("Please add some cards first.") + "<p/>"
|
||||
d = self.deck
|
||||
html="<h1>" + _("Deck Statistics") + "</h1>"
|
||||
html += _("Deck created: <b>%s</b> ago<br>") % self.createdTimeStr()
|
||||
|
@ -325,60 +328,60 @@ class DeckStats(object):
|
|||
(stats["new"], stats["newP"]) = (new, newP)
|
||||
(stats["old"], stats["oldP"]) = (old, oldP)
|
||||
(stats["young"], stats["youngP"]) = (young, youngP)
|
||||
html += _("Total number of cards: <b>%d</b><br>") % total
|
||||
html += _("Total number of facts: <b>%d</b><br><br>") % d.factCount
|
||||
html += _("Total number of cards:") + " <b>%d</b><br>" % total
|
||||
html += _("Total number of facts:") + " <b>%d</b><br><br>" % d.factCount
|
||||
|
||||
html += _("<b>Card counts</b><br>")
|
||||
html += _("Mature cards: <b>%(old)d</b> "
|
||||
"(<b>%(oldP)0.2f%%</b>)<br>") % stats
|
||||
html += _("Young cards: <b>%(young)d</b> "
|
||||
"(<b>%(youngP)0.2f%%</b>)<br>") % stats
|
||||
html += _("Unseen cards: <b>%(new)d</b> "
|
||||
"(<b>%(newP)0.2f%%</b>)<br><br>") % stats
|
||||
html += "<b>" + _("Card counts") + "</b><br>"
|
||||
html += _("Mature cards:") + " <b>%(old)d</b> (%(oldP)s)<br>" % {'old': stats['old'], 'oldP' : fmtPerc(stats['oldP'])}
|
||||
html += _("Young cards:") + " <b>%(young)d</b> (%(youngP)s)<br>" % {'young': stats['young'], 'youngP' : fmtPerc(stats['youngP'])}
|
||||
html += _("Unseen cards:") + " <b>%(new)d</b> (%(newP)s)<br><br>" % {'new': stats['new'], 'newP' : fmtPerc(stats['newP'])}
|
||||
|
||||
html += _("<b>Correct answers</b><br>")
|
||||
html += _("Mature cards: <b>%(gMatureYes%)0.1f%%</b> "
|
||||
"(<b>%(gMatureYes)d</b> of <b>%(gMatureTotal)d</b>)<br>") % stats
|
||||
html += _("Young cards: <b>%(gYoungYes%)0.1f%%</b> "
|
||||
"(<b>%(gYoungYes)d</b> of <b>%(gYoungTotal)d</b>)<br>") % stats
|
||||
html += _("First-seen cards: <b>%(gNewYes%)0.1f%%</b> "
|
||||
"(<b>%(gNewYes)d</b> of <b>%(gNewTotal)d</b>)<br><br>") % stats
|
||||
html += "<b>" + _("Correct answers") + "</b><br>"
|
||||
html += _("Mature cards:") + "<b>" + fmtPerc(stats['gMatureYes%']) + (
|
||||
"</b> " + _("%(partOf)d of %(totalSum)d") % {'partOf' : stats['gMatureYes'],
|
||||
'totalSum' : stats['gMatureTotal'] } + "<br>")
|
||||
html += _("Young cards:") + " <b>" + fmtPerc(stats['gYoungYes%']) + (
|
||||
"</b> " + _("%(partOf)d of %(totalSum)d") % {'partOf' : stats['gYoungYes'],
|
||||
'totalSum' : stats['gYoungTotal'] } + "<br>")
|
||||
html += _("First-seen cards:") + " <b>" + fmtPerc(stats['gNewYes%']) + (
|
||||
"</b> " + _("%(partOf)d of %(totalSum)d") % {'partOf' : stats['gNewYes'],
|
||||
'totalSum' : stats['gNewTotal'] } + "<br><br>")
|
||||
# average pending time
|
||||
existing = d.cardCount - d.newCountToday
|
||||
avgInt = self.getAverageInterval()
|
||||
def tr(a, b):
|
||||
return "<tr><td>%s</td><td align=right>%s</td></tr>" % (a, b)
|
||||
if existing and avgInt:
|
||||
html += _("<b>Averages</b><br>")
|
||||
html += "<b>" + _("Averages") + "</b>"
|
||||
if sys.platform.startswith("darwin"):
|
||||
html += "<table width=250>"
|
||||
else:
|
||||
html += "<table width=200>"
|
||||
html += tr(_("Interval"), _("<b>%0.0f</b> days") % avgInt)
|
||||
html += tr(_("Average reps"), _("<b>%0.1f</b> cards/day") % (
|
||||
self.getSumInverseRoundInterval()))
|
||||
html += tr(_("Reps next week"), _("<b>%0.1f</b> cards/day") % (
|
||||
self.getWorkloadPeriod(7)))
|
||||
html += tr(_("Reps next month"), _("<b>%0.1f</b> cards/day") % (
|
||||
self.getWorkloadPeriod(30)))
|
||||
html += tr(_("Reps last week"), _("<b>%0.1f</b> cards/day") % (
|
||||
self.getPastWorkloadPeriod(7)))
|
||||
html += tr(_("Reps last month"), _("<b>%0.1f</b> cards/day") % (
|
||||
self.getPastWorkloadPeriod(30)))
|
||||
html += tr(_("Avg. added"), _("<b>%(a)d</b>/day, <b>%(b)d</b>/mon") % {
|
||||
'a': self.newAverage(), 'b': self.newAverage()*30})
|
||||
html += tr(_("Interval"), ("<b>%s</b> ") % fmtFloat(avgInt) + _("days") )
|
||||
html += tr(_("Average reps"), ("<b>%s</b> ") % (
|
||||
fmtFloat(self.getSumInverseRoundInterval())) + _("cards/day"))
|
||||
html += tr(_("Reps next week"), ("<b>%s</b> ") % (
|
||||
fmtFloat(self.getWorkloadPeriod(7))) + _("cards/day"))
|
||||
html += tr(_("Reps next month"), ("<b>%s</b> ") % (
|
||||
fmtFloat(self.getWorkloadPeriod(30))) + _("cards/day"))
|
||||
html += tr(_("Reps last week"), ("<b>%s</b> ") % (
|
||||
fmtFloat(self.getPastWorkloadPeriod(7))) + _("cards/day"))
|
||||
html += tr(_("Reps last month"), ("<b>%s</b> ") % (
|
||||
fmtFloat(self.getPastWorkloadPeriod(30))) + _("cards/day"))
|
||||
html += tr(_("Avg. added"), _("<b>%(a)s</b>/day, <b>%(b)s</b>/mon") % {
|
||||
'a': fmtFloat(self.newAverage()), 'b': fmtFloat(self.newAverage()*30)})
|
||||
np = self.getNewPeriod(7)
|
||||
html += tr(_("Added last week"), _("<b>%(a)d</b> (<b>%(b)0.1f</b>/day)") % (
|
||||
{'a': np, 'b': np / float(7)}))
|
||||
html += tr(_("Added last week"), _("<b>%(a)d</b> (<b>%(b)s</b>/day)") % (
|
||||
{'a': np, 'b': fmtFloat(np / float(7))}))
|
||||
np = self.getNewPeriod(30)
|
||||
html += tr(_("Added last month"), _("<b>%(a)d</b> (<b>%(b)0.1f</b>/day)") % (
|
||||
{'a': np, 'b': np / float(30)}))
|
||||
html += tr(_("Added last month"), _("<b>%(a)d</b> (<b>%(b)s</b>/day)") % (
|
||||
{'a': np, 'b': fmtFloat(np / float(30))}))
|
||||
np = self.getFirstPeriod(7)
|
||||
html += tr(_("First last week"), _("<b>%(a)d</b> (<b>%(b)0.1f</b>/day)") % (
|
||||
{'a': np, 'b': np / float(7)}))
|
||||
html += tr(_("First last week"), _("<b>%(a)d</b> (<b>%(b)s</b>/day)") % (
|
||||
{'a': np, 'b': fmtFloat(np / float(7))}))
|
||||
np = self.getFirstPeriod(30)
|
||||
html += tr(_("First last month"), _("<b>%(a)d</b> (<b>%(b)0.1f</b>/day)") % (
|
||||
{'a': np, 'b': np / float(30)}))
|
||||
html += tr(_("First last month"), _("<b>%(a)d</b> (<b>%(b)s</b>/day)") % (
|
||||
{'a': np, 'b': fmtFloat(np / float(30))}))
|
||||
html += "</table>"
|
||||
return html
|
||||
|
||||
|
@ -394,10 +397,10 @@ class DeckStats(object):
|
|||
html = ""
|
||||
for key in keys:
|
||||
html += ("<tr><td align=right>%s</td><td align=right>" +
|
||||
"%d</td><td align=right>%0.2f%%</td></tr>") % (
|
||||
"%d</td><td align=right>%s</td></tr>") % (
|
||||
labels[key],
|
||||
boxes[key],
|
||||
boxes[key] / float(total) * 100)
|
||||
fmtPerc(boxes[key] / float(total) * 100))
|
||||
return html
|
||||
|
||||
def splitIntoIntervals(self, intervals):
|
||||
|
|
Loading…
Reference in a new issue