修改试卷 (Update)
Method: PUT
Endpoint:
/api/v1/exams/{id}
用完整 JSON 替换试卷内容,不修改试卷名。
路径参数
| 参数 | 类型 | 说明 |
|---|---|---|
id |
Integer | 试卷 id,必须为正整数 |
请求参数
Body (JSON):
请求体是完整 exam JSON,不包含 name。如果出现 name 会返回 400。
示例:
{
"schemaVersion": 1,
"unit": "ratio",
"paper": {
"name": "A4",
"width": 1240,
"height": 1754,
"physical": { "width": 210, "height": 297 },
"pdf": { "width": 595.28, "height": 841.89 }
},
"markers": [
{ "id": "top-left", "x": 0.03, "y": 0.03, "size": 0.035 },
{ "id": "top-right", "x": 0.935, "y": 0.03, "size": 0.035 },
{ "id": "bottom-left", "x": 0.03, "y": 0.935, "size": 0.035 },
{ "id": "bottom-right", "x": 0.935, "y": 0.935, "size": 0.035 }
],
"questions": [
{
"id": "q1",
"displayNumber": 1,
"type": "mark",
"region": { "x": 0.06, "y": 0.4, "width": 0.38, "height": 0.05 },
"choices": [
{ "value": "A", "region": { "x": 0, "y": 0, "width": 0.2, "height": 1 } },
{ "value": "B", "region": { "x": 0.25, "y": 0, "width": 0.2, "height": 1 } },
{ "value": "C", "region": { "x": 0.5, "y": 0, "width": 0.2, "height": 1 } },
{ "value": "D", "region": { "x": 0.75, "y": 0, "width": 0.2, "height": 1 } }
]
}
],
"answerKey": {
"q1": "A"
}
}
响应
成功返回 200。响应结构与 获取试卷 相同,data.exam 为刚刚提交的完整对象。
错误
400 / VALIDATION_ERROR:JSON 结构不合法,或顶层出现name400 / INVALID_JSON:请求体不是合法 JSON401 / UNAUTHORIZED:未鉴权404 / EXAM_NOT_FOUND:试卷不存在415 / UNSUPPORTED_MEDIA_TYPE:不是application/json