新增 categorisation 任务类型支持

HAR 文件分析发现新的任务类型 categorisation(分类题),
新增对应的答题策略函数并注册到 RESPONSE_BUILDERS 字典中。
优先使用服务器返回的 expectedResponse,回退时提交空映射。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 22:51:51 +08:00
parent 401c879ffd
commit 14433589ac
+17
View File
@@ -294,6 +294,22 @@ def build_response_flashcards(task: TaskInfo) -> dict:
} }
def build_response_categorisation(task: TaskInfo) -> dict:
"""categorisation: 分类题 — 优先使用expectedResponse,否则提交空映射"""
expected = task.expected_response.get("contents", {}).get("categorisation", {})
if expected:
return {"categorisation": expected}
# 回退:从task.detail获取items,全部设为未分类
cat = task.task_detail.get("categorisation", {})
items = cat.get("items", [])
result = {}
for item in items:
iid = item.get("id", "")
result[iid] = {"id": iid, "userInput": ""}
return {"categorisation": result}
# 任务类型 → 答题策略映射 # 任务类型 → 答题策略映射
RESPONSE_BUILDERS = { RESPONSE_BUILDERS = {
"media-with-time-markers": build_response_media_with_time_markers, "media-with-time-markers": build_response_media_with_time_markers,
@@ -305,6 +321,7 @@ RESPONSE_BUILDERS = {
"speaking-practice": build_response_speaking_practice, "speaking-practice": build_response_speaking_practice,
"multiple-choice": build_response_multiple_choice, "multiple-choice": build_response_multiple_choice,
"text-highlights": build_response_text_highlights, "text-highlights": build_response_text_highlights,
"categorisation": build_response_categorisation,
} }