Randomize questions on every Anki regen
Also make explanation section slightly more readable
This commit is contained in:
+38
-4
@@ -33,6 +33,7 @@ import json
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import secrets
|
||||
import shutil
|
||||
import sqlite3
|
||||
import sys
|
||||
@@ -1415,7 +1416,7 @@ CARD_CSS = """
|
||||
font-size: 15px;
|
||||
line-height: 1.5;
|
||||
color: #333;
|
||||
font-style: italic;
|
||||
font-style: normal;
|
||||
}
|
||||
.af-explanation-header {
|
||||
font-family: Arial, sans-serif;
|
||||
@@ -1451,6 +1452,28 @@ CARD_CSS = """
|
||||
color: #1a73e8;
|
||||
text-decoration: none;
|
||||
}
|
||||
.nightMode .af-explanation,
|
||||
.card.nightMode .af-explanation {
|
||||
border-top-color: #555;
|
||||
color: #ddd;
|
||||
}
|
||||
.nightMode .af-explanation-header,
|
||||
.card.nightMode .af-explanation-header {
|
||||
color: #aaa;
|
||||
}
|
||||
.nightMode .af-explanation-source,
|
||||
.card.nightMode .af-explanation-source {
|
||||
color: #bbb;
|
||||
}
|
||||
.nightMode .af-explanation-source a,
|
||||
.card.nightMode .af-explanation-source a {
|
||||
color: #8ab4f8;
|
||||
}
|
||||
.nightMode .af-explanation-low-confidence,
|
||||
.card.nightMode .af-explanation-low-confidence {
|
||||
background: #4a3510;
|
||||
color: #ffd77a;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
@@ -1481,6 +1504,13 @@ def build_epoch_from_manifest(manifest, override_epoch=None):
|
||||
) from e
|
||||
|
||||
|
||||
def resolve_shuffle_seed(seed):
|
||||
"""Return the explicit shuffle seed or a fresh one for this build."""
|
||||
if seed is not None:
|
||||
return seed
|
||||
return secrets.token_hex(16)
|
||||
|
||||
|
||||
def build_all(data_dir, out_dir, seed, override_epoch=None, explanations_path=None):
|
||||
"""Build every category's `.apkg` and return their result dicts.
|
||||
|
||||
@@ -1546,8 +1576,11 @@ def _parse_args(argv):
|
||||
)
|
||||
parser.add_argument(
|
||||
"--seed",
|
||||
default="amateurfunk-anki-v1",
|
||||
help="deterministic seed for answer shuffling",
|
||||
default=None,
|
||||
help=(
|
||||
"deterministic seed for answer shuffling; omit to reshuffle "
|
||||
"answers on every build"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--epoch",
|
||||
@@ -1573,11 +1606,12 @@ def _parse_args(argv):
|
||||
def main(argv=None):
|
||||
"""Top-level entry point. Returns an exit code; never raises."""
|
||||
args = _parse_args(argv)
|
||||
seed = resolve_shuffle_seed(args.seed)
|
||||
try:
|
||||
results = build_all(
|
||||
args.data,
|
||||
args.out,
|
||||
seed=args.seed,
|
||||
seed=seed,
|
||||
override_epoch=args.epoch,
|
||||
explanations_path=args.explanations,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user