17 3
Contact Author Sign in to rate

HUMBLE PIE: "distinct cards studied today" statistic

<10kB. Updated 2020-03-25.
The author has shared 9 other item(s).

Description

PROBLEM: The main window has a statistic that says "Studied X cards in Y minutes today." This counts repeated cards in the total. In other words, if you learnt 50 distinct cards today, but repeated them each twice, Anki tells you you studied 100 cards today. This overestimates how many distinct pieces of knowledge you reviewed. SOLUTION: This addon modifies the message so that only distinct cards are counted. In other words, if you learnt 50 cards, but repeated them each twice, Anki will show "Studied 50 distinct cards in Y minutes today." Even though repeats are ignored for card count, the total minutes spent studying is still displayed accurately. Also, it will only make this change on the main window--not the statistic window. NOTE: If you want to use this together with the add-on More Decks Stats and Time Left, open the latter's add-on folder (Tools>Add-ons>View files) and replace the text in the file called "mds_time_left" with the text found in this link: https://www.codepile.net/pile/mPOVqaoq CREDIT: Made by Joseph Yasmeh. Tested on Anki 2.0 and 2.1 on Mac.

Download

As add-ons are programs downloaded from the internet, they are potentially malicious. You should only download add-ons you trust.

Supported Anki versions:

To download this add-on, please copy and paste the following code into Anki 2.1:

2133933791

If you were linked to this page from the internet, please open Anki on your computer, go to the Tools menu and then Add-ons>Browse & Install to paste in the code.

All Anki 2.1.x Add-Ons Contact Author

Reviews

