diff --git a/deeptutor/learning/semantic_assessment.py b/deeptutor/learning/semantic_assessment.py index 1abb1a984..f5611b1a1 100644 --- a/deeptutor/learning/semantic_assessment.py +++ b/deeptutor/learning/semantic_assessment.py @@ -114,9 +114,11 @@ def exact_verdict(question, answer): confidence=1, feedback=question.explanation or "Matches the stored answer.", ) - # Only a short answer is the bare number itself; open answers may explain - # one, and an ambiguous separator has two readings, so both stay semantic. - if question.question_type == "short" and numeric[0].comparable and not numeric[0].ambiguous: + # Only a single short number is final: open answers may explain one, an + # ambiguous reading may still be right, and multi-part answers may earn + # partial credit, so all of those stay semantic. + first = numeric[0] + if question.question_type == "short" and len(first.parts) == 1 and not first.ambiguous: return Verdict( result="incorrect", confidence=1, diff --git a/deeptutor/learning/tests/test_grading.py b/deeptutor/learning/tests/test_grading.py index 20eb09dd8..738cfb0be 100644 --- a/deeptutor/learning/tests/test_grading.py +++ b/deeptutor/learning/tests/test_grading.py @@ -333,3 +333,8 @@ class TestExactVerdictNumeric: assert self._verdict("125000", "125.000") is None assert self._verdict("about 1250", "1250.50") is None assert self._verdict("1300", "1250.50", accepted=["ca. 1300"]).result == "correct" + + def test_multi_part_mismatch_keeps_partial_credit_open(self): + assert self._verdict("a) 1.000; b) 260", "a) 1.000; b) 250") is None + assert self._verdict("1250", "Goodwill = 1.250; NCI = 300") is None + assert self._verdict("a) 1.000; b) 250", "a) 1.000; b) 250").result == "correct"