From 8a85c58844f6a5c86cc148dcf8b06c94e1aaf8dc Mon Sep 17 00:00:00 2001 From: rjgoif Date: Sun, 24 Nov 2019 14:07:06 -0500 Subject: [PATCH] initial upload of add-on files --- __init__.py | 25 ++++++ daily_learns_first.py | 115 ++++++++++++++++++++++++++++ rj_daily_learns_early_002_legacy.py | 46 +++++++++++ 3 files changed, 186 insertions(+) create mode 100644 __init__.py create mode 100644 daily_learns_first.py create mode 100644 rj_daily_learns_early_002_legacy.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..8d0d764 --- /dev/null +++ b/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +######################################################################### +# Copyright (C) 2015–2020 by anki/github user rjgoif +# # +# This program is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program; if not, see . # +######################################################################### + +# loads the add-on into Anki. +# don't edit this file. Edit the called file instead. + + + +from . import daily_learns_first \ No newline at end of file diff --git a/daily_learns_first.py b/daily_learns_first.py new file mode 100644 index 0000000..8ba4147 --- /dev/null +++ b/daily_learns_first.py @@ -0,0 +1,115 @@ +# # # -*- coding: utf-8 -*- + +######################################################################### +# Copyright (C) 2014–2020 by anki/github user rjgoif +# # +# This program is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program; if not, see . # +######################################################################### + +## this is an Anki 2.1 update of my popular Anki 2.0 add-on +## that changes the order of your daily reviews: + +## This is a simple add-on that inserts the daily-learning cards, i.e. +## cards in the learning queue with intervals that crossed the day turnover, +## before starting standard reviews (the green number). Normally these cards +## daily-learning cards go last, but I want them to go first. + +## as of beta 32, there is an option to enable this built into Anki if you are using the +## v2 scheduler. +## HOWEVER, I still think the learning reviews should come before new reviews. So I have built that in. If you use v2, this add-on respects the option toggle built into native Anki. +## I won't be testing v2 myself, so if it works for you please let me know via Github + +## a legacy version will be uploaded to Github for anyone holding out with Anki 2.0. + +## https://github.com/rjgoif/ + +# # # # # # # # # # # # # # # # + +__version__ = '2.1.001' + + +# classic (ie from v2.0) scheduler +import anki.sched as oldSched +def _getCardReordered(self): + "Return the next due card id, or None." + # learning card due? + c = self._getLrnCard() + if c: + return c + # day learning card due? + c = self._getLrnDayCard() + if c: + return c + # new first, or time for one? + if self._timeForNewCard(): + c = self._getNewCard() + if c: + return c + # card due for review? + c = self._getRevCard() + if c: + return c + # new cards left? + c = self._getNewCard() + if c: + return c + # collapse or finish + return self._getLrnCard(collapse=True) + + +oldSched.Scheduler._getCard = _getCardReordered + + + + +# # Anki 2.1 scheduler v2 +import anki.schedv2 as oldSchedv2 +def _getCardReorderedv2(self): + "Return the next due card id, or None." + # learning card due? + c = self._getLrnCard() + if c: + return c + + # day learning first and card due? + dayLearnFirst = self.col.conf.get("dayLearnFirst", False) + c = dayLearnFirst and self._getLrnDayCard() + if c: + return c + + # new first, or time for one? + if self._timeForNewCard(): + c = self._getNewCard() + if c: + return c + + # card due for review? + c = self._getRevCard() + if c: + return c + + # day learning card due? + c = not dayLearnFirst and self._getLrnDayCard() + if c: + return c + + # new cards left? + c = self._getNewCard() + if c: + return c + + # collapse or finish + return self._getLrnCard(collapse=True) + +oldSchedv2.Scheduler._getCard = _getCardReorderedv2 \ No newline at end of file diff --git a/rj_daily_learns_early_002_legacy.py b/rj_daily_learns_early_002_legacy.py new file mode 100644 index 0000000..ce6b0b6 --- /dev/null +++ b/rj_daily_learns_early_002_legacy.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# by Anki user rjgoif +# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html + +# #################################################################### + +# This is a simple add-on that inserts the daily-learning cards, i.e. +# cards in the learning queue with intervals that crossed the day turnover, +# before starting other reviews (new cards, review cards). Normally these cards +# go last, but I want them to go first. + + +# #################################################################### + + + +import anki.sched as oldSched + +def _getCardReordered(self): + "Return the next due card id, or None." + # new first, or time for one? + if self._timeForNewCard(): + c = self._getNewCard() + if c: + return c + # learning card due? + c = self._getLrnCard() + if c: + return c + # day learning card due? + c = self._getLrnDayCard() + if c: + return c + # card due for review? + c = self._getRevCard() + if c: + return c + # new cards left? + c = self._getNewCard() + if c: + return c + # collapse or finish + return self._getLrnCard(collapse=True) + + +oldSched.Scheduler._getCard = _getCardReordered \ No newline at end of file