on 1635698752
I love this add on! Just what I been looking for.
Just like some other people I have a problem with implementing "More deck stats and tiime left" and would really like to get it to work.
on 1630175897
totally speechless. thank you for your contribution. it's super helpful in my studies!
on 1624964825
This add-on should be the default info showed on Anki and I really want it to work with More Decks Stats and Time Left, but didn't have luck with changing the code of mds_time_left.py, using the Author custom files or changing the versions like I've read in another comment :(
on 1615311819
Great add-on! Just what I was looking for.

I tried to merge it with the more deck stats and time left add-on, but when I enable both distinct cards and the more deck stats add-on, your add-on overrides and I can't see the info from more deck stats. I replaced the code in the mds_time_left file like it says in the instructions. Could it be due to the version of add-on/anki im using?

I would like to get my anki to look like https://i.imgur.com/vA2UyxB.png
Comment from author
Sorry the instructions didn't work for you. I'd double check to see if the instructions were followed correctly, and if that's not the cause, then I'd guess the blame lies with your Anki version.

Alternatively, here's the exact version of the custom More Deck Stats add-on I'm using, if you like to try installing it in your Anki addons21 folder (don't forget to unzip): https://bit.ly/3v9USgp
on 1613705549
I merged this with the "More Decks Stats and Time Left" add-on but, since it's almost entirely a copy-paste job without permission from authors of either add-ons, I don't think I'm allowed to share it. I have no idea where to go from here but for anyone trying to do the same thing: at least know that it can be done by someone with zero initial programming knowledge, a lot of trial-and-error and guesswork.

Here's what got mine to look like: https://i.imgur.com/vA2UyxB.png
Comment from author
Awesome work! If you scroll down to the earlier reviews, I had previously shared the code to make this work. I put the link in the description so no one else goes through your trouble (though I hope it inspired you look into coding!).
on 1604817888
Such a useful tweak that should honestly be built in by default. However, it doesn't work with More Deck Stats and Time Left on Anki 2.1.32. This also removes the average time spent per card which I found useful. I saw that the author uses an older version of More Deck Stats, but I don't think those are available to 2.1 users/ available to download. Could this be updated to be compatible with More Deck Stats? Or at least updated to have the average time per card displayed as well?
Comment from author
For More Deck Stats, here's the version of the code I'm using for the file called mds_time_left.py: https://www.codepile.net/pile/mPOVqaoq
on 1590417814
This patch (NOT RENDERED CORRECTLY HERE, PICK LINES MANUALLY, ADJUSTING THE INDENTATION! Only blank lines don't matter in Python.) adds an option to prepend the text to the original text instead of replacing it. Also stops the warnings about "_" and fmtTimeSpan.

I don't know what I am doing, but it seems to work with both Anki 2.1 and 2.0. Sorry about the extra blank line. Feel free to add to the add-on. Note, however, that the license should either be the "GNU General Public License" <https://www.gnu.org/licenses/gpl-3.0.html> or the "GNU Affero General Public License" <https://www.gnu.org/licenses/agpl-3.0.html>, not "GNU license".

-- Aleksej

--- Anki2/addons21/2133933791-2020-05-25/__init__.py.original
+++ Anki2/addons21/2133933791/__init__.py
@@ -11,8 +11,13 @@
#Search "revlog" in the Anki manual to learn more.

from aqt.deckbrowser import*
+from anki.hooks import wrap
+from anki.lang import _
from anki.utils import fmtTimeSpan

+# True to prepend to the default text about repetitions instead of replacing,
+# False to replace it.
+_keepOriginal = True

def _renderStats2(self):
cards, thetime = self.mw.col.db.first("""
@@ -21,9 +26,21 @@
cards = cards or 0
thetime = thetime or 0
msgp1 = ngettext("<!--studied-->%d distinct card", "<!--studied-->%d distinct cards", cards) % cards
- buf = _("Studied %(a)s in %(b)s today.") % dict(a=msgp1,
+ try:
+ buf = _("Studied %(a)s in %(b)s today.") % dict(a=msgp1,
+ b=self.mw.col.backend.format_time_span(thetime))
+ except:
+ buf = _("Studied %(a)s in %(b)s today.") % dict(a=msgp1,
b=fmtTimeSpan(thetime, unit=1))
return buf

-orig__renderStats = DeckBrowser._renderStats
-DeckBrowser._renderStats = _renderStats2
+def _addstats(self, _old):
+ buf = _old(self)
+ return (_renderStats2(self) + "<br/>" + buf)
+
+
+if _keepOriginal:
+ # prepend to the default text
+ DeckBrowser._renderStats = wrap(DeckBrowser._renderStats, _addstats, "around")
+else: # replace the default text
+ DeckBrowser._renderStats = _renderStats2
on 1585220548
Deleted new (0s / card) information.
there is a (.) "dot" at the end which does not exist in the original.
Comment from author
Good points.

Yes, it removes the "(Xs /card)" text. I use the add-on "More Deck Stats and Time Left" so that text wasn't useful to me personally when making this.
on 1585186216
Thank you for making this add on!!!!!

I put in a discussion to the add-on forum to see if an issue is on my end or the add on, I'd love to hear your response.

UPDATE: This works now with the new update for me thank you!!!!
Comment from author before post was edited
Thanks for reporting the issue with newer versions of Anki. I plan to update my addons in June. Anyone interested in this discussion can check here:

https://anki.tenderapp.com/discussions/add-ons/42840-humble-pie-distinct-cards-studied-today
on 1585133371
Is not compatible with More Deck Stats and Time Left or More Overview Stats 21.
on 1585120614
Like the idea but is not compatible with More Deck Stats and Time Left or More Overview Stats 21. Would definitely use it otherwise.
Comment from author
I wonder if it's because you're using a newer version of the add-on "More Deck Stats and Time Left." I use an older version and it works fine with it.

For that add-on, here's the version of the code I'm using for the file called mds_time_left.py: https://www.codepile.net/pile/mPOVqaoq
on 1585077621
add-on erases new information from version 2.1.22
on 1585030193
If you're on Anki 2.1.22/23 and the add-on doesn't seem to be working, check the add-on dialog/window. If it says this addon requires version 2.1.21, it's because the author set the max supported Anki version to 2.1.21. To fix this, just delete the following snippet in meta.json:

"max_point_version": -21

This will remove the max Anki version restriction. After making this change, the add-on seems to be working fine for me on version 2.1.23.

**Of note: for some reason, this does remove "s/card" stat in the deck browser window. However, this isn't a major issue as the stat still available in the statistics window.
Comment from author
Interesting--thanks for reporting it works for 2.1.23. Someone reported earlier that it wasn't working for the newer versions.

I unlocked downloading for newer versions again, and I added a "canary" to the add-on: if it's working, the home screen now says "Studied X *distinct* cards..."
on 1583957631
Great idea and implementation!
on 1583137812
Thanks for bringing this illusion to our attention
on 1583086605
Very useful for a quick overview of your actual progress.
*Update*
Broken as of Anki 2.1.21 beta 2
*Update*
Replace the contents of init.py with the following
#This Anki 2.0 addon modifies the main window "Studied X cards today" message.
#Originally, Anki counts repeated cards in this statistic.
#This addon changes it so only distinct cards are counted.
#Made by Joseph Yasmeh for Anki 2.0 and 2.1 on Mac. July 12 2019.
#GNU license 3
#
#Code rationale:
#Each card has a unique ID assigned to it, called the cid.
#"Distinct" is a type of SQL command that tell the program that from the data it counts,
#exclude redundant things from whatever second column you chose (in this case, cid).
#Search "revlog" in the Anki manual to learn more.

from aqt.deckbrowser import*
from anki.utils import fmtTimeSpan
def _renderStats2(self):
cards, thetime = self.mw.col.db.first("""
select count(distinct cid), sum(time)/1000 from revlog
where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
cards = cards or 0
thetime = thetime or 0
msgp1 = ngettext("<!--studied-->%d card", "<!--studied-->%d cards", cards) % cards
buf = _("Studied %(a)s in %(b)s today.") % dict(a=msgp1,
b=fmtTimeSpan(thetime, unit=1))
return buf

DeckBrowser._renderStats = _renderStats2
Comment from author
Thank you for reporting this. I uploaded your fix (the extra import), which I can confirm still works on my end.
on 1578265511
Great but instead of showing your stat instead of the defaults, I think it would be better to show both !

Like : "Studied X cards and Y notes today"
Comment from author
The other reviewer agrees with you and shared the code for that below. Personally, I like to see a lower number so I'm motivated to work harder.
on 1573752764
# Studied x cards (y distinct) in z minutes today
def _renderStats2(self):
cards, thetime = self.mw.col.db.first("""
select count(), sum(time)/1000 from revlog
where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
dcards, thetime = self.mw.col.db.first("""
select count(distinct cid), sum(time)/1000 from revlog
where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
cards = cards or 0
dcards = dcards or 0
thetime = thetime or 0
msgp1 = ngettext("<!--studied-->%d card", "<!--studied-->%d cards", cards) % cards
msgp1 += " ("+str(dcards)+" distinct)"
buf = _("Studied %(a)s in %(b)s today.") % dict(a=msgp1,
b=fmtTimeSpan(thetime, unit=1))
return buf
on 1568975182
This is an add-on I didn't know I needed, but make great use out of! Thanks!! :)
on 1563285649
Great idea. Helps me to step forward through forest of new cards and make actual progress. (while suspending time-spending-badly-made-cards)