exam-to-template
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "exam-to-template" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-a2e16826b597d373bbd8e4830500ffe297d2bbff24699dbe6e0296962f8c34ab. Verify the upstream source and version against https://skillhub.cn/skills/user_2ed69ff3/exam-to-template before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
A tool to convert raw exam DOCX files into an intelligent import template format. Supports two scenarios: (1) questions and answers in the same document; (2) questions and answers in separate documents. Supports single-choice, multiple-choice, and true/false questions. Triggers: exam organization, question-bank import, intelligent template import, question formatting.
Introduction source: third_party · user_2ed69ff3 · 1.2.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Audience
- Not specified in the source documentation.
- Inputs and outputs
- Translation pending; see source documentation.
- Software, accounts and paid services
- Translation pending; see source documentation.
- Limits and differences
- Not specified in the source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: exam-to-template
slug: exam-to-template
version: 1.2.0
displayName: 试题智能导入模板转换
description: 将原始试题 docx 文档按智能导入模板格式整理。支持两种场景:(1) 试题+答案内嵌在同一文档;(2) 试题与答案分离在两个文档。支持单选题/多选题/判断题。触发词:试题整理、题库导入、智能导入模板、试题格式化。
agent_created: true试题 → 智能导入模板转换器
将原始试题文档转换为教学平台智能导入格式。
脚本选择指南
| 场景 | 脚本 | 题型支持 | 何时使用 |
|---|---|---|---|
| 试题+答案在同一文档 | convert_exam.py |
单选题(单一题型) | 题干末尾嵌有答案字母(如 题干:D),选项为无编号纯文本段落 |
| 试题与答案分离在两个文档 | convert_separated.py |
单选题 / 多选题 / 判断题 | 试题和参考答案是两个独立文件,试卷包含多种题型 |
快速判断:打开试题文档,如果能看到 "一、单选题" / "二、多选题" / "三、判断题" 这样的题型标题 → 用 convert_separated.py。如果只有连续的单选题目 + 无编号选项 → 用 convert_exam.py。
场景一:试题与答案在同一文档(convert_exam.py)
源文档格式(典型)
1. 下列哪项不是社区卫生服务的特点:D
综合
方便
有效
专科
经济
题干末尾的答案字母有三种变体:
- 冒号分隔:
题干:D - 空格分隔:
题干不包括 C - 无分隔符:
题干是A、题干?E
目标格式
单选题
1. 下列哪项不是社区卫生服务的特点
A、综合
B、方便
C、有效
D、专科
E、经济
答案:D
注意:题型行只保留类型名称(如"单选题"),不带"题型:"前缀。
用法
# Windows(命令提示符 / PowerShell)
python {baseDir}\scripts\convert_exam.py SOURCE_FILE OUTPUT_FILE [选项数] [标题]
# macOS / Linux
python3 {baseDir}/scripts/convert_exam.py SOURCE_FILE OUTPUT_FILE [选项数] [标题]
参数:
源文件.docx—— 原始试题文档路径输出文件.docx—— 输出路径选项数—— 每题选项数量,默认 5标题—— 文档标题(可选)
示例:
# Windows 示例
python %USERPROFILE%\.workbuddy\skills\exam-to-template\scripts\convert_exam.py ^
"C:\Users\xxx\Desktop\试题.docx" ^
"C:\Users\xxx\Desktop\试题_已整理.docx" ^
5 ^
"继续教育《社区护理学》单项选择题"
# macOS/Linux 示例
python3 ~/.workbuddy/skills/exam-to-template/scripts/convert_exam.py \
"/Users/xxx/Desktop/试题.docx" \
"/Users/xxx/Desktop/试题_已整理.docx" \
5 \
"继续教育《社区护理学》单项选择题"
解析逻辑
脚本通过两道正则按顺序匹配题号行:
- 冒号型:
^(\d+)[.、]\s*(.+?)[::]\s*([A-E])$— 有明确分隔符,匹配精度高 - 无冒号型:
^(\d+)[.、]\s*(.+?)\s*([A-E])$— 无分隔符,可能模糊
先匹配冒号型可确保冒号不会被错误吞入题干(非贪婪匹配会优先使用冒号作为分隔符)。
场景二:试题与答案分离在两个文档(convert_separated.py)
当试题和参考答案是两个独立文件时(常见于包含多种题型的试卷),使用 convert_separated.py。
源文档格式
试题文档 (.docx):典型试卷格式,包含题型标题(一、单选题 / 二、多选题 / 三、判断题),每题有题干和选项。
答案文档 (.doc 或 .docx):纯文本格式,按题型列出答案:
一、单项选择题
DDBEED...
二、多项选择题
ABCDEABDABCE...
三、判断题
√√×√×...
用法
# macOS / Linux
python3 {baseDir}/scripts/convert_separated.py <试题.docx> <参考答案.doc> [输出.docx] [标题]
# Windows
python {baseDir}\scripts\convert_separated.py <试题.docx> <参考答案.doc> [输出.docx] [标题]
参数:
试题.docx—— 试题文档路径(必填)参考答案.doc—— 答案文档路径(必填,支持 .doc/.docx)输出.docx—— 输出路径(可选,默认在试题同目录下,文件名加_已整理后缀)标题—— 文档标题(可选)
示例:
python3 ~/.workbuddy/skills/exam-to-template/scripts/convert_separated.py \
"/path/to/护理管理学 试题.docx" \
"/path/to/参考答案.doc" \
"/path/to/护理管理学_已整理.docx" \
"护理管理学试题"
解析逻辑
答案解析:
.doc文件通过 macOStextutil -convert docx转换后读取- 单选题:按顺序提取 A-E 字符
- 多选题:先过滤数字,再按"字母严格递增"规则分割(如
ABCDEABD→ABCDE,ABD) - 判断题:按顺序提取 √× 字符
试题解析:
- 合并所有段落为完整文本,按题型标题(一、单选题 / 二、多选题 / 三、判断题)切分区域
- 选择题:用
(?:^|\n)(\d+)[.、]定位题号起始位置,按题号边界切出每道题的 block;再用(?=[A-E][、..])分割选项和题干 - 判断题:用
[((]\s*[))]\s*(\d+)[.、]?\s*(.+?)(?=...)匹配( )题号. 题干格式
支持的复杂格式
- 多题挤在同一段落(如第 N 题选项与第 N+1 题题干同段)
- 每行一个选项 vs 所有选项在同一行(Tab 分隔)
- 判断题带/不带句号
- 题干中嵌入的括号
( )
运行环境(跨平台)
依赖安装(优先使用国内镜像):
| 镜像 | 命令 |
|---|---|
| 清华 TUNA | pip install -i https://pypi.tuna.tsinghua.edu.cn/simple python-docx |
| 阿里云 | pip install -i https://mirrors.aliyun.com/pypi/simple python-docx |
| PyPI 官方 | pip install python-docx(备用,较慢) |
命令名称差异:
- Windows:使用
python - macOS / Linux:使用
python3或python
字体说明:
- 默认使用"宋体"(Windows/macOS 的 Office 均支持)
- 如需修改,设置环境变量
EXAM_FONT
边界情况与局限
convert_exam.py
| 情况 | 行为 | 建议 |
|---|---|---|
| 题干以 A-E 字母结尾且无冒号分隔 | 可能误将题干尾部字母识别为答案,脚本会打印 ⚠️ 警告 | 人工核实警告的题目,或在源文档中加上冒号分隔 |
| 各题选项数不一致(混合题) | 选项数≠参数值的题目被跳过 | 分批次处理不同选项数的题目 |
| 选项中间夹杂非选项文本段落 | 选项数不匹配导致题目被跳过 | 清理源文档中多余的空白段落或说明文字 |
| 源文档包含题干说明/前言段落 | 可能被误识别为选项,导致第一题被跳过 | 删除源文档中的前言段落 |
| 仅支持单选题 | 不支持多选题、判断题 | 多题型场景请使用 convert_separated.py |
convert_separated.py
| 情况 | 行为 | 建议 |
|---|---|---|
| 题型标题不匹配(非"一、单选题"格式) | 无法定位题型区域,解析失败 | 确保文档标题为 一、单选题 / 二、多选题 / 三、判断题 |
| 答案文档是旧 .doc 格式 | 通过 macOS textutil 自动转换;非 macOS 需手动转为 .docx |
Windows 用户先手动另存为 .docx |
| 多选题答案字符串格式异常(字母不递增) | 分割错误导致答案错位 | 检查答案文档中的多选题答案格式 |
判断题区域无 ( ) 占位符 |
解析失败 | 确保每题前有 ( ) 或 ( ) 格式的括号 |
常见问题
文件路径报错
❌ 错误: 找不到文件 'xxx'
原因:路径拼写错误、文件不存在、路径中包含空格或中文未加引号。
解决:
- 确认文件确实存在:
ls "/path/to/file.docx"(macOS/Linux)或dir "C:\path\to\file.docx"(Windows) - 路径含空格或中文时用双引号包裹:
python convert_exam.py "C:\My Docs\试题.docx" ...
提示"未解析到有效题目"
原因:题干行格式不符合预期、选项数与参数不一致。
排查步骤:
- 确认题干行以数字 +
.或、开头(如1.、2、),末尾有 A-E 答案字母 - 检查选项数量是否与参数一致(默认 5 个,可用第 3 个参数调整)
- 清理源文档中的空白段落、前言说明或多余的格式标记
"题干包括 A" 这类题干被误判
题干以字母 A-E 结尾且无冒号分隔时,脚本可能误将题干尾字母当作答案。脚本运行后会在输出中打印 ⚠️ 警告,列出所有可疑题目。收到警告后,请在源文档中该类题目末尾加上冒号(如 题干包括 A: 改为 题干包括 A:B),或手动核实答案。
输出文档格式不符
确认选项数量参数与源文档一致。若源文档部分题目选项数不同,需分批次处理。
字体显示异常
脚本通过 EXAM_FONT 环境变量控制字体,默认"宋体"。若输出文档字体异常:
- Windows:
set EXAM_FONT=SimSun后运行脚本 - macOS:
export EXAM_FONT="Songti SC"后运行脚本
交互式调用指南
如果用户不提供完整参数,执行以下步骤:
- 确定场景 —— 试题文档是否有 "一、单选题/二、多选题" 等标题?有 →
convert_separated.py;无 →convert_exam.py - 确定源文件路径 —— 用户提供或询问
- 确定参数 —— 选项数量(convert_exam 默认 5)、输出路径(默认同目录
_已整理后缀)、标题(可选) - 运行脚本,查看结果
- 若有 ⚠️ 警告,提醒用户核实模糊匹配的题目
- 确认输出后告知用户
Current listing version
1.2.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 直接解决用户在教学场景中整理试题文档的核心痛点,显著提升效率
- 支持多种题型(单选/多选/判断)和复杂格式,适用性强
- 提供两种场景的完整解决方案,覆盖常见使用需求
Highlights
- 触发词精准完整,覆盖多种变体(试题整理、题库导入、智能导入模板、试题格式化)
- 边界清晰,不易与其他 Skill 重叠
Highlights
- Phase/步骤清晰,有明确的出口条件和端到端示例
- frontmatter完整,单文件结构良好,易于理解执行流程
Highlights
- 工具来源明确,参数正确,覆盖主要异常情况
- 不可逆操作有确认机制,提供详细的边界情况说明和常见问题排查
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 174, 175, 176
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- mirrors.aliyun.com
- pypi.tuna.tsinghua.edu.cn
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Translation pending; see source documentation.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.