批量检查试卷 (Check Batch)
Method: POST
Endpoint:
/api/v1/exams/check
一次检查多个已经上传的答题卡文件。试卷 id 和文件 id 全部放在请求体中,不放在路径里。
请求参数
Body (JSON):
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
examId |
Integer | 是 | 要检查的试卷 id |
fileIds |
Integer[] | 是 | 上传文件 id 数组,1–50 个 |
示例:
{
"examId": 1,
"fileIds": [1, 2, 3]
}
fileIds 来自 上传文件 返回的 data.fileId。
响应示例
{
"data": {
"examId": 1,
"total": 2,
"successCount": 1,
"failureCount": 1,
"results": [
{
"fileId": 1,
"success": true,
"answers": {
"q1": "A",
"q13": null
},
"metrics": {
"q1": {
"type": "mark",
"answer": "A",
"mode": "single",
"selected": 0,
"selectedOptions": ["A"],
"markedCount": 1,
"ratios": [0.91, 0.02, 0.01, 0],
"confidence": 0.89,
"expected": "A",
"correct": true,
"uncertain": false
},
"q13": {
"type": "other",
"answer": null,
"mode": "other",
"expected": null,
"correct": null,
"uncertain": false
}
},
"markers": [
{ "x": 100, "y": 100 },
{ "x": 1800, "y": 100 },
{ "x": 1800, "y": 2400 },
{ "x": 100, "y": 2400 }
],
"image": {
"width": 1920,
"height": 2560
}
},
{
"fileId": 2,
"success": false,
"code": "CHECK_FAILED",
"error": "未找到四个角定位块"
}
]
}
}
批量语义
- 一份试卷只解析一次;
- 按
fileIds顺序逐个检查; - 单个文件失败不会中断整个批次;
- 单个文件失败时,对应结果包含
success: false、code和error; total、successCount、failureCount是本次批次的汇总;- 整个请求只有在试卷不存在、试卷为空或试卷配置损坏时才直接返回错误。
错误
整批错误:
400 / VALIDATION_ERROR:examId或fileIds不合法400 / INVALID_JSON:请求体不是合法 JSON401 / UNAUTHORIZED:未鉴权404 / EXAM_NOT_FOUND:试卷不存在409 / EXAM_EMPTY:试卷还没有配置内容422 / EXAM_CONFIG_INVALID:已保存的试卷 JSON 不合法415 / UNSUPPORTED_MEDIA_TYPE:不是application/json
单个文件结果中的错误:
FILE_NOT_FOUND:文件 id 不存在或磁盘文件丢失CHECK_FAILED:图片定位或识别失败