"""Loading challenge definitions and submission files.""" from __future__ import annotations import json from pathlib import Path def load_challenges(challenges_dir: Path) -> dict[str, dict]: out = {} for p in sorted(Path(challenges_dir).glob("*/challenge.json")): with open(p) as f: ch = json.load(f) ch["_dir"] = p.parent out[ch["challenge_id"]] = ch return out def load_submissions(solutions_dir: Path) -> list[dict]: """Return every submission JSON under solutions//*.json, with _path and _dir_challenge set.""" out = [] for p in sorted(Path(solutions_dir).glob("*/*.json")): with open(p) as f: sub = json.load(f) sub["_path"] = p sub["_dir_challenge"] = p.parent.name out.append(sub) return out