summaryrefslogtreecommitdiffstats
path: root/src/session.py
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2024-09-26 07:43:17 +0200
committerEddy Pedroni <epedroni@pm.me>2024-09-26 07:43:17 +0200
commitce76b00d7b2ccac6843732f92becfabb753864a0 (patch)
treef240e4d42512924acfa5e1b5032ff0af17979959 /src/session.py
parent5931fddd909711fa20ea9afcbf656586b7d30c22 (diff)
Improve documentation
Diffstat (limited to 'src/session.py')
-rw-r--r--src/session.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/session.py b/src/session.py
index 33870aa..f30160f 100644
--- a/src/session.py
+++ b/src/session.py
@@ -6,17 +6,38 @@ from parser import parseFiles
from state_json import load, save
class Session:
+ """
+ Represents a play session. During a session, multiple practice and test runs
+ can be made with the same scheduler.
+ """
def __init__(self, scheduler_name: str, card_files: list[str], state_file: str):
self._cards = parseFiles(card_files)
self._state_file = state_file
self._scheduler = getSchedulerClass(scheduler_name)(self._cards, load(state_file))
def practice(self, size: int) -> Iterator[Card]:
+ """
+ Yields cards for a practice run of the requested size.
+
+ Practice runs do not affect the scheduler state.
+ """
ids = self._scheduler.practice(size)
for id in ids:
yield self._cards[id]
def test(self, size: int) -> Iterator[tuple[Card, Callable]]:
+ """
+ Yields cards for a test run of the requested size.
+
+ A function is yielded with each card that takes single boolean argument.
+ The UI is expected to call the function for each card to indicate whether
+ the user correctly guessed the card (True) or not (False).
+
+ Multiple subsequent calls to the same function overwrite past results.
+
+ When the test run is done, the scheduler state is updated with the
+ collected results
+ """
ids = self._scheduler.practice(size)
results = {}