Skip to content

Conversation

L-M-Sherlock
Copy link
Contributor

@L-M-Sherlock L-M-Sherlock commented Mar 4, 2025

This PR adds a new "Grade Now" feature to the browser, allowing users to grade cards directly without going through the review process. This is useful for quickly adjusting card states in bulk.

Changes

  1. Added a new action in the browser UI with keyboard shortcut Ctrl+Shift+G
  2. Added backend support for grading cards outside the normal review flow
  3. Added proper queue management for graded cards
  4. Added translation strings and UI elements

Implementation Details

The implementation includes:

  • A new GradeNow operation in the backend
  • A dialog in the browser that shows the four standard grading buttons (Again, Hard, Good, Easy)
  • Proper handling of queue updates after grading
  • Support for grading multiple selected cards at once

Screenshots

image image image

close #3694

@iamllama
Copy link
Contributor

iamllama commented Mar 4, 2025

Could this be implemented as a submenu on "Grade Now" instead of opening another dialog? Similar to how ajt's card management addon currently does it. I understand that the dialog mirrors the reviewer's button bar, but feel it might be too clunky in practice

197412891-fcef27e4-49ed-4175-a42d-a50ef2252151

@Expertium
Copy link
Contributor

Expertium commented Mar 4, 2025

I think "Set Due Date" should be removed then
Relevant: open-spaced-repetition/fsrs4anki#675

Also, shouldn't it be "Rate now", since the manual usually says "ratings" and not "grades"?
Though, personally, I prefer "grades".

@user1823
Copy link
Contributor

user1823 commented Mar 4, 2025

I think "Set Due Date" should be removed then

No, both have their own use cases.

  • Grade now is used when the user has recalled the material externally - successfully or unsuccessfully .
  • Set due date is used when the user doesn't want to answer the card at that time (e.g. got passively exposed to the information).

SuperMemo also has both the options: https://supermemopedia.com/wiki/Ctrl%2BJ_vs._Ctrl%2BShift%2BR

@Expertium
Copy link
Contributor

I thought the whole point of adding "Grade Now" was to remove "Set Due Date" since FSRS can't properly work with it?

@JSchoreels
Copy link
Contributor

Would it be feasible to make it accessible through APIs like AnkiConnect so third party tools like Yomitan could be used to mark a word as "Forgotten" ? For example, if I'm reading a book, I hover a word I forgot, if I see it's already in Anki and has reviews, I could mark it as "Again" meaning I forgot it, and thus my external review would be counted by the scheduler as a review

@user1823
Copy link
Contributor

user1823 commented Mar 4, 2025

if I'm reading a book, I hover a word I forgot, if I see it's already in Anki and has reviews, I could mark it as "Again" meaning I forgot it, and thus my external review would be counted by the scheduler as a review

Yeah, that's the purpose of adding the Grade now feature.

However, I can't say whether connecting this to third party tools would be easily possible or not.

@YukiNagat0
Copy link
Contributor

YukiNagat0 commented Mar 4, 2025

However, I can't say whether connecting this to third party tools would be easily possible or not.

All that’s needed from Anki side is to expose the grade_now API (in the programming interface sense, not a web-API). This would allow tools like Anki Connect or other Anki add-ons to interact with the feature directly through Python code. Of course, it would be add-on developer work to implement this feature in theirs add-ons by using exposed API.

@YukiNagat0
Copy link
Contributor

upd: It’s worth noting that Anki Connect already provides a Graphical Actions API, which allows users to view selected cards. This means Anki Connect's existing API is already capable of handling the task.

For instance, Yomitan demonstrates this functionality by enabling users to quickly view duplicates (cards already in their collection) for a specific word. This same mechanism could be adapted to Grade Now a card:

  1. Scan the word you want to Grade Now (via pop-up or Search Page).
  2. Click the View added note button.
  3. Grade the card directly in Anki using the built-in Grade Now interface.

Demonstration:

Demo.mp4

@YukiNagat0
Copy link
Contributor

The advantage of leveraging the Graphical Actions API is that developers of end-apps (e.g., Yomitan) wouldn’t need to create their own custom interface for displaying grades or handling grading. Instead, they can seamlessly redirect users to Anki’s native interface, where users can perform a variety of actions on the card: grade it, edit it, delete it, and so on.

@brishtibheja
Copy link
Contributor

brishtibheja commented Mar 6, 2025

I thought the whole point of adding "Grade Now" was to remove "Set Due Date" since FSRS can't properly work with it?

@Expertium I think people should be allowed to grade the cards when they're using SDD. Or, allow setting a due date when using GN. That was also the initial idea with this feature if I remember correctly, i.e. reschedules will stop having a manual 0 entry making it easier for FSRS to schedule those cards.

I'll leave the matter to Jarrett however.

@L-M-Sherlock
Copy link
Contributor Author

To solve the set due date problem, we may require the user to grade before set due date.

@Expertium
Copy link
Contributor

To solve the set due date problem, we may require the user to grade before set due date.

I feel like we need to merge both GN and SDD into one feature.

@brishtibheja
Copy link
Contributor

To solve the set due date problem, we may require the user to grade before set due date.

A normal review just before a SDD would also help? And how will people be let known that needs to be done? I feel changes to SDD needs to be made (maybe in a different PR).

@Expertium
Copy link
Contributor

