2
# scheduler.py <Peter.Bienstman@UGent.be>
5
from mnemosyne.libmnemosyne.component import Component
8
class Scheduler(Component):
11
component_type = "scheduler"
15
"""Called when starting the scheduler for the first time."""
17
raise NotImplementedError
21
"""For code that needs to run periodically."""
25
def set_initial_grade(self, cards, grade):
27
"""Sets the initial grades for a set of sister cards, making sure
28
their next repetitions do no fall on the same day.
30
Called when cards are given their initial grade outside of the
31
review process, e.g. when the user gives an initial grade when
32
adding a new card in the GUI. Therefore, 'unseen' is still left to
33
True, as this card has not yet been seen in the interactive review
36
Cards which don't have initial grade information available (e.g. for
37
cards created during import or conversion from different card type),
38
get their initial grade when they are encountered in the interactive
39
review process for the first time.
41
In both cases, this initial grading is seen as the first repetition.
43
In this way, both types of cards are treated in the same way. (There
44
is an ineffectual asymmetry left in the log messages they generate,
45
but all the relevant information can still be parsed from them.)
49
raise NotImplementedError
51
def avoid_sister_cards(self, card):
53
"""Change card.next_rep to make sure that the card is not scheduled
54
on the same day as a sister card.
56
Factored out here to allow this to be used by e.g. MnemoGogo.
60
raise NotImplementedError
62
def rebuild_queue(self, learn_ahead=False):
64
"""Called by the rest of the library when an existing queue risks
65
becoming invalid, e.g. when cards have been deleted in the GUI.
66
'next_card' also makes use of this in certain implementations.
70
raise NotImplementedError
72
def is_in_queue(self, card):
74
"""To check whether the queue needs to be rebuilt, e.g. if it contains
75
a card that was deleted in the GUI.
79
raise NotImplementedError
81
def remove_from_queue_if_present(self, card):
82
raise NotImplementedError
84
def next_card(self, learn_ahead=False):
85
raise NotImplementedError
87
def is_prefetch_allowed(self):
89
"""Can we display a new card before having processed the grading of
94
raise NotImplementedError
96
def grade_answer(self, card, new_grade, dry_run=False):
97
raise NotImplementedError
99
def scheduled_count(self):
100
raise NotImplementedError
102
def non_memorised_count(self):
103
raise NotImplementedError
105
def active_count(self):
106
raise NotImplementedError
108
def card_count_scheduled_n_days_from_now(self, n):
110
"""Yesterday: n=-1, today: n=0, tomorrow: n=1, ... .
112
Is not implemented in the database, because this could need internal
113
scheduler information.
116
raise NotImplementedError
118
def next_rep_to_interval_string(self, next_rep, now=None):
120
"""Converts next_rep to a string like 'tomorrow', 'in 2 weeks', ...
124
raise NotImplementedError
126
def last_rep_to_interval_string(self, last_rep, now=None):
128
"""Converts last_rep to a string like 'yesterday', '2 weeks ago', ...
132
raise NotImplementedError