Closed not-nocturnal closed 3 years ago
Hi, I made a github account because of this issue - I tried to replicate what you laid out here, but I couldn't access the in init.py code - it just said "# This file was auto-generated by build_ui.sh. Don't edit." Is there a way I could do what you did? (I don't know shit about coding)
You might not be looking in the right place. The file (on windows) is located in:
C:\Users\
There should be four files: __init__.py config.json config.md meta.json
The one you want to modify is __init__.py, which should be around 4KB, and you should be opening it with a text editor such as notepad++, (using normal windows notepad might cause issues). This file shouldn't be empty, as it's the main component of the addon.
The line you're looking for is this, which should be at or around line 75 in the file:
card.factor = max(2000, card.factor - ivlPenalty) # If the interval is especially long, make it harder
The line you want to add after it is:
card.factor = int(round(card.factor))
Once this is done, save it, restart anki, and try the import again, hopefully this time with success. If you can't find this file or it's really not there, I'm not sure what to suggest, it could be in a different location on your system and the one you found before was perhaps a dummy file of some sort.
Hope this helps.
Wow, thank you so much for the speedy and thorough instructions - I found the file and pasted the code, easy, but I keep getting the traceback error.
Thanks again, man. Wish this would have worked.
I think I know what might have happened, and it would've been due to vagueness in my initial instructions:
# Update cards
for cid in cids:
# Get card
card = mw.col.getCard(cid)
# Update
card.due = mw.col.sched.today + isDueIn(str(due)) # Day on which card will be due
card.reps = int(passes) + int(fails) # Reviews
card.lapses = int(fails) # Times relearnt
card.ivl = max(1, isDueIn(due) + seenLast(lastseen)) # Interval
card.factor = 2000 + min(600, max(0, 300 * math.log(b) - 10 * b)) # 300 * ln(x) - 10*x
if card.ivl >= 15:
i = min(150, card.ivl)
ivlPenalty = (i ** 2) / 10 - 1.065 * max(0, (i ** 2.26) / 40 - 25 * math.sqrt(i))
card.factor = max(2000, card.factor - ivlPenalty) # If the interval is especially long, make it harder
card.factor = int(round(card.factor))
# Card type
card.type = 2 # Due
if card.reps == 0:
card.type = 0 # New
card.ivl = 0
card.factor = 2500
elif b == 1:
card.type = 3 # Relearnt (We can't distinguish between 'restudy' and 'relearnt'
card.ivl = 1 # => assume 'relearnt'
card.due = mw.col.sched.today
card.queue = card.type
# Flush
card.flush()
# Success
return True
You might need to un-indent the new line (like in the code I posted above) so it's not inside the if statement, but after it; if it were in the if statement, it wouldn't be applying to any cards with a short interval. My bad on not making that clear.
If it's not that, it could be something to do with our line numbers not quite matching up, and the line I gave you not being the last line in # Update
. You could also try putting it immediately before card.flush()
instead.
!!! It worked!! I even played around with the indentation a bit when I initaly pasted it, but I didn't put it in that exact slot - thank you for your patent and specific help to the code-blind. Made my day.
Guess who accidentally turned off notifications for this project? 😜 I've merged your changes 7c05eae into the release branch of the plugin @not-nocturnal. I have not seen a visible difference in card reviews with it either. Thank you very much for helping. It's working on my side but if you keep experiencing issues, be sure to let me know ^.^
When I try and import my progress, I'm greeted with this error many times over (presumably once for each note). Using Anki 2.1.26. Also using the 2.1 scheduler, but I tried unchecking it, restarting, and doing a fresh import and it still threw the error.
Based on the error, I tried adding
card.factor = int(round(card.factor))
right after all the card factor math in __init__.py, retried the import, and it seems to have succeeded. Not sure what the implications are as far as precision goes, but my 7 days of review ahead and my 7-day forecast on kanji.koohi match up at the very least.