Expertium commented Mar 9, 2025

@dae seems like nobody agrees on anything. Let me summarize:

  1. We could combine "Grade Now" and "Set Due Date" into the same feature. Not sure how exactly, though.
    I think we could ask the user to select a grade and optionally an interval length.
    If the user only selected a grade, the intervals will be handled by SM-2/FSRS.
    If the user selected a grade and provided and interval length as well, we get SDD but with proper grades.
  2. We could keep GN and SDD as two separate features, but that would be awkward and confusing,

@brishtibheja
Copy link
Contributor

I don't think it'd be confusing per se. Just that the issues with SDD will still be there for some users. There's a good way to solve those by having users use GN along with SDD, but if they're seperated like this users won't know they've got to do this.

@Danika-Dakika
Copy link
Collaborator

[I question whether a PR for one feature is a useful place to discuss removing/altering another feature, but I'll respond here, since the discussion is already underway.]

There's nothing confusing about having Set Due Date and Grade Now as 2 separate features -- they do completely different things. It's great if Grade Now can address some SDD use-cases, specific to New cards, that were challenges for FSRS, but it certainly doesn't cover all of the uses. For instance, Grade Now doesn't allow a user to set a card to be due on a particular date/range.

My primary use case for SDD is when I've made major changes to a note, even adding New siblings that will be introduced soon, and I don't want to wait months to study the existing Review siblings again. For that, Grade Now would be useless to me. I don't want to skip studying those cards and grade them today -- I want to actually study them, just sooner.

SDD is also a reasonable technique for addressing a missed-day/vacation backlog: scatter those overdue cards across the next X days. There are better techniques -- but it's a fast and simple alternative for folks who don't want to deal with Filtered decks, and it's better by far than the "postpone your whole collection X days"-type add-ons.

Copy link
Member

@dae dae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Jarrett, I've left some comments about the technical side of things below.

I too find myself wondering how exactly we should integrate SDD and GC into Anki. Would some sort of unified interface where the user could specify grade and/or due date make sense? Are there situations where it would make sense for FSRS users to use SDD without grading the card?

@user1823
Copy link
Contributor

Are there situations where it would make sense for FSRS users to use SDD without grading the card?

Currently, I use SDD in only one situation and in that situation, grading the card would be harmful.

I use SDD when I am in the reviewer and encounter a card that I don't want to answer for the next few days (depending on its stability). Basically, I use SDD as a "prolonged bury" feature.

Why I don't want to answer it?
It's because I saw a very related card that day or 1-2 days ago, which is artificially boosting my memory of the answer. If I grade the card, it will be pushed way far in the future and I will likely forget it by then. By using SDD, I "bury" the card for 10-15 days, assuming that the effect of the passive exposure would have vanished till then and I can test myself fairly.

What would happen if I rate it Good and then use SDD?
Experience suggests that if I press Good on a card after 1 year and then press Again after 10 days, FSRS gets terribly confused (because FSRS doesn't know that I rated Good only because I read the fact 5 minutes ago).
In fact, in the past, I have had to delete these faulty Good ratings from my collection in order to make FSRS work in a reasonable manner. See open-spaced-repetition/fsrs4anki#572 (comment)

- Add `from_queue` field to `CardAnswer` struct and proto message
- Modify `answer_card_inner` to handle queue updates based on `from_queue`
- Remove `grade_card` method and consolidate card answering logic
- Update related test cases to set `from_queue` flag
- Refactor `grade_now` to collect processed card IDs first
- Add new `update_queues_for_processed_cards` method for efficient batch queue updates
- Improve queue management by removing entries and updating counts in a single pass
- Remove individual queue update method in favor of batch processing
Copy link
Member

@dae dae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting there! A couple more technical concerns below.

On the GUI end, I agree with @iamllama that a dropdown may be a better choice - the current pop-up feels a bit clunky, and can't be navigated easy with a keyboard. But that can be deferred to a follow-up PR by someone with more of a GUI focus.

Or not. I still also find myself wondering whether it might make sense to present these two features with a unified interface, allowing one to grade & optionally set due date or vice versa, but I don't have any great ideas for how it could be done at the moment.

// We don't need to save undo information here since
// this is a batch operation
// and grade now can be undone as a normal op
}
Copy link
Member

@dae dae Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this more carefully, I find myself wondering if you've actually accidentally taken the second approach I mentioned? maybe_clear_study_queues_after_op() does not cover the grade now case, so the next queue operation after this one causes the queues to be rebuilt. If I'm right about that, all this code could be dropped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know maybe_clear_study_queues_after_op() before you mentioned it :-). I will check whether the code is useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I guess this info means I can remove the function update_queues_for_processed_cards safely?

[rslib/src/scheduler/queue/mod.rs:213:9] &op = OpChanges {
    op: GradeNow,
    changes: StateChanges {
        card: true,
        note: false,
        deck: true,
        tag: false,
        notetype: false,
        config: false,
        deck_config: false,
        mtime: true,
    },
}
[rslib/src/scheduler/queue/mod.rs:214:9] &op.requires_study_queue_rebuild() = true

@dae dae merged commit 0e31efa into ankitects:main Mar 15, 2025
1 check passed
@L-M-Sherlock L-M-Sherlock deleted the Feat/grade-now branch March 15, 2025 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a 'grade now' feature
9 participants