git » alan.git » commit 255f986

Add version metadata to answer key output

author Alan Dipert
2025-12-04 16:19:10 UTC
committer Alan Dipert
2025-12-04 16:19:10 UTC
parent 82479a0ad55933317cae2d0852866d8d1fc454f2

Add version metadata to answer key output

render_text.py +15 -0

diff --git a/render_text.py b/render_text.py
index 2ab9f6e..da42d6a 100644
--- a/render_text.py
+++ b/render_text.py
@@ -79,6 +79,21 @@ def render_booklet(data: Dict[str, Any]) -> str:
 
 def render_key(data: Dict[str, Any]) -> str:
     lines = ["# Answer Key", ""]
+    meta = data.get("meta", {})
+    info_bits = []
+    if meta.get("seed") is not None:
+        info_bits.append(f"seed={meta['seed']}")
+    if meta.get("git_sha"):
+        info_bits.append(f"sha={str(meta['git_sha'])[:7]}")
+    params = meta.get("generation_params") or {}
+    if params:
+        joined = ", ".join(f"{k}={v}" for k, v in sorted(params.items()))
+        info_bits.append(f"params: {joined}")
+    if info_bits:
+        lines.append(
+            f"<div style=\"font-size: 0.7em; font-family: monospace; margin: 0 0 4px 0;\">"
+            f"Test Version: {'; '.join(info_bits)}</div><br/>"
+        )
     for section in data.get("sections", []):
         for q in section.get("questions", []):
             correct = next((o for o in q["options"] if o["is_correct"]), None)