ig3 / anki-limitnew

Limit the number of new cards in Anki
MIT License
3 stars 0 forks source link

no changes in addon settings + one more #3

Closed Reunion31 closed 3 years ago

Reunion31 commented 3 years ago

(Delete this: When setting the limits in the deck options, they don't get ported to the addon settings) <- figured out by reading the github page. A little confusing. Anyway...

Custom decks don't seem to be affected, but I haven't tested it a lot to be 100% sure. Can you confirm there's an issue yourself? As for me, I'll know for sure maybe in a week.

ig3 commented 3 years ago

Yes, per-deck settings don't appear in the add-on settings. Only the global (all decks) limits are in the settings file.

I don't use custom/filtered decks myself so haven't tested the add-on with them. Sorry. I suppose I should add a note about this to the documentation, at least.

Scheduling for filtered decks is somewhat different and I haven't inspected it much. It may be that the way filtered decks are scheduled, what I have done has not impact, particularly for the global settings but maybe also for the per-deck limits. Let me know your experience and I'll try to find some time to have a look at it.

ig3 commented 3 years ago

I had a brief look at filtered decks and custom study.

Options for these decks are different and the add-on per-deck options do not appear. But maybe this is reasonable as the context is so different for these decks.

After studying to my new card limit, I created a custom study deck and increased the new card limit by 10. 10 new cards were shown. This seems reasonable, I explicitly asked for 10 more new cards. In this case, I don't think the add-on should limit the new cards in this case. I don't know if the new cards studied in a custom deck will affect the new card limits of regular decks. I will have to test and review the code.

I also created a filtered deck. In a filtered deck, I don't think new cards a tracked. One simply selects a set of cards (via the filter) and study that set of cards. So, limits on new cards are irrelevant here. However, cards studied in a filtered deck should still be included in the count of cards studied on the day and so should still affect the 'global' limit on new cards.

ig3 commented 3 years ago

For Anki 2.1.22 and later, the implementation is based on hooks.scheduler_new_limit_for_single_deck and gui_hooks.reviewer_did_answer_card. The new card limit may be reduced by the former hook function but this hook is only called for regular decks. It is not called for custom study or filtered decks, so the add-on cannot affect new card limits for these deck types.

For Anki version 2.1.17 through 2.1.21, the original implementation of the add-on is used. This has only the global limits. This does not limit dynamic decks (I think filtered decks and custom study decks are forms of dynamic decks).

Custom Study either modifies the deck being studied (e.g. when the new card limit is increased) or creates a filtered deck named 'Custom Study Session', depending on what custom study options are selected. Custom study is not available on a filtered deck.

If the new card limit of a regular deck is changed by custom study, the record of the number of new cards studied today is altered (increased or decreased, according to the adjustment entered). This adjusted number is subtracted from the new card limit. For example, if one had studied 10 new cards today with a limit of 15 then, via custom study, allowed 25 additional new cards, the count of new cards studied today is changed to -15. If the new card limit is 15 then 15 - (-15) = 30, so you can study another 30 cards: the 5 that were remaining, plus 25 more. As more new cards are studied, the count of new cards studied is incremented, until it reaches the limit. The add-on may scale the new card limit, according to its parameters and total number of cards scheduled and studied, but it will never set it below 0. If the count of new cards studied today was changed to -15 and the new card limit is reduced by the add-on to 0, then one can still study another 15 cards. So, even if the new card limit is 0, if the number of new cards studied today is less than 0 then the scheduler will present new cards until the number of new cards scheduled today reaches 0. Thus, the add-on will not prevent reviewing new cards in this case. But the whole point of "increase today's new limit" is to allow more new cards than the normal limits allow, so this seems reasonable. On the other hand, if the new card limit is 100 and 100 cards are studied, then 10 more new cards are allowed, the count of cards studied is reduced to 90. If total workload causes the new card limit to be reduced to 0, 90 is more than 0 so no new cards can be studied. In this case, it would be necessary to allow more than 90 more new cards, in order to study more today. This is a bit confusing - or maybe not and I am just confusing myself. It is a result of how the scheduler handles the adjustment - by adjusting the count of new cards studied, rather than adjusting the limit.

Let me try to make it clearer: if one has a limit of 100 new cards per day and studies new cards first, then one can study 100 new cards, reaching the limit (assuming the add-on parameters don't scale back the new card limit, based on workload). If one then studies many review cards, eventually the total workload will cause the new card limit to be scaled back, eventually to 0. So, scaled back new card limit is 0 and number of new cards studied today is 100. If one then uses custom study to allow 20 additional new cards, the count of new cards studied today is reduced from 100 to 80, but this is still more than 0, so you still can't study new cards. Allow another 20 and the count is reduced to 60, but this is still more than 0. Now allow another 75 cards and the count of new cards studied today is set to -15. This is less than 0, so one can now study 15 more cards. This is hardly intuitive. But, unless I rewrite significant parts of the scheduler and/or the custom study interface, there is nothing that can be done about it.

But, I should update the documentation to explain some of this.

Filtered decks may include new cards. In a filtered deck, the limit on new cards is hard coded to 99,999. Not actually unlimited, but a limit one is very unlikely to reach. For a filtered deck, the hook this add-on sets is not called, so the behaviour is pure Anki standard behaviour. But this is probably OK because filtered decks are used primarily for study outside the usual, scheduled study of regular decks, so it seems less important to limit new cards in a filtered deck. Of course, if one wants a filtered deck but does not want to study new cards, then the new cards can be excluded by the filter.

For the 'global' limits (not per-deck limits) every card scheduled and every card viewed contributes to the calculation of total workload, regardless of deck. This will include cards scheduled and viewed in filtered decks. But, the intent of the 'global' limits is to limit new cards according to the total workload, so this isn't unreasonable. To avoid this, one can set 'enableTotalLimits' to false, then only per-deck limits will be applied and these are based on workload within the deck (i.e. cards studied and scheduled to be studied within that deck (including sub-decks, if there are any)). A regular deck will exclude filtered decks normally. I haven't tried but it might be possible to make a filtered deck a sub-deck of a regular deck - but then it would make sense to include it. By default, a new filtered deck is created as a new top-level deck, at least in my experiments.

If both total limits and per-deck limits are enabled, the limit is the lesser of the two.

Sorry, this is long winded. I'll revisit it in a bit, then update the documentation, hopefully with a short but helpful addition that explains this.

Reunion31 commented 3 years ago

Thank you for looking into this issue, I appreciate it.

I think I got the gist of what you were trying to say. Yes, maybe add this nuance to the description and it will suffice. After all, I did find a workaround: I limit the number of cards in the filtered decks and increase it if I really feel like it. The addon is perfect just like that, sir. I'm using it everyday and happy about it:)

ig3 commented 3 years ago

I have updated the documentation to cover the points raised here. Please let me know if it is still unclear.