feat: 初始化 CS 知识应试强化系统

- 纯 HTML/CSS/JS 单页应用,支持填空题和选择题交互
- 5 个主题共 100 道题(GC/JVM、AI 结构化输出、记忆管理、幻觉、工具链)
- 按主题组织、按题型拆分的 JSON 数据结构
- JSON Schema 校验 + 提示词模板 + 题型模板
- 自定义导入功能(粘贴/上传 JSON)
- 项目文档(需求 + 架构)

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
2026-09-02 18:22:20 +08:00
parent cf589b12f4
commit d3cba0e23c
30 changed files with 4092 additions and 1 deletions
+250
View File
@@ -0,0 +1,250 @@
# 题目生成提示词模板
## 使用方法
将以下提示词中的 `{变量}` 替换为实际内容,发送给 LLM。
---
## 提示词
你是一个计算机科学教育专家。请根据以下要求生成题目:
**主题**: {topic_name}
**领域**: {domain_name} > {subdomain_name}
**题型**: {question_type}
**数量**: {count}
**难度范围**: {min_difficulty}-{max_difficulty}
**知识点标签**: {tags}
### 输出格式要求
请严格按照以下 JSON Schema 输出,不要添加任何额外内容:
```json
{
"topic": "{topic_slug}",
"type": "{question_type}",
"schema_version": "1.0.0",
"generated": "{ISO-8601 timestamp}",
"questions": [
// 根据题型填写,参见下方题型说明
]
}
```
### 题型说明
#### 单选题 (single_choice)
- 4 个选项,只有 1 个正确答案
- 选项应具有合理的干扰性
- 解析应说明为什么正确答案正确,其他选项为什么错误
```json
{
"id": "domain-subdomain-topic-sc-001",
"type": "single_choice",
"difficulty": 3,
"tags": ["tag1", "tag2"],
"question": "题目内容?",
"options": {
"A": "选项 A",
"B": "选项 B",
"C": "选项 C",
"D": "选项 D"
},
"answer": "A",
"explanation": "详细解析...",
"source": null,
"related": []
}
```
#### 多选题 (multiple_choice)
- 4-6 个选项,2-3 个正确答案
- 解析应说明每个选项的对错原因
```json
{
"id": "domain-subdomain-topic-mc-001",
"type": "multiple_choice",
"difficulty": 3,
"tags": ["tag1", "tag2"],
"question": "以下哪些是正确的?(多选)",
"options": {
"A": "选项 A",
"B": "选项 B",
"C": "选项 C",
"D": "选项 D"
},
"answer": ["A", "C"],
"explanation": "A 正确因为...,B 错误因为...,C 正确因为...,D 错误因为...",
"source": null,
"related": []
}
```
#### 判断题 (true_false)
- 陈述一个明确的事实或概念
- answer 为 true 或 false
- 解析应解释为什么对或错
```json
{
"id": "domain-subdomain-topic-tf-001",
"type": "true_false",
"difficulty": 2,
"tags": ["tag1", "tag2"],
"question": "判断以下陈述是否正确:某概念的描述。",
"answer": true,
"explanation": "该陈述正确/错误,因为...",
"source": null,
"related": []
}
```
#### 填空题 (fill_blank)
- 题目中用 `______` 标记空白处
- answer 数组可包含多个可接受的答案
- answer_rule: "any"(任一匹配)、"all"(全部匹配)、"ordered"(按顺序匹配)
- 解析应说明答案的来源和上下文
```json
{
"id": "domain-subdomain-topic-fb-001",
"type": "fill_blank",
"difficulty": 3,
"tags": ["tag1", "tag2"],
"question": "______ 协议工作在 OSI 模型的第 ______ 层。",
"answer": ["HTTP", "7"],
"answer_rule": "ordered",
"explanation": "HTTP 是应用层协议,工作在 OSI 模型的第 7 层(应用层)。",
"source": null,
"related": []
}
```
#### 简答题 (short_answer)
- 提出开放性问题
- 提供参考答案和评分关键词
- keywords 用于自动评分匹配
- scoring_rubric 描述评分标准
- 解析应包含完整的回答思路
```json
{
"id": "domain-subdomain-topic-sa-001",
"type": "short_answer",
"difficulty": 4,
"tags": ["tag1", "tag2"],
"question": "请简述某概念的原理和应用场景。",
"answer": "参考答案内容...",
"keywords": ["关键词1", "关键词2", "关键词3"],
"scoring_rubric": "答对核心原理得 60 分;举出应用场景得 20 分;说明优缺点得 20 分。",
"explanation": "完整解析...",
"source": null,
"related": []
}
```
#### 代码阅读题 (code_reading)
- 提供完整的代码片段
- 设置 2-3 个子问题(可以是任何题型)
- 解析应逐步分析代码执行过程
```json
{
"id": "domain-subdomain-topic-cr-001",
"type": "code_reading",
"difficulty": 4,
"tags": ["tag1", "tag2"],
"question": "阅读以下代码,回答问题。",
"code": "// 代码片段",
"language": "python",
"sub_questions": [
{
"index": 1,
"type": "single_choice",
"question": "子问题 1",
"options": { "A": "...", "B": "...", "C": "...", "D": "..." },
"answer": "A",
"explanation": "解析..."
},
{
"index": 2,
"type": "short_answer",
"question": "子问题 2",
"answer": "参考答案",
"keywords": ["关键词"],
"explanation": "解析..."
}
],
"explanation": "整体代码解析...",
"source": null,
"related": []
}
```
#### 场景分析题 (scenario)
- 描述一个实际的技术场景
- 设置 2-3 个分析性子问题
- 解析应提供系统性的分析框架
```json
{
"id": "domain-subdomain-topic-sn-001",
"type": "scenario",
"difficulty": 5,
"tags": ["tag1", "tag2"],
"question": "请分析以下技术场景。",
"context": "详细场景描述...",
"code": null,
"sub_questions": [
{
"index": 1,
"type": "short_answer",
"question": "分析性问题 1",
"answer": "参考答案",
"keywords": ["关键词"],
"scoring_rubric": "评分标准",
"explanation": "解析..."
},
{
"index": 2,
"type": "multiple_choice",
"question": "选择性问题 2",
"options": { "A": "...", "B": "...", "C": "...", "D": "..." },
"answer": ["A", "C"],
"explanation": "解析..."
}
],
"explanation": "整体场景分析...",
"source": null,
"related": []
}
```
### ID 命名规则
题目 ID 格式:`{domain}-{subdomain}-{topic}-{type_code}-{number}`
- domain: 领域缩写(如 os, net, db, algo, ai)
- subdomain: 子领域缩写
- topic: 主题缩写
- type_code: 题型代码(sc/mc/tf/fb/sa/cr/sn)
- number: 三位数字序号(001-999)
### 注意事项
1. 每道题必须包含完整的 explanation(解析)
2. 难度等级 1-5:1=基础概念,2=理解应用,3=分析综合,4=评价设计,5=创新拓展
3. tags 应包含具体知识点,便于后续统计和筛选
4. source 字段可填 null,如有参考资料请填写
5. related 字段可填空数组,如有相关题目 ID 请填写
+334
View File
@@ -0,0 +1,334 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Examination Question Set",
"description": "CS 知识应试强化系统 - 题目集 JSON Schema",
"type": "object",
"required": ["topic", "type", "schema_version", "questions"],
"properties": {
"topic": {
"type": "string",
"description": "主题 slug"
},
"type": {
"type": "string",
"enum": ["single_choice", "multiple_choice", "true_false", "fill_blank", "short_answer", "code_reading", "scenario"],
"description": "题目类型"
},
"schema_version": {
"type": "string",
"const": "1.0.0"
},
"generated": {
"type": "string",
"format": "date-time"
},
"questions": {
"type": "array",
"items": {
"$ref": "#/definitions/question"
}
}
},
"definitions": {
"question": {
"type": "object",
"required": ["id", "type", "difficulty", "tags", "question", "explanation"],
"properties": {
"id": {
"type": "string",
"pattern": "^(sc|mc|tf|fb|sa|cr|sn)-[0-9]{3}$",
"description": "题目唯一标识,格式: typecode-number(如 fb-001, sc-003)"
},
"type": {
"type": "string",
"enum": ["single_choice", "multiple_choice", "true_false", "fill_blank", "short_answer", "code_reading", "scenario"]
},
"difficulty": {
"type": "integer",
"minimum": 1,
"maximum": 5
},
"tags": {
"type": "array",
"items": { "type": "string" }
},
"question": {
"type": "string"
},
"explanation": {
"type": "string"
},
"source": {
"type": ["string", "null"],
"default": null
},
"related": {
"type": "array",
"items": { "type": "string" },
"default": []
},
"options": {
"description": "选项(选择题类型)或 null"
},
"answer": {
"description": "答案(根据题型不同而不同)"
},
"answer_rule": {
"type": "string",
"enum": ["any", "all", "ordered"],
"default": "any",
"description": "填空题答案匹配规则"
},
"keywords": {
"type": "array",
"items": { "type": "string" },
"description": "简答题评分关键词"
},
"scoring_rubric": {
"type": "string",
"description": "简答题评分标准"
},
"code": {
"type": ["string", "null"],
"description": "代码片段(代码阅读题和场景题)"
},
"language": {
"type": "string",
"description": "编程语言(代码阅读题必填)"
},
"context": {
"type": "string",
"description": "场景描述(场景分析题必填)"
},
"sub_questions": {
"type": "array",
"items": {
"$ref": "#/definitions/sub_question"
},
"description": "子问题列表(代码阅读题和场景分析题)"
}
},
"allOf": [
{
"if": { "properties": { "type": { "const": "single_choice" } } },
"then": {
"required": ["options", "answer"],
"properties": {
"options": {
"type": "object",
"patternProperties": {
"^[A-Z]$": { "type": "string" }
},
"additionalProperties": false,
"minProperties": 2
},
"answer": {
"type": "string",
"pattern": "^[A-Z]$"
}
}
}
},
{
"if": { "properties": { "type": { "const": "multiple_choice" } } },
"then": {
"required": ["options", "answer"],
"properties": {
"options": {
"type": "object",
"patternProperties": {
"^[A-Z]$": { "type": "string" }
},
"additionalProperties": false,
"minProperties": 2
},
"answer": {
"type": "array",
"items": { "type": "string", "pattern": "^[A-Z]$" },
"minItems": 1,
"uniqueItems": true
}
}
}
},
{
"if": { "properties": { "type": { "const": "true_false" } } },
"then": {
"required": ["answer"],
"properties": {
"answer": { "type": "boolean" }
}
}
},
{
"if": { "properties": { "type": { "const": "fill_blank" } } },
"then": {
"required": ["answer"],
"properties": {
"answer": {
"type": "array",
"items": { "type": "string" },
"minItems": 1
},
"answer_rule": {
"type": "string",
"enum": ["any", "all", "ordered"],
"default": "any"
}
}
}
},
{
"if": { "properties": { "type": { "const": "short_answer" } } },
"then": {
"required": ["answer"],
"properties": {
"answer": { "type": "string" },
"keywords": {
"type": "array",
"items": { "type": "string" }
},
"scoring_rubric": { "type": "string" }
}
}
},
{
"if": { "properties": { "type": { "const": "code_reading" } } },
"then": {
"required": ["code", "language", "sub_questions"],
"properties": {
"code": { "type": "string" },
"language": { "type": "string" },
"sub_questions": {
"type": "array",
"items": { "$ref": "#/definitions/sub_question" },
"minItems": 1
}
}
}
},
{
"if": { "properties": { "type": { "const": "scenario" } } },
"then": {
"required": ["context", "sub_questions"],
"properties": {
"context": { "type": "string" },
"code": { "type": ["string", "null"] },
"sub_questions": {
"type": "array",
"items": { "$ref": "#/definitions/sub_question" },
"minItems": 1
}
}
}
}
]
},
"sub_question": {
"type": "object",
"required": ["index", "type", "question", "answer", "explanation"],
"properties": {
"index": {
"type": "integer",
"minimum": 1
},
"type": {
"type": "string",
"enum": ["single_choice", "multiple_choice", "true_false", "fill_blank", "short_answer", "code_reading", "scenario"]
},
"question": { "type": "string" },
"answer": {},
"explanation": { "type": "string" },
"options": {
"type": "object",
"patternProperties": {
"^[A-Z]$": { "type": "string" }
},
"additionalProperties": false
},
"keywords": {
"type": "array",
"items": { "type": "string" }
},
"scoring_rubric": { "type": "string" }
},
"allOf": [
{
"if": { "properties": { "type": { "const": "single_choice" } } },
"then": {
"required": ["options"],
"properties": {
"options": {
"type": "object",
"patternProperties": {
"^[A-Z]$": { "type": "string" }
},
"additionalProperties": false,
"minProperties": 2
},
"answer": {
"type": "string",
"pattern": "^[A-Z]$"
}
}
}
},
{
"if": { "properties": { "type": { "const": "multiple_choice" } } },
"then": {
"required": ["options"],
"properties": {
"options": {
"type": "object",
"patternProperties": {
"^[A-Z]$": { "type": "string" }
},
"additionalProperties": false,
"minProperties": 2
},
"answer": {
"type": "array",
"items": { "type": "string", "pattern": "^[A-Z]$" },
"minItems": 1,
"uniqueItems": true
}
}
}
},
{
"if": { "properties": { "type": { "const": "true_false" } } },
"then": {
"properties": {
"answer": { "type": "boolean" }
}
}
},
{
"if": { "properties": { "type": { "const": "fill_blank" } } },
"then": {
"properties": {
"answer": {
"type": "array",
"items": { "type": "string" },
"minItems": 1
}
}
}
},
{
"if": { "properties": { "type": { "const": "short_answer" } } },
"then": {
"properties": {
"answer": { "type": "string" },
"keywords": {
"type": "array",
"items": { "type": "string" }
},
"scoring_rubric": { "type": "string" }
}
}
}
]
}
}
}
+42
View File
@@ -0,0 +1,42 @@
{
"topic": "example-topic",
"type": "code_reading",
"schema_version": "1.0.0",
"generated": "2026-01-01T00:00:00Z",
"questions": [
{
"id": "dom-sub-top-cr-001",
"type": "code_reading",
"difficulty": 4,
"tags": ["example", "template", "javascript"],
"question": "阅读以下 JavaScript 代码,回答子问题。",
"code": "function fibonacci(n) {\n if (n <= 1) return n;\n let a = 0, b = 1;\n for (let i = 2; i <= n; i++) {\n [a, b] = [b, a + b];\n }\n return b;\n}\n\nconsole.log(fibonacci(6));",
"language": "javascript",
"sub_questions": [
{
"index": 1,
"type": "short_answer",
"question": "这段代码的输出是什么?",
"answer": "8",
"explanation": "fibonacci(6) 的计算过程:f(0)=0, f(1)=1, f(2)=1, f(3)=2, f(4)=3, f(5)=5, f(6)=8。最终输出 8。"
},
{
"index": 2,
"type": "single_choice",
"question": "该算法的时间复杂度是什么?",
"options": {
"A": "O(1)",
"B": "O(n)",
"C": "O(n^2)",
"D": "O(2^n)"
},
"answer": "B",
"explanation": "该实现使用迭代方式,for 循环执行 n-1 次,每次操作是常数时间,因此时间复杂度为 O(n)。"
}
],
"explanation": "这段代码实现了斐波那契数列的迭代求解。与递归实现相比,迭代版本避免了重复计算,时间复杂度从 O(2^n) 降低到 O(n),空间复杂度为 O(1)。",
"source": null,
"related": []
}
]
}
+20
View File
@@ -0,0 +1,20 @@
{
"topic": "example-topic",
"type": "fill_blank",
"schema_version": "1.0.0",
"generated": "2026-01-01T00:00:00Z",
"questions": [
{
"id": "dom-sub-top-fb-001",
"type": "fill_blank",
"difficulty": 3,
"tags": ["example", "template"],
"question": "HTTP 协议默认使用 ______ 端口,HTTPS 默认使用 ______ 端口。",
"answer": ["80", "443"],
"answer_rule": "ordered",
"explanation": "HTTP 默认端口为 80,HTTPS 默认端口为 443。这是网络编程的基础知识。answer_rule 设为 ordered 表示答案顺序必须与题目中的空白顺序一致。",
"source": null,
"related": []
}
]
}
+26
View File
@@ -0,0 +1,26 @@
{
"topic": "example-topic",
"type": "multiple_choice",
"schema_version": "1.0.0",
"generated": "2026-01-01T00:00:00Z",
"questions": [
{
"id": "dom-sub-top-mc-001",
"type": "multiple_choice",
"difficulty": 3,
"tags": ["example", "template"],
"question": "以下哪些选项是正确的?(多选)",
"options": {
"A": "正确选项一",
"B": "错误选项",
"C": "正确选项二",
"D": "错误选项",
"E": "正确选项三"
},
"answer": ["A", "C", "E"],
"explanation": "A、C、E 是正确答案。B 和 D 是错误选项,需要考生具备全面的知识理解才能准确作答。",
"source": null,
"related": []
}
]
}
+57
View File
@@ -0,0 +1,57 @@
{
"topic": "example-topic",
"type": "scenario",
"schema_version": "1.0.0",
"generated": "2026-01-01T00:00:00Z",
"questions": [
{
"id": "dom-sub-top-sn-001",
"type": "scenario",
"difficulty": 5,
"tags": ["example", "template", "system-design"],
"question": "请分析以下技术场景并回答问题。",
"context": "某电商平台在双十一大促期间,订单量突然增长 10 倍,导致系统出现以下问题:1) 数据库响应时间从 50ms 飙升到 5s;2) 部分用户看到下单成功但实际未扣减库存;3) 消息队列积压超过 100 万条消息。系统架构为:Nginx -> Spring Boot 应用 -> MySQL 主从 -> RabbitMQ。",
"code": null,
"sub_questions": [
{
"index": 1,
"type": "short_answer",
"question": "针对数据库响应缓慢问题,请提出至少三种优化方案。",
"answer": "1) 引入 Redis 缓存热点数据,减少数据库查询;2) 对订单表进行分库分表,分散读写压力;3) 读写分离,将读请求路由到从库;4) 优化慢 SQL,添加合适索引;5) 使用连接池并调优参数。",
"keywords": ["缓存", "分库分表", "读写分离", "索引", "连接池"],
"scoring_rubric": "每提出一种合理方案得 20 分,最高 100 分。方案需具体可行,不能只说概念。"
},
{
"index": 2,
"type": "multiple_choice",
"question": "关于库存超卖问题,以下哪些是有效的解决方案?",
"options": {
"A": "使用 Redis 分布式锁控制库存扣减",
"B": "在数据库层面使用乐观锁(版本号机制)",
"C": "使用消息队列异步处理订单",
"D": "增加应用服务器数量",
"E": "使用 Redis 原子操作 DECR 实现库存预扣减"
},
"answer": ["A", "B", "E"],
"explanation": "A 正确:分布式锁可以保证同一时刻只有一个请求能修改库存。B 正确:乐观锁通过版本号防止并发更新冲突。C 不直接解决超卖:异步处理可能加剧超卖。D 不解决:增加服务器不能解决并发竞争问题。E 正确:Redis DECR 是原子操作,可以保证扣减的原子性。"
},
{
"index": 3,
"type": "single_choice",
"question": "对于消息队列积压问题,最优先的处理方式是?",
"options": {
"A": "增加消费者实例数量",
"B": "丢弃部分消息",
"C": "临时扩容消费者并优化消费逻辑",
"D": "重启消息队列服务"
},
"answer": "C",
"explanation": "C 是最佳方案:临时扩容可以快速提升消费能力,同时优化消费逻辑(如批量处理、减少 IO)可以从根本上提升吞吐量。A 不够全面;B 会导致数据丢失;D 不能解决积压问题。"
}
],
"explanation": "这是一个典型的高并发系统问题场景。核心挑战包括:数据库瓶颈、并发一致性、消息堆积。解决思路需要从缓存、数据库优化、分布式一致性、消息队列调优等多个维度综合考虑。",
"source": null,
"related": []
}
]
}
+21
View File
@@ -0,0 +1,21 @@
{
"topic": "example-topic",
"type": "short_answer",
"schema_version": "1.0.0",
"generated": "2026-01-01T00:00:00Z",
"questions": [
{
"id": "dom-sub-top-sa-001",
"type": "short_answer",
"difficulty": 4,
"tags": ["example", "template"],
"question": "请简述 TCP 三次握手的过程及其作用。",
"answer": "TCP 三次握手过程:1) 客户端发送 SYN 报文,seq=x;2) 服务器回复 SYN+ACK 报文,seq=y, ack=x+1;3) 客户端发送 ACK 报文,seq=x+1, ack=y+1。三次握手的目的是确认双方的发送和接收能力正常,同步初始序列号。",
"keywords": ["SYN", "ACK", "seq", "三次握手", "序列号"],
"scoring_rubric": "答对三次握手的完整流程得 60 分;正确说明每步的标志位得 20 分;说明握手目的得 20 分。",
"explanation": "三次握手是 TCP 建立连接的核心机制。第一次握手:客户端发送 SYN;第二次握手:服务器回复 SYN+ACK;第三次握手:客户端确认 ACK。这确保了双方都能发送和接收数据。",
"source": null,
"related": []
}
]
}
+25
View File
@@ -0,0 +1,25 @@
{
"topic": "example-topic",
"type": "single_choice",
"schema_version": "1.0.0",
"generated": "2026-01-01T00:00:00Z",
"questions": [
{
"id": "dom-sub-top-sc-001",
"type": "single_choice",
"difficulty": 3,
"tags": ["example", "template"],
"question": "以下哪项是单选题的正确示例?",
"options": {
"A": "这是一个正确选项",
"B": "这是一个干扰选项",
"C": "这也是一个干扰选项",
"D": "这还是一个干扰选项"
},
"answer": "A",
"explanation": "A 是正确答案,因为它是预设的正确选项。B、C、D 均为干扰项,用于测试考生的辨别能力。",
"source": null,
"related": []
}
]
}
+19
View File
@@ -0,0 +1,19 @@
{
"topic": "example-topic",
"type": "true_false",
"schema_version": "1.0.0",
"generated": "2026-01-01T00:00:00Z",
"questions": [
{
"id": "dom-sub-top-tf-001",
"type": "true_false",
"difficulty": 2,
"tags": ["example", "template"],
"question": "判断以下陈述是否正确:这是一个判断题的示例陈述。",
"answer": true,
"explanation": "该陈述是正确的。这是一个用于演示判断题格式的示例。",
"source": null,
"related": []
}
]
}