孩子端应用题 answer 模式:拍照+填最终答案,交卷归一化匹配秒判(rubric 流程不变)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
jacobxu666
2026-08-20 14:07:12 +08:00
co-authored by Claude Haiku 4.5
parent e896b2be51
commit 255c9a244c
4 changed files with 98 additions and 5 deletions
+13 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { answersMatch, normalizeAnswer } from "./answer-match";
import { answersMatch, normalizeAnswer, solveAnswerHit } from "./answer-match";
describe("normalizeAnswer", () => {
it("分数转小数", () => {
@@ -42,4 +42,16 @@ describe("answersMatch", () => {
it("空期望数组不判对", () => {
expect(answersMatch([], "0.5")).toBe(false);
});
});
describe("solveAnswerHit", () => {
const q = { answers: ["2", "x=2"] };
it("命中最终答案", () => {
expect(solveAnswerHit({ answers: ["2"] }, "2")).toBe(true);
expect(solveAnswerHit(q, " x = 2 ")).toBe(true);
});
it("未命中", () => {
expect(solveAnswerHit(q, "3")).toBe(false);
expect(solveAnswerHit({ answers: [] }, "2")).toBe(false);
});
});