Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Randomises the due dates of the cards in a deck, but only bringing them closer to being due. Run in Anki's REPL console (ctrl+:)
# Randomises the due dates of the cards in a deck, but only bringing them closer to being due
# Run in Anki's REPL console (ctrl+:)
from random import random
from math import floor
deckName = u"わかった!"
for cid in self.col.decks.cids(self.col.decks.byName(deckName)["id"], True):
card = self.col.getCard(cid)
due = abs(card.due - self.col.sched.today)
isDuePositive = card.due - self.col.sched.today >= 0
if due >= 2:
adjustment = floor(random() * (due / 2 + 1))
card.due = (due - adjustment) * (1 if isDuePositive else -1) + self.col.sched.today
card.flushSched()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.