新增功能: 1. AI智能评分系统 - 集成OpenAI兼容API进行简答题评分 - 提供分数、评语和改进建议 - 支持自定义AI服务配置(BaseURL、APIKey、Model) 2. 题目列表页面 - 展示所有题目和答案 - Tab标签页形式的题型筛选(选择题、多选题、判断题、填空题、简答题) - 关键词搜索功能(支持题目内容和编号搜索) - 填空题特殊渲染:****显示为下划线 - 判断题不显示选项,界面更简洁 3. UI优化 - 答题结果组件重构,支持AI评分显示 - 首页新增"题目列表"快速入口 - 响应式设计,适配移动端和PC端 技术改进: - 添加AI评分服务层(internal/services/ai_grading.go) - 扩展题目模型支持AI评分结果 - 更新配置管理支持AI服务配置 - 添加AI评分测试脚本和文档 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
108 lines
4.7 KiB
PowerShell
108 lines
4.7 KiB
PowerShell
# AI评分功能测试脚本 (PowerShell版本)
|
||
# 请先登录获取token,并将token替换下面的$Token变量
|
||
|
||
# 配置
|
||
$BaseUrl = "http://localhost:8080"
|
||
$Token = "YOUR_TOKEN" # 请替换为你的实际token
|
||
$QuestionId = 465 # 简答题ID(第一道题)
|
||
|
||
Write-Host "=========================================" -ForegroundColor Green
|
||
Write-Host "AI评分功能测试" -ForegroundColor Green
|
||
Write-Host "=========================================" -ForegroundColor Green
|
||
Write-Host ""
|
||
|
||
# 测试1: 提交一个完整的答案
|
||
Write-Host "测试1: 提交完整答案(应该得高分)" -ForegroundColor Yellow
|
||
Write-Host "-----------------------------------------" -ForegroundColor Yellow
|
||
|
||
$Body1 = @{
|
||
question_id = 465
|
||
answer = "《中华人民共和国保守国家秘密法》第四十八条列举了十二种违法行为,主要包括:非法获取、持有国家秘密载体;买卖、转送或私自销毁秘密载体;通过无保密措施渠道传递秘密;未经批准携带秘密载体出境;非法复制、记录、存储国家秘密;在私人交往中涉及秘密;在互联网传递秘密;将涉密计算机接入公网;在涉密系统与公网间交换信息;使用非涉密设备处理秘密;擅自修改安全程序;以及将退出使用的涉密设备改作他用等。"
|
||
} | ConvertTo-Json
|
||
|
||
$Headers = @{
|
||
"Content-Type" = "application/json"
|
||
"Authorization" = "Bearer $Token"
|
||
}
|
||
|
||
try {
|
||
$Response1 = Invoke-RestMethod -Uri "$BaseUrl/api/practice/submit" -Method Post -Headers $Headers -Body $Body1
|
||
Write-Host "响应结果:" -ForegroundColor Cyan
|
||
$Response1 | ConvertTo-Json -Depth 10 | Write-Host
|
||
|
||
if ($Response1.data.ai_grading) {
|
||
Write-Host ""
|
||
Write-Host "AI评分结果:" -ForegroundColor Green
|
||
Write-Host " 分数: $($Response1.data.ai_grading.score)" -ForegroundColor Green
|
||
Write-Host " 是否正确: $($Response1.data.correct)" -ForegroundColor Green
|
||
Write-Host " 评语: $($Response1.data.ai_grading.feedback)" -ForegroundColor Green
|
||
Write-Host " 建议: $($Response1.data.ai_grading.suggestion)" -ForegroundColor Green
|
||
}
|
||
} catch {
|
||
Write-Host "错误: $_" -ForegroundColor Red
|
||
}
|
||
|
||
Write-Host ""
|
||
Write-Host ""
|
||
|
||
# 测试2: 提交一个简短的答案
|
||
Write-Host "测试2: 提交简短答案(应该得中等分数)" -ForegroundColor Yellow
|
||
Write-Host "-----------------------------------------" -ForegroundColor Yellow
|
||
|
||
$Body2 = @{
|
||
question_id = 465
|
||
answer = "主要包括非法获取国家秘密、买卖秘密载体、通过互联网传递秘密、将涉密设备接入公网等违法行为。"
|
||
} | ConvertTo-Json
|
||
|
||
try {
|
||
$Response2 = Invoke-RestMethod -Uri "$BaseUrl/api/practice/submit" -Method Post -Headers $Headers -Body $Body2
|
||
Write-Host "响应结果:" -ForegroundColor Cyan
|
||
$Response2 | ConvertTo-Json -Depth 10 | Write-Host
|
||
|
||
if ($Response2.data.ai_grading) {
|
||
Write-Host ""
|
||
Write-Host "AI评分结果:" -ForegroundColor Green
|
||
Write-Host " 分数: $($Response2.data.ai_grading.score)" -ForegroundColor Green
|
||
Write-Host " 是否正确: $($Response2.data.correct)" -ForegroundColor Green
|
||
Write-Host " 评语: $($Response2.data.ai_grading.feedback)" -ForegroundColor Green
|
||
Write-Host " 建议: $($Response2.data.ai_grading.suggestion)" -ForegroundColor Green
|
||
}
|
||
} catch {
|
||
Write-Host "错误: $_" -ForegroundColor Red
|
||
}
|
||
|
||
Write-Host ""
|
||
Write-Host ""
|
||
|
||
# 测试3: 提交一个不完整的答案
|
||
Write-Host "测试3: 提交不完整答案(应该得低分)" -ForegroundColor Yellow
|
||
Write-Host "-----------------------------------------" -ForegroundColor Yellow
|
||
|
||
$Body3 = @{
|
||
question_id = 465
|
||
answer = "不能泄露国家秘密,不能在网上传播秘密信息。"
|
||
} | ConvertTo-Json
|
||
|
||
try {
|
||
$Response3 = Invoke-RestMethod -Uri "$BaseUrl/api/practice/submit" -Method Post -Headers $Headers -Body $Body3
|
||
Write-Host "响应结果:" -ForegroundColor Cyan
|
||
$Response3 | ConvertTo-Json -Depth 10 | Write-Host
|
||
|
||
if ($Response3.data.ai_grading) {
|
||
Write-Host ""
|
||
Write-Host "AI评分结果:" -ForegroundColor Green
|
||
Write-Host " 分数: $($Response3.data.ai_grading.score)" -ForegroundColor Green
|
||
Write-Host " 是否正确: $($Response3.data.correct)" -ForegroundColor Green
|
||
Write-Host " 评语: $($Response3.data.ai_grading.feedback)" -ForegroundColor Green
|
||
Write-Host " 建议: $($Response3.data.ai_grading.suggestion)" -ForegroundColor Green
|
||
}
|
||
} catch {
|
||
Write-Host "错误: $_" -ForegroundColor Red
|
||
}
|
||
|
||
Write-Host ""
|
||
Write-Host ""
|
||
Write-Host "=========================================" -ForegroundColor Green
|
||
Write-Host "测试完成" -ForegroundColor Green
|
||
Write-Host "=========================================" -ForegroundColor Green
|