把工作区里其余在制品一并入库,主要是工作台产品化的推进:
后端:新增 capability_definition / project / my_app_center / office_skill
接口与 action_definition / skill_definition / project / user_app_center
模型,config 加路由健康上报。
前端:新增 frontend/src/skills(Office 技能与 workbuddy 复刻)、
项目管理、应用中心、能力目录页,以及配套 api / store / config;
聊天侧新增 SpecialistChip / SpecialistPanel / SkillStrip / AppChatRail
等组件。
清理:移除旧 views/tools 下的单页工具(已并入工作台)、_frozen 冻结组件、
cmd/inspect_oa_debug 调试入口,以及两份调试笔记。
其它:文档与启动脚本同步。
(这批改动与上一提交的 SY23 工作并行进行,此前已在同一工作区内交织。)
Co-Authored-By: Claude Code <noreply@anthropic.com>
4.1 KiB
4.1 KiB
BE02 — 考试模块设计
版本:V2.0 | 框架:Go + Gin + GORM + SQLite 参考:
backend-go/internal/api/exam.go
1. 模块职责
- 题库管理(管理员 CRUD)
- 考试配置/组卷(管理员设置)
- 学员端考试(开始/答题/交卷/判分)
- 考试记录与回溯
2. 考试流程
管理员端:
录入题目 → 配置考试(名称/类型/题量/总分/合格线/时长/随机)
员工端:
考试列表 → 查看封面/说明 → 开始考试 → 答题 → 交卷
↓ ↓
自测:即时显示对错+答案 正式考:存档(得分/明细/是否通过)
3. 数据表关系
question(题库)← exam_paper(考试配置,通过 domain+question_count 抽题)
↓
exam_record(每次交卷的记录)
4. 题库 API
// backend-go/internal/api/exam.go
// GET /api/exam/questions?domain=company&status=active # 题目列表
func ListQuestions(c *gin.Context)
// POST /api/exam/questions # 新增题目
func CreateQuestion(c *gin.Context)
// PUT /api/exam/questions/{id} # 编辑题目
func UpdateQuestion(c *gin.Context)
// DELETE /api/exam/questions/{id} # 停用题目
func DeleteQuestion(c *gin.Context)
// GET /api/exam/papers # 考试配置列表
func ListPapers(c *gin.Context)
// POST /api/exam/papers # 创建考试
func CreatePaper(c *gin.Context)
// PUT /api/exam/papers/{id} # 编辑考试
func UpdatePaper(c *gin.Context)
// DELETE /api/exam/papers/{id} # 停用考试
func DeletePaper(c *gin.Context)
5. 学员端考试 API
// GET /api/exam/list # 我的考试列表
func ExamList(c *gin.Context)
// GET /api/exam/cover?id={paperId} # 考试封面/说明
func ExamCover(c *gin.Context)
// POST /api/exam/start # 开始考试 → 下发题目
func ExamStart(c *gin.Context)
// POST /api/exam/submit # 交卷判分
func ExamSubmit(c *gin.Context)
// GET /api/exam/record # 我的考试记录
func ExamRecordList(c *gin.Context)
// GET /api/exam/record/{recordId} # 考试记录详情
func ExamRecordDetail(c *gin.Context)
6. 判分逻辑(exam.go 内 isCorrect 函数)
// backend-go/internal/api/exam.go
func isCorrect(qtype string, correct []string, user any) bool {
switch qtype {
case "multiple": // 多选题:集合相等
return sortedEqual(correct, us)
case "judge": // 判断题:值相等
return strings.EqualFold(correct[0], us)
default: // 单选题:值相等
return correct[0] == us
}
}
func ExamSubmit(c *gin.Context) {
// 逐题比对 → 统计得分/正确数
// 简答题(essay)走 LLM 评分,其余题型确定性判分
}
7. 自测 vs 正式考区别
| 维度 | 自测 (self_test) | 正式考 (formal) |
|---|---|---|
| 次数限制 | 不限 | 按配置(通常 1 次) |
| 即时反馈 | 每题显示对错+答案 | 交卷后显示成绩 |
| 成绩存档 | 不存 | 永久保存到 exam_record |
| 答题明细 | 不存 | JSON 持久化 |
8. 考试记录设计
// exam_record.detail_json 示例(SQLite TEXT 列)
{
"questions": [
{
"question_id": 1,
"stem": "博昇的主营业务包括?",
"type": "single",
"user_answer": "D",
"correct_answer": "D",
"is_correct": true,
"explanation": "博昇双主营业务为资本咨询与AI产业落地"
}
],
"time_spent_sec": 1200
}
9. 权限
- 员工: 仅查看自己的考试记录
- 管理员: 查看全部考试记录(
/api/system/exam-records)