[Automatic Ease Scoring] Time-based default card rating / Change default card rating based on flip time (through custom scheduling?)

For the past few months I’ve been using a javascript timer on the front of each card, and rating cards as “hard” if the timer runs out, and I’ve found it pretty helpful. I would really like to try and automate this process—so that, for instance, when I press “enter” to rate the card (or swipe right on mobile), the card is rated based on how long I took to flip it—say, “hard” if over seven seconds, “easy” if less than a second, “good” if between one and seven seconds. Obviously, I can use the buttons—but the simplification of four buttons to two (or, on mobile, buttons and swipes to just swipes) would really streamline the review process. I would only have to worry about right or wrong (pass or fail), and could let Anki handle the ease.

It may already be possible to implement this through custom scheduling, but I have very limited coding experience, and from looking at the manual and snooping around the forum, I don’t think it currently is. (But if it is, please let me know! And if you would be so kind, maybe point me toward the functions/variables/objects(?) I would need to use to make it work!)

Other thoughts

I have tried implementing this myself in order to test it out through a desktop add-on. I found this add-on which changes the default ease based on time, but unfortunately it also auto-rates the card, and I was unable to reverse engineer it for my purposes. (In the end, a desktop add-on isn’t ideal anyway, because I do a significant amount of reviews on mobile.)

But from my experience with the timer, I genuinely think it’s helping—I don’t have to ask myself “Was that hard?” when I rate a card, but instead just “Did the timer run out?”, which has an easy-to-see visual representation. I almost never used the hard button before—I found that stopping and thinking about ease just interrupted my flow. But now that I have the timer, I find the hard button to be fairly effective in dealing with difficult cards. One downside is that I can see the intervals going down—but when I finally get the hang of a difficult card and answer it quickly, I forget to press the “easy” button (I haven’t really used that in the past, either), and the ease ends up staying the same.

I do like the buttons, by the way—if you were to get distracted while reviewing, for instance, you would still need them—but a way to automatically select ease would definitely speed things up, and hopefully increase focus as well.

Bonus: Code for the timer

If you’ve been looking for a Life Drain-esque timer that also works on mobile, here’s the code I’ve been using. It’s a red horizontal bar across the top of your card. It times how long you spend on the front side, and pauses when you flip the card to the back, so you can see how much time it took you to answer. It’s also a good visual indicator for when it’s time to move on from a card, without forcing you ahead in case the answer is on the tip of your tongue.

Front Template:

<div class="time-bar"></div>



[Your Card Info Here]



<script>
var ms = Date.now();

sessionStorage.setItem("time", ms);
</script>

Back Template:

<div class="time-bar"></div>



[Your Card Info Here]



<style id="timer"></style>

<script>
var end = Date.now();
var start = sessionStorage.getItem("time");

var timeElapsed = (end - start) / 1000;

var percentElapsed = timeElapsed / 7;
var barPercent = 1 - percentElapsed;

if (barPercent <= 0) {
document.getElementById("timer").innerHTML = ".time-bar {height: 5px; background: linear-gradient(to bottom, red, #900); animation-play-state: paused; transform: scaleX(0); transform-origin: left center;}";
}
if (barPercent > 0) {
document.getElementById("timer").innerHTML = ".time-bar {height: 5px; background: linear-gradient(to bottom, red, #900); animation-play-state: paused; transform: scaleX(" + barPercent + "); transform-origin: left center;}";
}
</script>

Styling:

