fix(exam_pkg): 判断题返回bool + 填空题扁平数组归一化
grader.py: - 判断题批阅结果 student_answer/correct_answer 统一返回 true/false (bool) 兼容 "对"/"错"/"true"/"false"/True/False/1/0 等所有输入格式 - 填空题新增 _normalize_fill_blank_answer 兜底归一化 修复 LLM 生成扁平数组 ["ans1","ans2"] 导致 1空多选项误判满分的bug - feedback 文本统一用小写 true/false generator.py: - validate_questions_schema 出题时修正扁平数组为二维格式 从源头防止填空题答案格式错误
This commit is contained in:
@@ -169,6 +169,14 @@ def validate_questions_schema(questions: List[Dict]) -> List[Dict]:
|
||||
if not content.get('data', {}).get('options'):
|
||||
continue
|
||||
|
||||
# 填空题答案格式归一化:扁平数组 → 二维数组
|
||||
if q_type == 'fill_blank':
|
||||
ans = content.get('answer')
|
||||
if isinstance(ans, list) and ans and all(isinstance(item, str) for item in ans):
|
||||
# 扁平数组 ["答案1", "答案2"] → [["答案1"], ["答案2"]]
|
||||
content['answer'] = [[item] for item in ans]
|
||||
logger.warning(f"填空题答案格式修正: 扁平数组 → 二维数组 ({len(ans)} 空)")
|
||||
|
||||
validated.append(q)
|
||||
|
||||
return validated
|
||||
|
||||
Reference in New Issue
Block a user