当前位置: 首页 > Skill >

题库格式化:原始题目 → 结构化 JSON(支持单选/多选/判断/填空)

题库格式化:原始题目 → 结构化 JSON(支持单选/多选/判断/填空)

题库格式化:原始题目 → 结构化 JSON(支持单选/多选/判断/填空)

Convert raw question text into structured JSON question bank format. Handles single-choice, multi-choice, true/false, and fill-in-the-blank questions with auto chapter mapping and difficulty rating. Framework-agnostic — output works with any quiz system, LMS, or flashcard app.

1.1.0 2026.11.26 711
获取Skill文件查看使用说明
作 者:沈景 许可证: 更新时间:2026.11.26
本文目录展开

Question Bank Formatter (题库格式化)

Convert raw question text (from textbooks, PDFs, or pasted content) into a strict JSON question bank format.

When to Use

  • User provides question text and asks to "转换成题库" or "生成题库"
  • User says "题库格式转换" or references the specific JSON output format
  • User attaches a document with exam questions to be structured

Output JSON Format

{
  "questions": [
    {
      "id": "subject.ch1.001",
      "content": "题目内容(去掉末尾的括号或空格)",
      "options": ["选项A文本", "选项B文本", "选项C文本", "选项D文本"],
      "answer": "正确答案字母(单选如A,多选如BCD)",
      "explanation": "解析(可为空字符串)",
      "type": "single_choice",
      "difficulty": 3,
      "source": "来源书名或课程名",
      "nodes": ["subject.ch1"],
      "formulas": [],
      "siblings": []
    }
  ]
}

Type Rules

JSON type field CryptoForge DB type options answer Notes
single_choice → choice 各选项文本数组 单个字母如 "A" 单选
multi_choice → choice 各选项文本数组 字母组合如 "BCD" 多选,字母必须按顺序排列
true_false → choice 固定为 ["对", "错"] "对" 或 "错" 判断题
fill → fill 单项数组如 ["响应"] 填空答案文本 填空题

CRITICAL for CryptoForge import: The type field stored in the DB must be choice or fill, NOT single_choice/multi_choice/true_false. The import script handles this remapping automatically.

ID Format Rules

Pattern: subject.chapter.number

  • Subject: lowercase abbreviation must match CryptoForge nameMap (see Integration section). Verify before creating new subjects.
  • Chapter: ch0 (绪论), ch1-ch8+, or type suffix (tf, sc, mc, fill) for generic question banks
  • Number: three-digit zero-padded (001, 015, 123)

Examples: marxism.ch1.001, cisa.ch3.015, computer_org.ch1.003, computer_org.ch9.fill.001

Chapter Mapping

Infer the chapter from question content:

  • 绪论/导论 → ch0
  • 第一章 → ch1
  • 第二章 → ch2
  • 第三章 → ch3
  • 第四章 → ch4
  • 第五章 → ch5
  • 判断题无法判断 → tf

If the source material uses domain-based structure (like CISA), map domains to chapters:

  • Domain 1 → ch1
  • Domain 2 → ch2
  • etc.

Difficulty Rules

Level Value Criteria
简单 2 Basic definition recall, straightforward fact questions
中等 3 Understanding and application, requires some reasoning
较难 4 Comprehensive analysis, multi-step reasoning, scenario-based

Cleaning Rules

  1. Strip option prefixes: Remove leading letter labels like "A. ", "B、", "A)", "B."
  2. Trim whitespace: Remove leading/trailing spaces from options and content
  3. Sort multi-choice answers: "BD" not "DB", "ACD" not "CDA"
  4. Split true/false inline: If question text contains "对/错" at the end, separate it
  5. Remove trailing markers: Strip trailing parentheses, brackets, or spaces from content
  6. Skip invalid questions: If content or answer is missing, skip the question

Workflow

Step 1: Parse Source

  • If from PDF/EPUB: use pdf-deep-reading or EPUB extraction first
  • If pasted text: parse directly

Step 2: Identify Question Type

Look for:

  • A. ... B. ... C. ... D. ... with one correct → single_choice
  • A. ... B. ... C. ... D. ... with multiple correct → multi_choice
  • Statements ending with 对/错 or √/× → true_false

