fix: restore main runtime sources and cache consistency

This commit is contained in:
User
2026-07-14 14:19:36 +08:00
parent e40989eeab
commit f951bc6598
15 changed files with 1664 additions and 29 deletions

View File

@@ -219,6 +219,41 @@ def grade_fill_blank(answer: Dict) -> Dict:
student_answers = answer.get('student_answer', [])
max_score = answer.get('max_score', 4.0)
if not isinstance(student_answers, list):
logger.warning(
"填空题学生答案格式错误: 期望列表,实际为 %s",
type(student_answers).__name__,
)
return {
"question_id": answer.get('question_id'),
"score": 0,
"max_score": max_score,
"grading_status": "failed",
"details": {
"error": f"学生答案格式错误,期望列表,实际为 {type(student_answers).__name__}"
},
}
for index, student_answer in enumerate(student_answers):
if not isinstance(student_answer, str):
logger.warning(
"填空题学生答案第 %s 项格式错误: 期望字符串,实际为 %s",
index + 1,
type(student_answer).__name__,
)
return {
"question_id": answer.get('question_id'),
"score": 0,
"max_score": max_score,
"grading_status": "failed",
"details": {
"error": (
f"填空题学生答案第 {index + 1} 项格式错误,期望字符串,"
f"实际为 {type(student_answer).__name__}"
)
},
}
# 归一化答案格式(修复 LLM 生成的扁平数组问题)
blank_count = question_content.get('data', {}).get('blank_count', 0)
correct_answers = _normalize_fill_blank_answer(correct_answers, blank_count)