Skip to content
2 changes: 1 addition & 1 deletion lanes/dev1/repair_overlay/frontend/renderers-base.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lanes/dev1/repair_overlay/tests/test_accessibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def test_parallel_witness_renderer_is_keyboard_linear_and_structured(self):
"witnessesLabel.htmlFor='parallel-witnesses'",
"synthesis: synthesis.value",
"witnesses:witnesses.value.split(/\\r?\\n/)",
"кілька посилань у джерелі записані через крапку з комою",
"обидва формати оцінюються однаково",
):
self.assertIn(marker.replace("synthesis: synthesis.value", "synthesis:synthesis.value"), self.renderers)
self.assertNotIn("dto(task,{choice:c.one()})});\nregister('OT_NT_LINK'", self.renderers)
Expand Down
20 changes: 18 additions & 2 deletions runtime_engine/scripture_archive_runtime/grading.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ def _structured_text(value: Any) -> str:
return str(value or "")


def _parallel_witness_set(values: Sequence[Any]) -> set[str]:
"""Normalize authored witness blocks without changing canonical source bytes.

Historical D2 authority stores some array[passage] values as one semicolon-
delimited string while the keyboard UI accepts one passage per line. Treat
those two encodings as equivalent at grading time and nowhere else.
"""
normalized: set[str] = set()
for value in values:
for part in str(value).split(";"):
item = normalize_text(part)
if item:
normalized.add(item)
return normalized


def _feedback(task: TaskDefinition, correctness: Correctness) -> str:
if correctness is Correctness.CORRECT:
return task.success_feedback
Expand Down Expand Up @@ -150,14 +166,14 @@ def grade_parallel_witness_compare(task: TaskDefinition, answer: Any) -> GradeRe
return _result(task, Correctness.INCORRECT, 0.0, details={"validation": "parallel witness synthesis must be non-empty"})
if not isinstance(witnesses, Sequence) or isinstance(witnesses, (str, bytes)) or not witnesses:
return _result(task, Correctness.INCORRECT, 0.0, details={"validation": "parallel witness list must be non-empty"})
submitted_witnesses = {normalize_text(value) for value in witnesses if normalize_text(value)}
submitted_witnesses = _parallel_witness_set(witnesses)
accepted = task.accepted_answer if isinstance(task.accepted_answer, Mapping) else {}
canonical_witnesses = task.grading.get("required_witnesses")
if canonical_witnesses is None:
canonical_witnesses = accepted.get("witnesses")
if not isinstance(canonical_witnesses, Sequence) or isinstance(canonical_witnesses, (str, bytes)) or not canonical_witnesses:
return _result(task, Correctness.INCORRECT, 0.0, details={"validation": "missing canonical parallel witnesses"})
expected_witnesses = {normalize_text(value) for value in canonical_witnesses if normalize_text(value)}
expected_witnesses = _parallel_witness_set(canonical_witnesses)
if not expected_witnesses:
return _result(task, Correctness.INCORRECT, 0.0, details={"validation": "empty canonical parallel witnesses"})

Expand Down
22 changes: 20 additions & 2 deletions runtime_engine/tests/test_grading.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,27 @@ def test_parallel_witness_compare_requires_synthesis_and_exact_witness_set(self)
self.assertEqual(Correctness.CORRECT, exact.correctness)
self.assertEqual(1.0, exact.score)

split_lines = self.registry.grade(
task,
{"synthesis": synthesis, "witnesses": ["Acts 9:10–19", "Acts 22:12–16"]},
)
self.assertEqual(Correctness.CORRECT, split_lines.correctness)
self.assertEqual(1.0, split_lines.score)

missing_witness = self.registry.grade(task, {"synthesis": synthesis, "witnesses": ["Acts 9:10–19"]})
self.assertEqual(Correctness.INCORRECT, missing_witness.correctness)
self.assertEqual(0.0, missing_witness.score)
self.assertEqual(Correctness.PARTIAL, missing_witness.correctness)
self.assertEqual(0.5, missing_witness.score)

extra_witness = self.registry.grade(
task,
{
"synthesis": synthesis,
"witnesses": ["Acts 9:10–19", "Acts 22:12–16", "Acts 26:12–18"],
},
)
self.assertEqual(Correctness.PARTIAL, extra_witness.correctness)
self.assertAlmostEqual(2 / 3, extra_witness.score)
self.assertIn("acts 26 12 18", extra_witness.details["witnesses"]["extras"])

weak_synthesis = self.registry.grade(
task,
Expand Down
Loading