Step 3: Determine Subject and Chapter

  • Infer subject from the source (e.g., Marxism → marxism, CISA → cisa)
  • Map question content to chapter using the chapter mapping rules

Step 4: Clean and Format

Apply all cleaning rules. Ensure:

  • JSON is valid (no trailing commas, proper escaping)
  • All required fields present: id, content, options, answer, explanation, type, difficulty, source, nodes, formulas, siblings

Step 5: Output

  • Output raw JSON, NOT wrapped in markdown code blocks (```json)
  • Save to file if user requests: C:Users13657Desktop{name}_题库.json

Integration

User Intent Skill Chain
Feed book → generate questions textbook-learning → question-bank-formatter
Pasted exam questions → format question-bank-formatter directly
PDF of exam → format questions pdf-deep-reading → question-bank-formatter
Translate English bank → Chinese question-bank-formatter + model translation
Import into CryptoForge DB question-bank-formatter → direct SQLite script (see below)

CryptoForge DB Direct Import

For "导入到X科目" requests, use the direct SQLite import script not the HTTP API (which requires a file upload + confirm two-step). Full operational guide: references/cryptoforge-import.md. Template script: scripts/import_questions.js.

Mandatory rules:

  1. Subject prefix MUST match nameMap in server/index.js (e.g., computer_org not comp_org) — verify the map first
  2. DB type field: use choice or fill (NOT single_choice/multi_choice/true_false)
  3. sql.js is in-memory — direct .db file writes are invisible to running server. You MUST restart the server after every import
  4. After restart, verify with API: curl http://localhost:8967/api/questions?subject=XXX&chapter=N
  5. Before starting, check existing chapter count: curl http://localhost:8967/api/questions?subject=XXX&limit=200 to avoid duplicates

Server restart procedure:

# 1. Find PID
netstat -ano | grep 8967 | grep LISTENING
# 2. Kill
taskkill //F //PID <PID>
# 3. Start (use foreground timeout trick — background=true causes "stdin is not a tty")
cd C:/Users/13657/Desktop/cryptoforge && node start_server.js
# 4. Wait, then verify
sleep 3 && curl http://localhost:8967/api/health

Fill-in-the-blank (填空题) format for CryptoForge:

  • type: fill
  • options: single-element array with the answer, e.g., ["响应"] or multi-blank array ["WCR", "MAR", "DAR", "0"]
  • answer: comma-joined answer text, e.g., "响应" or "WCR,MAR,DAR,0"
  • Short answer (简答题) also uses type: fill

HTTP API fallback (only if import script unavailable): POST /api/import/upload (multipart file) → POST /api/import/confirm with {filePath, subject, chapter, overwrite}

Pitfalls

  1. Don't wrap in markdown code blocks — output raw JSON unless saving to file
  2. Multi-choice answer sorting — "BD" not "DB", use alphabetical order
  3. True/false must use Chinese — options are ["对", "错"], answer is "对" or "错"
  4. Don't change the chapter mapping mid-batch — use the same subject.chapter scheme throughout
  5. When book has domain structure (like CISA) — map Domain 1→ch1, Domain 2→ch2, etc., and note the mapping
  6. Don't lose the explanation — even if from the source material, carry it through
  7. Difficulty should be consistent within a batch — basic recall=2, applied=3, scenario/analysis=4
  8. EPUB HTML class variants — McGraw-Hill practice exam books use BOTH class="ques" AND class="ques1" for question blocks in the answer section. Always search for both: <p class="ques[^"]*". Similarly, answer sections may use tick (correct) + check (incorrect explanation) instead of explicit answer letter markers. See references/mcgraw-hill-epub-patterns.md for the full HTML structure.
  9. Parse answers from the ANSWER section, not the Q section — for practice exam books, the answer section contains the most reliable correct-answer data (via tick markers). The question section alone lacks answer data.
  10. CTF/domain-heavy books can be imported as layered knowledge — map broad book parts to coarse chapter nodes first, then add finer subnodes from section headings so the database stays navigable without exploding node count.
  11. Keep source names user-facing — if the book title is long or noisy, use the concise display title in source, but keep the full title in the generated file name when saving the bank.
  12. For large EPUBs, extract a concise knowledge index first — chapter titles + key subtopics are often enough to drive question generation and node mapping without fully mirroring every paragraph.
  13. When importing into CryptoForge, preserve importable fields exactly — options should stay JSON-encoded text, nodes/formulas/siblings arrays should be present, and novel node ids are created automatically from nodes during import.
  14. Subject prefix must match existing nameMap — check server/index.js nameMap before inventing a new subject ID. Wrong prefix = questions land under an invisible subject (e.g., comp_org vs computer_org).
  15. Server restart is mandatory after direct DB writes — sql.js loads the .db file into memory at startup. Writing the file from an external script while the server runs has zero effect until restart. Use netstat -ano | grep 8967 | grep LISTENING to find PID, then taskkill //F //PID <PID>, then node start_server.js.
  16. Background mode fails for server startup — Hermes TUI terminal(background=true) causes "stdin is not a tty" error with the CryptoForge Node.js server. Instead, use the foreground timeout trick: run node start_server.js as a foreground command with a short timeout. The server continues running in the background after the terminal call times out.
  17. Deduplicate before import — Check existing questions via API (curl http://localhost:8967/api/questions?subject=XXX&chapter=N&limit=200) before bulk-inserting. If the same chapter already has questions from a prior batch (e.g., old ID format ch9.q01 vs new ch9.sc.001), delete the old batch first to avoid duplicates showing up in the UI.
  18. Fill-in-the-blank (填空题) import format — For CryptoForge: type must be fill (not fill_blank), options should be a single-element array or multi-blank array with the answer text, answer is the answer text (comma-joined for multi-blank). Short answer / 简答题 also uses type: fill. The import script does NOT shuffle fill question options (only shuffles choice type).

相关文章

更多
PHP cURL接收API响应并解析JSON数据的方法

使用 curl_init 初始化句柄,配置 CURLOPT_URL 、 CURLOPT_RETURNTRANSFER 等选项执行请求,获取响应后用 json_decode 解析为关联数组。

2026.10.30 1,000
deep-lu-trans:JSON对象与数组键值深度大小写转换工具

针对后端返回数据键值全大写导致前端使用不便的问题,介绍一款名为 deep-lu-trans 的轻量级工具。该库支持对嵌套的 JSON 对象和数组进行递归遍历,提供 objKeysToLower 和 arrKeysToUpper 等方法,实现键名的深度大小写转换,避免重复造轮子。

2025.05.03 992
PHP与JS JSON格式差异及跨域调用实现

本文对比了JavaScript对象数组与标准JSON格式的语法差异,并演示了PHP中json_encode和json_decode函数的用法。通过创建包含JSON数据的PHP文件并在HTML中直接嵌入变量,实现了前端JS对后端JSON数据的直接访问与解析,从而完成简单的跨域数据交互场景。

2025.12.04 983
PHP 接收 JSON 表单时,怎样区分不改备注和清除备注

用七份请求复现字段缺失、显式 null、空字符串和类型错误,结合 array_key_exists 保留订单编辑时各自的写入含义。

2025.06.14 979
PHP中serialize与json_encode对比:长度、速度及对象处理

在PHP开发中,serialize和json_encode是两种常用的数据转换方式。测试表明,json_encode生成的字符串长度约为serialize的一半,且在大数据量下的执行速度快近一个数量级。然而,serialize能够完整保留对象的方法定义和私有状态,而json_encode仅能处理数据属性,无法恢复对象行为。因此,serialize适用于需要持久化复杂对象结构的场景,而json_encode更适合轻量级的数据交换。

2025.09.04 964
PHP二维数组转JSON或CSV格式的方法

使用 json_encode 直接输出 JSON ,用 fputcsv 逐行写入 CSV 。

2025.03.03 964
Skill 文件
  • SKILL.md
    • Question Bank Formatter (题库格式化)
    • When to Use
    • Output JSON Format
    • Type Rules
    • ID Format Rules
    • Chapter Mapping
    • Difficulty Rules
    • Cleaning Rules
    • Workflow
      • Step 1: Parse Source
      • Step 2: Identify Question Type
      • Step 3: Determine Subject and Chapter
      • Step 4: Clean and Format
      • Step 5: Output
    • Integration
      • CryptoForge DB Direct Import
    • Pitfalls
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期