docs(exam): 出题批卷接口变更说明及文档同步

- 新增《出题批阅接口变更说明(2026-06-05)》面向后端的迁移指南
- 同步更新 curl测试手册 和 后端对接规范 中的出题批卷章节
This commit is contained in:
lacerate551
2026-06-05 14:06:17 +08:00
parent 3f1980ba78
commit 6f863ddfd7
3 changed files with 510 additions and 38 deletions

View File

@@ -1415,6 +1415,13 @@ curl -s http://localhost:5001/exam/health
- 需要手动指定 `question_types`(每种题型的数量)
- 适合有明确需求的场景(如"出 5 道单选题"
**入参校验**
- `question_types` 中每个题型必须属于: `single_choice`, `multiple_choice`, `true_false`, `fill_blank`, `subjective`
- 每种题型数量必须为非负整数
- `difficulty` 必须为 1-5 的整数
- **总题数上限 20 道**(所有题型数量之和不能超过 20
- 校验失败返回 HTTP 400error_code 为 `INVALID_PARAMS`
```bash
curl -s -X POST http://localhost:5001/exam/generate \
-H "Content-Type: application/json" \
@@ -1430,6 +1437,7 @@ curl -s -X POST http://localhost:5001/exam/generate \
| `difficulty` | int | ❌ | 难度等级1-5默认 3 |
| `options` | object | ❌ | 附加选项(如 `max_source_chunks` |
| `request_id` | string | ❌ | 请求 ID幂等性 |
| `exclude_stems` | string[] | ❌ | 已有题目题干列表(跨调用去重,最多 100 条) |
> **注意**:生产模式(`DEV_MODE=false`)下无需传 `Authorization` header直接放行。开发模式下可传 `Authorization: Bearer mock-token-admin` 模拟管理员身份。
@@ -1474,7 +1482,10 @@ curl -s -X POST http://localhost:5001/exam/generate \
"request_id": null,
"source_chunks_used": 15,
"success": true,
"total": 10
"total": 10,
"requested_types": {"single_choice": 5, "true_false": 3, "fill_blank": 2},
"actual_types": {"single_choice": 5, "true_false": 3, "fill_blank": 2},
"warnings": []
},
"message": "出题成功",
"status": "success",
@@ -1483,7 +1494,9 @@ curl -s -X POST http://localhost:5001/exam/generate \
}
```
**验证结果**:✅ 通过
> **说明**`warnings` 字段在某题型实际生成数量少于请求数量时返回提示信息。
**验证结果**:✅ 通过2026-06-05
---
@@ -1562,7 +1575,7 @@ curl -s -X POST http://localhost:5001/exam/generate-smart \
批阅答案。
```bash
echo '{"answers":[{"question_id":"q1","question_type":"single_choice","question_content":{"answer":"B"},"student_answer":"B","max_score":2}]}' > /tmp/grade.json
echo '{"answers":[{"question_id":"q1","question_type":"single_choice","content":{"answer":"B"},"student_answer":"B","max_score":2}]}' > /tmp/grade.json
curl -s -X POST http://localhost:5001/exam/grade \
-H "Content-Type: application/json" \
-d @/tmp/grade.json
@@ -1578,10 +1591,12 @@ curl -s -X POST http://localhost:5001/exam/grade \
|------|------|------|------|
| `question_id` | string | ✅ | 题目 ID |
| `question_type` | string | ✅ | 题型 |
| `question_content` | object | ✅ | 题目内容(含标准答案 |
| `content` | object | ✅ | 题目内容(与出题接口返回的 `content` 字段结构一致,后端可直接透传 |
| `student_answer` | string/array | ✅ | 学生答案 |
| `max_score` | int | ✅ | 满分 |
> **注意**`question_type` 必须为以下值之一:`single_choice`, `multiple_choice`, `true_false`, `fill_blank`, `subjective`。传入无效类型返回 HTTP 400。
**响应示例**
```json
{
@@ -1589,11 +1604,16 @@ curl -s -X POST http://localhost:5001/exam/grade \
"request_id": null,
"results": [
{
"correct": true,
"feedback": "正确!",
"max_score": 2,
"question_id": "q1",
"score": 2
"score": 2,
"max_score": 2,
"grading_status": "success",
"details": {
"correct": true,
"student_answer": "B",
"correct_answer": "B",
"feedback": "正确!"
}
}
],
"score_rate": 100.0,
@@ -1608,7 +1628,13 @@ curl -s -X POST http://localhost:5001/exam/grade \
}
```
**验证结果**:✅ 通过
**`grading_status` 取值说明**
- `success`:评分成功
- `failed`:评分失败(主观题 LLM 解析失败或超时),此时 `details` 包含 `error` 字段
> **注意**:当主观题缺少 `scoring_points` 评分标准时,`details.warnings` 会包含警告信息,评分结果仅供参考。
**验证结果**:✅ 通过2026-06-05
---