diff --git a/exam_pkg/api.py b/exam_pkg/api.py index ba6e573..9296544 100644 --- a/exam_pkg/api.py +++ b/exam_pkg/api.py @@ -356,6 +356,8 @@ def api_grade_answers(): answers = data.get('answers', []) if not answers: return error_response("MISSING_PARAMS", BAD_REQUEST, "缺少答案数据", http_status=400) + if not isinstance(answers, list): + return error_response("INVALID_PARAMS", BAD_REQUEST, "answers 必须为数组", http_status=400) # 校验每道题的 question_type for i, ans in enumerate(answers):