9e262abb23
- Move files from exam/.claude/skills/exam/ to exam/ - Update path references in SKILL.md - Fix schema path resolution in validate scripts (1 level up instead of 3)
3.9 KiB
3.9 KiB
name, description
| name | description |
|---|---|
| exam | Generate, validate, and manage CS exam questions. Trigger: '生成题目', 'generate questions', 'validate', '添加题目', '/exam' |
CS 知识应试强化 — 题目生成 Skill
为 topics/ 目录生成符合 JSON Schema 的题目文件。
目录结构
examination/
├── schema/
│ ├── question.schema.json # 题目 JSON Schema (Draft-07)
│ ├── prompt-template.md # 提示词模板参考
│ └── templates/ # 各题型示例
├── topics/
│ ├── index.json # 主题索引
│ └── {group}/{subtopic}/
│ ├── meta.json # 子主题元信息
│ ├── fill_blank.json # 填空题
│ └── single_choice.json # 单选题
└── exam/ # 本 skill 目录
├── SKILL.md
├── validate.py # Python 校验脚本
└── validate.mjs # Node.js 校验脚本
工作流
1. 确定目标
用户会说类似「生成填空题」「给 gc-jvm 加10道选择题」。你需要:
- 确认 子主题:读
topics/index.json找到对应 slug 和 path - 确认 题型:fill_blank / single_choice / multiple_choice / true_false / short_answer / code_reading / scenario
- 确认 数量:默认 10
如果用户没指定,主动询问。
2. 读取上下文
# 查看子主题已有题目,避免重复
cat topics/{group}/{subtopic}/meta.json
cat topics/{group}/{subtopic}/{type}.json # 如果存在
3. 生成题目
你(Claude)直接生成 JSON。遵循以下规则:
- 输出格式严格匹配
schema/question.schema.json - ID 格式:
{type_short}-{seq},如fb-001,序号从已有最大值 +1 开始 - type_short 映射:sc=single_choice, mc=multiple_choice, tf=true_false, fb=fill_blank, sa=short_answer, cr=code_reading, sn=scenario
- difficulty 1-5,根据主题上下文合理分布
- tags 使用子主题 meta.json 中的 tags 作为参考
- explanation 必须详细,解释为什么对/错
生成后,将 JSON 写入临时文件进行校验:
# 写入临时文件
cat > /tmp/exam_gen.json << 'ENDJSON'
{ ...生成的JSON... }
ENDJSON
4. 校验
根据可用运行时选择其一:
# Python (优先)
python3 exam/validate.py /tmp/exam_gen.json
# Node.js (备选)
node exam/validate.mjs /tmp/exam_gen.json
- 校验通过 → 继续写入
- 校验失败 → 修正 JSON 后重新校验,直到通过
5. 写入文件
校验通过后:
- 如果目标题型文件已存在,读取现有 questions 数组,追加新题目(不覆盖旧题)
- 如果不存在,创建新文件
- 更新
meta.json的question_files和stats - 更新
topics/index.json中对应子主题的stats
文件格式:
{
"topic": "{subtopic-slug}",
"type": "{question_type}",
"schema_version": "1.0.0",
"generated": "{ISO-8601}",
"questions": [ ... ]
}
6. 确认
报告生成结果:题型、数量、文件路径。
提示用户在线查看:
✅ 已完成!前往 http://47.121.181.112:30000/ 查看新题目。
校验脚本
两个脚本功能相同,检测可用环境后选用:
exam/validate.py— 优先用jsonschema,不可用时回退到基础校验exam/validate.mjs— 纯 Node.js 内置模块,无外部依赖
退出码:0=通过,1=有错误,2=用法错误。
7 种题型速查
| 题型 | type | 关键字段 |
|---|---|---|
| 填空 | fill_blank | answer: string[], answer_rule: "any"/"all"/"ordered" |
| 单选 | single_choice | options: {A-D}, answer: string |
| 多选 | multiple_choice | options: {A-D}, answer: string[] |
| 判断 | true_false | answer: boolean |
| 简答 | short_answer | answer: string, keywords: string[], scoring_rubric: string |
| 代码阅读 | code_reading | code, language, sub_questions[] |
| 场景分析 | scenario | context, sub_questions[] |