Coder Social home page Coder Social logo

anki-correct-due's Introduction

Correct new card ordering, clean due number

Rationale

This add-on solve a problem related to the order of new card. This problem only appear either:

  • if you download a shared deck with this problem (you have no way to know whether it is the case while downloading)
  • if you edited a note, and created new cards of this note, when some cards where already reviewed before version 2.1.16 of Anki.

More precisely, anki is supposed to show you all new cards of a note before showing you cards of another note. There are exceptions to this rules. For example, when you see a card, you may bury its siblings. In which case the card which should have been shown today is not shown and another card must be selected. But the main idea is that, if a note have a few cards, you'll discover all of those cards near in the same week, or at worst in the same month.

However, it may occurs that suddenly, anki decides to show you the first card of each note before showing you the second card of any note. Depending on how you use anki, it may be a real problem, and there is virtually no way to correct it by yourself. This is why this add-on is here.

You can see whether you need this add-on by opening a browser, and searching "due>=1000000". If you see any card it means that this add-on may help you. Otherwise, this add-on won't hurt, and won't change anything.

Usage

In the main window, select "Tools>clean due". And that's it.

Warning

I can't imagine how this add-on could break anything. I hope this means warning is useless. However, better be safe, and be sure to make a back up before trying the add-on.

Internal

This add-on does not change any method.

Here is the explanation of the cause of the bug, and of the solution.

When selecting a new card in a deck d, anki selects the card in d, which is new, not suspended, not buried, and whose due value is minimal. This mean that the only purpose of the due value of new card is to decide in which order new cards will be shown. Intuitively, the due value is a computation, done in advance, to find new cards quickly. Which means that if this computation had an error, new cards will be found in the wrong order.

The due value of a new note is chosen to be the greatest due value of the collection, plus one. Which means that the due given to cards always increase. However, for technical reason, the due is capped at 1,000,000 (this ensures that the due value holds on 32 bits, i.e. on an int). It is usually not a problem since most collection does not have a million note. However, if for some reason you have any card whose due value is 1,000,000, all cards will then have this due value. And suddenly due does not means anything anymore.

Thus, this add-on recompute the due value of ALL new cards. Hence, if you have n new cards, the due values will be from 0 to n. It will then randomize the order of new cards when the card is in a deck whose option requires it.

Possible cause of the problem

The trouble being that, if you change a deck's option, and choose to see new cards in random order/order of creation, then anki will give a new due value to each card in decks having this deck option.

The bug mentionned above is caused by the fact that the due number of each card is always incremented and never decremented. However

The problem may also occur if, in the browser, you select Cards>Reposition and choose a value at least equal to 1,000,000.

Version 2.0

Port by lovac42

Links, licence and credits

Key Value
Copyright Arthur Milchior [email protected]
Based on Anki code by Damien Elmes [email protected]
License GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
Source in https://github.com/Arthur-Milchior/anki-correct-due
Addon number 127334978

anki-correct-due's People

Contributors

arthur-milchior avatar

Stargazers

 avatar Steven Nevers avatar

Watchers

 avatar James Cloos avatar

Forkers

lovac42

anki-correct-due's Issues

Error when attempting to clean due

This happened on latest version of Anki for Arch Linux, only other addons I have are Anki Simulator and Japanese Support

Debug info:
Anki 2.1.35 (84dcaa86) Python 3.9.0 Qt 5.15.2 PyQt 5.15.2
Platform: Linux
Flags: frz=False ao=True sv=2
Add-ons, last update check: 2020-12-14 10:20:17
Add-ons possibly involved: ⁨Correcting a bug in anki which makes new card appearing in wrong order⁩

Caught exception:
Traceback (most recent call last):
  File "/home/lxb/.local/share/Anki2/addons21/127334978/redue.py", line 16, in redue
    dconfs = col.decks.dconf
AttributeError: 'DeckManager' object has no attribute 'dconf'

Seems like this may not be compatible with the latest version of Anki

Screws up card order after reposition

Arthur, thanks for bring this to attention.

The SQL query may not be correct:

    cids = col.db.list(f"select id from cards order by id and type = {CARD_NEW}")

I changed it to (python 2.7):

    # Save time
    if not col.db.scalar("select id from cards where type=0 and due>666000"):
        return

    # Sorted by due and siblings for whole collection
    cids = col.db.list("select id from cards where type=0 order by due,ord")
    sched.sortCards(cids,shift=True)

This will keep the existing order of cards. It can also wrap around anki.collection._Collection.fixIntegrity to auto check whenever the db was checked.

Hope this helps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.