本文档描述了EduAdmin主观题自动化评估系统的API接口。系统采用微服务架构,包含以下服务:
- eval-service: Python + FastAPI 微服务(NLP 计算)
- go-backend: Go 后端服务(业务逻辑)
- frontend: Vue.js 前端(管理端和学员端)
- eval-service: http://localhost:8000
- go-backend: http://localhost:8080
- 前端管理端: http://localhost:8080
- 前端学员端: http://localhost:8081
GET /health响应:
{
"status": "healthy",
"service": "eval-service",
"version": "1.0.0"
}POST /api/v1/evaluate请求体:
{
"question_id": "string",
"reference_answer": "string",
"student_answer": "string",
"language": "zh|en|uk|...|auto",
"human_score": null
}响应:
{
"final_score": 85.5,
"semantic_score": 0.8234,
"keyterm_score": 78.0,
"coherence_score": 0.7567,
"hit_keywords": {
"core": ["人工智能", "机器学习"],
"related": ["算法", "数据"],
"aux": ["技术", "应用"]
},
"explanations": {
"summary": "总分85.5分(良好):答案质量较好,基本符合要求",
"notes": [
"语义理解基本正确,与参考答案较为一致",
"关键词覆盖较好,主要要点已包含",
"表达基本连贯,逻辑较为清晰"
]
},
"artifacts": {
"heatmap_url": null,
"word_cloud_url": null,
"keyword_analysis": {
"total_keywords": 5,
"core_count": 2,
"related_count": 2,
"aux_count": 1
}
}
}POST /api/v1/feedback请求体:
{
"question_id": "string",
"user_id": "string",
"human_score": 88.0,
"system_score": 85.0
}响应:
{
"success": true,
"message": "反馈已成功提交,权重已更新",
"updated_weights": {
"semantic": 0.6,
"keyterm": 0.3,
"coherence": 0.1
}
}GET /healthPOST /api/v1/exam/submit请求体:
{
"paper_id": "string",
"user_id": "string",
"answers": {
"question_1": "answer_1",
"question_2": "answer_2"
},
"subjective_questions": {
"subjective_1": "学生的主观题答案",
"subjective_2": "另一道主观题答案"
}
}GET /api/v1/exam/result/{paperId}/{userId}POST /api/v1/subjective/evaluateGET /api/v1/subjective/result/{questionId}/{userId}POST /api/v1/subjective/feedbackGET /api/v1/teacher/scores/{paperId}响应:
{
"paper_id": "paper_001",
"scores": [
{
"paper_id": "paper_001",
"question_id": "question_001",
"user_id": "user_001",
"student_name": "张三",
"final_score": 85.5,
"semantic_score": 0.8234,
"keyterm_score": 78.0,
"coherence_score": 0.7567,
"hit_keywords": {
"core": ["人工智能", "机器学习"],
"related": ["算法", "数据"],
"aux": ["技术", "应用"]
},
"explanations": {
"summary": "总分85.5分(良好):答案质量较好,基本符合要求",
"notes": ["语义理解基本正确", "关键词覆盖较好"]
},
"can_override": true,
"created_at": "2024-01-15T14:30:25Z"
}
],
"total": 1
}POST /api/v1/teacher/override-score请求体:
{
"paper_id": "string",
"question_id": "string",
"user_id": "string",
"new_score": 88.0
}GET /api/v1/student/scores/{paperId}/{userId}响应:
{
"paper_id": "paper_001",
"user_id": "user_001",
"scores": [
{
"paper_id": "paper_001",
"question_id": "question_001",
"final_score": 85.5,
"hit_keywords": {
"core": ["人工智能", "机器学习"],
"related": ["算法", "数据"],
"aux": ["技术", "应用"]
},
"explanations": {
"summary": "总分85.5分(良好):答案质量较好,基本符合要求",
"notes": ["语义理解基本正确", "关键词覆盖较好"]
},
"created_at": "2024-01-15T14:30:25Z"
}
],
"total": 1
}所有API都遵循统一的错误响应格式:
{
"error": "错误描述",
"details": "详细错误信息"
}常见HTTP状态码:
- 200: 成功
- 400: 请求参数错误
- 404: 资源不存在
- 422: 数据验证错误
- 500: 服务器内部错误
目前系统未实现认证机制,在生产环境中应该添加适当的认证和授权。
建议在生产环境中添加API限流机制,防止滥用。
系统提供健康检查接口,可用于监控服务状态。
import requests
# 评估主观题
def evaluate_subjective(question_id, reference_answer, student_answer, language="zh"):
url = "http://localhost:8000/api/v1/evaluate"
data = {
"question_id": question_id,
"reference_answer": reference_answer,
"student_answer": student_answer,
"language": language
}
response = requests.post(url, json=data)
return response.json()
# 使用示例
result = evaluate_subjective(
question_id="q001",
reference_answer="人工智能是计算机科学的一个分支。",
student_answer="AI是让机器智能的技术。"
)
print(f"最终得分: {result['final_score']}")// 评估主观题
async function evaluateSubjective(questionId, referenceAnswer, studentAnswer, language = 'zh') {
const response = await fetch('http://localhost:8000/api/v1/evaluate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
question_id: questionId,
reference_answer: referenceAnswer,
student_answer: studentAnswer,
language: language
})
});
return await response.json();
}
// 使用示例
const result = await evaluateSubjective(
'q001',
'人工智能是计算机科学的一个分支。',
'AI是让机器智能的技术。'
);
console.log(`最终得分: ${result.final_score}`);- 初始版本发布
- 实现BCHS + REWT + CAMF算法
- 支持中英文评估
- 提供完整的REST API
- 集成前后端界面