.time-bar {
  height: 5px;
  background: linear-gradient(to bottom, red, #900);

  animation: timebar 7s linear forwards;

  transform-origin: left center;
}

@keyframes timebar {
  to {
    transform: scaleX(0);
  }
}

Note that if you want to change the timer duration, in the styling section you will need to change the 7 in the line animation: timebar 7s linear forwards; to your desired number of seconds; on the back template, you will also need to change the last number in the line var percentElapsed = timeElapsed / 7; to that same number. To be honest, I don’t really know how this works because I made it through trial and error and stuff I found online, so I can’t help you if you have problems/want certain things changed. There are almost definitely better ways to implement this, but all I can say is that it works for me on both Anki desktop (Mac) and Anki mobile.

Wait… shouldn’t it be rated Again if time runs out?

Rating failed cards as Hard instead of Again will cause a lot of problems with that deck if you ever switch to the FSRS scheduler later, because its parameters will be badly calculated.


There is an add-on that does automated timer-based rating (only for cards where you type in the answer). I’ve never used it so I don’t know if it works, but perhaps you might find some coding ideas from it.

2 Likes

Well, the timer is more about how long I want to spend on cards. There are cards I’m sure I could get if I spent 15-20 seconds on them, but over time I’ve found that it’s easier just to relearn the card at that point. For me, the timer is a way of telling myself, “Ok, unless you’ve almost got it, it’s time to move on.” I’ve tried auto-advance add-ons like Speed Focus Mode before, but these have the opposite problem, where I’ve almost got the card, but it flips, and I end up closing my eyes while I get the answer, or I get the answer the instant it flips and now have to spend time deciding how I want to rate it. The timer is less distracting and helps me deal with borderline cards better, and the hard button is perfect for those “tip of your tongue” type of cards. To clarify, I don’t use “hard” for cards that I fail to recall.

Thanks for the add-on link. Maybe I’ll find that one easier to alter than the other one.

EDIT: Oh! But that add-on links to another add-on which seems to do what I want! Will have to test it later! Thanks again!

EDIT 2: But, last updated in 2020, and doesn’t seem to work properly based on the comments. Again, will have to test it out.

EDIT 3: It links to this, too, but it also seems to be broken. Seems this topic has been talked about as “automatic ease scoring,” which is not what I’ve used when searching—so there might be a lot more to find.

You can use the built-in auto-advance feature to automatically rate cards with a preset rating after a certain delay.

It’s possible I’m misunderstanding the auto-advance feature, but I don’t think it’s quite what I’m looking for.

I’m reviewing cards normally, but rating the difficulty based on the amount of time it took me to flip the card. I’d like to implement this automatically, so that, for example:

If I clicked “Show Answer” within… pressing enter on the back side will rate the card as…
0-1 seconds easy
1-7 seconds good
7+ seconds hard

and if I fail to recall the card, then I myself will rate it as “again.” In all cases, I flip the card, and choose to either “pass” or “fail” it, by myself.

Essentially, I want to consolidate the three “correct” buttons into one, using recall time as a proxy for difficulty. And I think it makes sense: if I answer a card super quickly, it was easy; if it takes a long time to answer, it was hard; and anything in-between is good. I’m pretty much already doing this, just in a more mechanical way—which is obviously slower than if Anki could do it automatically. (To be clear, I don’t want to do away with the buttons; just to change the default rating on spacebar/enter/swipe based on these criteria.)

I’ve found a number of add-ons (thanks to sprvlcn) that do some variation of this, but unfortunately they all seem to have gone defunct with the introduction of the V3 scheduler. But since I do so many reviews on mobile, I’d really like to know if it could be possible to implement through custom scheduling (which has already helped me a bunch).

The add-ons in question:
  1. SMART SPACEBAR: automatic ease scoring
  2. Automatic Scoring sets the default grade (easy, good, hard &again) based on time
  3. Quick & Easy (easy cards only)

These two add-ons are for typed answers only. In addition to changing the default rating based on answer time, they also auto-advance, which is not what I’m looking for.

  1. auto rate typed answer
  2. Automatic Scoring and Progression (correct and time based)

auto advance can’t do it all, but you can have it rate the card as again or hard for you if you take too long. I’m not sure it’s such a great idea though, as you risk either rating cards with again when you would have eventually remembered them, or rating them as hard when you would not have.

Ah, I want to advance all cards myself. But say I looked at the question for more than 10 seconds before flipping the card—I would like to make the default rating “hard” instead of “good,” so that pressing just “enter” will rate the card as “hard.” If that makes sense.

For that, you’ll need an add-on I’m afraid.

1 Like

Darn, was really hoping it was possible through custom scheduling and I’d just missed something. I think it would be a useful behavior because, generally, if I answer a card super quickly, it’s easy; and a card that takes a long time is usually hard. Given the amount of add-ons attempting this, I’m probably not the only one who would like to be able to set that up. I’ll try and fix one and see how it works. Thank you for your help.

Ok, here’s the add-on.

The following add-on changes the default rating based on how long it takes you to flip a card from front to back. If you flip a card within a second, the default rating (on enter/spacebar) will be set to “easy.” If you flip a card after seven seconds, the default rating will be set to “hard.”

To change the times corresponding to each rating, simply change the numbers in seconds in the following two lines, near the top of the file:

EASY_TIME_MAX = 1
HARD_TIME_MIN = 7

If you change these settings, make sure to understand how the buttons work and the easy and hard multipliers, so that you can choose appropriate rating times.

You can override the new default ratings by simply using the answer buttons, the same way it works now.

I considered uploading this as an add-on, but (1) it’s pretty bare-bones, (2) I need to test it much more extensively, and (3) I have a very limited ability to maintain it should it break in the future. But if you would like to make improvements and/or upload it, please feel free to do anything you like with the following code. It is largely based on the Smart Spacebar add-on mentioned above. It restores what I believe was the original function of Smart Spacebar, which appears to have based the rating on flip time and not answer time, but no longer works that way. Unlike Smart Spacebar, this add-on will not rate cards as “again.”

If you install this add-on (example here), I highly recommend using it in conjunction with an answer confirmation add-on like Color Confirmation to make sure it’s working as intended. (You can also use the timer in my first post above, or Anki’s built-in timer, to get an idea of elapsed time.) I am not a programmer; use this add-on at your own risk. I’ve only tested it on the current version of Anki on Mac (23.12.1), and haven’t had problems so far.

After a few days of using it, the only really idiosyncratic change I’ve made is disabling it for learning-stage cards. I think systematically using the hard button in the learning stage drags things out for too long. The easy button in this stage can be a little hit-and-miss as well; I usually don’t want a card I’ve just learned to end up being rated “easy” just because I answered quickly on the last learning step. A possible solution might be lowering the time for easy cards and raising the time for hard cards, specifically for the learning stage; but I think disabling the add-on here works for now.

If you would like to enable this add-on for the learning stage and see for yourself, delete or comment out the following two lines:

	if self.card.queue == QUEUE_TYPE_LRN or self.card.queue == QUEUE_TYPE_DAY_LEARN_RELEARN:
		new_ease = 3

Other than that, it’s exciting to review using a dynamic pass/fail system, and so far I like it a lot. Reviewing is fast and focused, and ratings are consistent—there’s no longer a need to stop and think about how to rate a card, or indeed to press a different button to rate it, except in special cases like distraction. I used Anki’s built-in preferences to set the “Again” answer key to ', so it’s right next to the enter key. I’ll need to keep an eye on my proportions of hard/easy ratings and overall ease, but considering I’ve been doing this manually for a few months, I don’t expect any problems.

Really happy with this—only wish it was possible on mobile. Thanks again to sprvlcn for pointing me toward these add-ons.

import time
from aqt import gui_hooks
from anki.hooks import addHook
from aqt.reviewer import Reviewer
from anki.consts import *

EASY_TIME_MAX = 1
HARD_TIME_MIN = 7

def startTimer(self):
	global timer_start
	timer_start = time.perf_counter()

def stopTimer(self):
	timer_end = time.perf_counter()
	
	global duration
	duration = timer_end - timer_start
	
	Reviewer._defaultEase = my_defaultEase

def my_defaultEase(self):
	
	new_ease = 3
	
	if self.mw.col.sched.answerButtons(self.card) == 4:
		if duration <= EASY_TIME_MAX:
			new_ease = 4
		elif EASY_TIME_MAX < duration < HARD_TIME_MIN:
			new_ease = 3
		elif HARD_TIME_MIN <= duration:
			new_ease = 2
	elif self.mw.col.sched.answerButtons(self.card) == 3:
		if duration < HARD_TIME_MIN:
			new_ease = 3
		elif HARD_TIME_MIN <= duration:
			new_ease = 2
	
	if self.card.queue == QUEUE_TYPE_LRN or self.card.queue == QUEUE_TYPE_DAY_LEARN_RELEARN:
		new_ease = 3
	
	max_ease = self.mw.col.sched.answerButtons(self.card)
	return min(new_ease, max_ease)

gui_hooks.reviewer_did_show_question.append(startTimer)
gui_hooks.reviewer_did_show_answer.append(stopTimer)

I never thought of using a timer to help rate my cards! Thanks for the idea! I agree that the idea that you have is a good one. I would just want an easy override.

Maybe an answer button based on the time in addition to the regular answer button (but that may complicate things too much.

so i just like the idea of adding the bar to my cards and using it as a guideline.

Yeah, I also have the problem that there are decks I need different easy/hard times for, so there will be cases where I either need to disable the add-on (maybe add an off switch somehow?), override every individual card, or find a way to make the defaults deck-specific (which I’m sure is possible, but will take me time to figure out). So I’ll probably cross that bridge when I get there, and maybe update here.

If my memory serves me correctly, Anki used to highlight the “Show Answer” and “Good” buttons so that you knew what enter/spacebar would do; a similar functionality would make a lot of sense for an add-on like this. An extra button for a “suggested” rating isn’t a bad idea either.

Glad you liked the timer—it really helped me drive down my overall review time and identify harder cards.

Just posting to say I’ve uploaded a basic add-on doing this. It sets the default rating to easy, good, or hard based on how long you take to flip the card. You can override the suggested rating using the buttons.

Pass/Fail Review: Automatic difficulty rating based on answer time (beta ver.)

If you install it, I highly recommend installing Color Confirmation as well, so that you can ensure that this add-on is working as expected. For example, if you edit a card during review, the suggested rating will be reset, and you might not notice unless you have a confirmation add-on.

1 Like

That’s good!

1 Like