FX-2: surface born-digital per-part marks from auto-map
The board grammar already parses per-part marks ([N marks] / "Total for Question N is M marks"), but they were dropped building the first-pass template and the row mapper hardcoded max_marks=0 — so every born-digital paper came back with zero marks for a teacher to re-key by hand. Thread the parsed mark through: bands.py derive_bands now carries each part's `marks`, template.build passes it into part_bands, and _map_first_pass_to_rows reads it via a defensive _safe_marks (non-negative int; unknown/None -> 0, so image-only OCR — which has no marks yet — is unchanged). Containers still roll up from parts. Adds test_auto_map_surfaces_born_digital_part_marks. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
6c73174829
commit
cce46305c9
@@ -642,6 +642,21 @@ def test_auto_map_fast_path_merges_ai_rows_and_returns_detail(monkeypatch):
|
||||
assert store["exam_boundaries"] and store["exam_boundaries"][0]["derivation"] == "docling-main-band"
|
||||
|
||||
|
||||
def test_auto_map_surfaces_born_digital_part_marks(monkeypatch):
|
||||
# Regression: the born-digital grammar parses per-part marks, but the row mapper hardcoded
|
||||
# max_marks=0. A part band carrying `marks` must flow through to the question row's max_marks.
|
||||
store = _template_with_source()
|
||||
store.update({"exam_questions": [], "exam_response_areas": [], "exam_boundaries": [], "exam_template_layout": []})
|
||||
client, store = make_client(store=store)
|
||||
fp = _first_pass_template()
|
||||
fp["pages"]["1"]["part_bands"][0]["marks"] = 4
|
||||
_patch_auto_map(monkeypatch, store, fast=True)
|
||||
monkeypatch.setattr(templates_mod, "auto_map", lambda *_a, **_k: fp) # override with the marked part band
|
||||
assert client.post("/api/exam/templates/t1/auto-map").status_code == 200
|
||||
part = next(q for q in store["exam_questions"] if q.get("label") == "01.1")
|
||||
assert part["max_marks"] == 4
|
||||
|
||||
|
||||
def test_auto_map_deduplicates_repeated_response_area_ids(monkeypatch):
|
||||
store = _template_with_source()
|
||||
client, store = make_client(store=store)
|
||||
|
||||
Reference in New Issue
Block a user