---
name: sylvia-exam
description: Use when converting test paper photos, scanned exam sheets, or question screenshots of any subject into dual-track digital materials (a clean student practice worksheet preserving blanks and a teacher solution sheet with answers and detailed explanations), outputting both editable Word (.docx) and print-ready PDF/HTML in A4 or B4 formats.
---

# Universal Exam Dual Sheet (通用考卷雙軌數位化神器)

## Overview

A robust, teacher-oriented digitization and instructional transformation pipeline. It converts photographed or scanned exam sheets (A4 or B4, single or double column, multi-subject, containing handwriting marks, diagrams, or imperfect lighting) into two professional, standardized outputs:
1. **Student Practice Sheet (學用練習卷)**: Clean, handwriting-free, structured questions preserving original blanks, response parentheses `(   )`, and 11–12 pt typography.
2. **Teacher Solution Sheet (教用解答解析卷)**: Red-bold answers, sentence-by-sentence Chinese translations, curriculum-aligned core concepts (e.g., 7000-word levels, grammar, formulas), distractor elimination rationale, and reading text line citations in 9–10 pt.

Delivers both **editable Word (.docx)** and **100% Print-safe HTML/PDF** for instant classroom distribution and printing.

---

## When to Use

- When given a smartphone photo, scan, or screenshot of a paper exam, test sheet, or quiz.
- When the original sheet has student handwriting, grading checkmarks, highlighter strokes, or folds that must be cleaned out.
- When an exam needs to be formatted for either **A4** (210×297mm) or **JIS B4** (250×353mm, double-column).
- When a teacher needs both a clean practice sheet for students and a comprehensive explanation key for instruction/correction.
- When questions contain diagrams, charts, geometric figures, biology/physics diagrams, or comics that must be preserved.

---

## Core Operational Workflow

```
[Exam Photo / Screenshot (A4/B4)]
          │
          ▼
┌──────────────────────────────────────┐
│  Phase 1: Vision OCR & De-noising    │
│  - Filter out handwriting & markings │
│  - Contextual spell/grammar check    │
│  - Bounding-box detection for images │
└──────────────────────────────────────┘
          │
          ▼
┌──────────────────────────────────────┐
│  Phase 2: Pedagogical Solving Engine │
│  - Solve every question with 100% acc│
│  - Provide fluent Traditional Chinese│
│  - Core test points & distractor why │
│  - Reading passage line/evidence ref │
└──────────────────────────────────────┘
          │
          ▼
┌──────────────────────────────────────┐
│  Phase 3: Dual-Track Generation      │
│  - Student Sheet (11-12pt, blanks)   │
│  - Teacher Sheet (9-10pt explanation)│
│  - Export .docx via python-docx      │
│  - Export .html for 100% PDF print   │
└──────────────────────────────────────┘
```

---

## Typography & Page Layout Specifications

### 1. Page Dimensions & Margins
- **A4 Specification**: 210 × 297 mm. Margins: Top/Bottom 12mm, Left/Right 12mm.
- **JIS B4 Specification**: 250 × 353 mm (standard Taiwanese school exam size). Typically formatted in 2 balanced columns with 15mm outer margins.
- **Print-Safe Rule**: All text, tables, and borders MUST remain within margins. 100% Actual Size printing without shrinking or clipping.

### 2. Strict Typography Hierarchy
- **Exam Title**: 16–18 pt, Bold, Centered. Teacher edition adds `【教師解答解析卷】` in bold red (`#C53030`).
- **Student Info Row**: `班級：_______  座號：_____  姓名：_______________  得分：_______` (10.5 pt).
- **Section Headers**: 12–13 pt, Bold (e.g., `一、 詞彙測驗 (Vocabulary)`).
- **Question Stems & Options**:
  - Font Size: Strictly **11.0 pt ～ 12.0 pt** (Times New Roman for English, Microsoft JhengHei / PMingLiU for Chinese).
  - Tolerance: $\pm 10\%$ micro-adjustment allowed to prevent awkward single-line orphan overflow.
  - Option Grid: Standard 2×2 layout (`(A)` / `(B)` on left, `(C)` / `(D)` on right) or inline spaced, never squished.
- **Teacher Edition Layout (B1L1 Master Visual System / 校本迷你雜誌風卡片系統)**:
  - **🚫 嚴禁在題下堆砌大塊笨重灰色長篇解析框**（粗製濫造、浪費版面與紙張、破壞視覺美感）。
  - **✔ 題目全面卡片化 (`.q-card`)**：每題封裝於帶細黑邊框（`1px solid #666`）、白底、圓角之獨立卡片內。
  - **✔ 頂部卡片標籤列 (`.q-header`)**：
    - 左側：紅色大字答案 `( <span class="score-val">B</span> )`
    - 中間：黑色圓角膠囊題型徽章（如 `Q35 Picture Match`、`Q1 Vocabulary`）
    - 右側：自評或訂正星號 `★`（學生版為空心 `☆`）
  - **✔ 題幹與選項雙欄網格 (`.q-options`)**：
    - 題幹採 Times New Roman 10.5pt 粗體黑字。
    - 選項嚴格採 2×2 網格對齊（或單行排列），絕不擁擠擠壓。
  - **✔ 精巧粉紅詳解膠囊 (`.q-exp-box`)**：
    - 位於卡片最底部，底色 `#fff5f5`，淡粉紅框 `1px solid #feb2b2`，紅色文字 `#c53030`，8.2pt 微軟正黑體。
    - 以 1～2 行精鍊文字直擊「核心考點與誘答排除理由」，視覺精巧細膩，完全不佔篇幅。
  - **✔ 正面課文卡片與背面翻譯卡對齊**：
    - 正面段落以 `[ 1 ]`, `[ 2 ]` 黑色方塊徽章卡片化呈現，難字以紅色底線標記並附行內小中譯。
    - 背面底部附對稱網格之完整繁體中文翻譯卡。

---

## Vision OCR & Handwriting Removal Rules

1. **Active De-noising**:
   - Strip all red checkmarks, pencil scribbles, circled answers, highlighter shading, and correction tape marks.
   - Reconstruct all questions into pristine, un-answered blanks.
2. **Contextual Text Recovery**:
   - If letters/words are slightly blurred by camera focus or shadow, leverage contextual English grammar, collocations, and the CEEC 7000 vocabulary syllabus to restore accurate words.
   - If an equation or word is genuinely unreadable, flag it explicitly as `[模糊待確認: xxx?]` instead of hallucinating.
3. **Column Ordering**:
   - For B4 double-column exams, strictly process from Top-to-Bottom on the Left Column first, then Top-to-Bottom on the Right Column. Do not jump across columns.

---

## Multi-Subject & Diagram Question Handling

This skill is subject-agnostic (English, Chinese, Math, Physics, Chemistry, Biology, History, Geography, Civics):
- **For Picture & Diagram Questions**:
  1. **Image Cropping**: Use Python `Pillow` to crop the diagram bounding box from the original uploaded photo and save as `assets/q[N]_diagram.png`.
  2. **Embedding**: Insert the cropped diagram directly below the question stem in both Word (`.docx`) and HTML.
  3. **Data Tables & Charts**: Transcribe into clean, border-aligned HTML/Word tables rather than blurry bitmap crops whenever possible.

---

## Dual-Track Output Structure

### 1. Student Edition (`[Exam_Name]_student.docx` / `.html`)
- Header with school/exam title and score row.
- Numbered questions with `(   )` answer brackets and generous fill-in underlines.
- Clean 11.5 pt font, zero answers or spoiler hints.

### 2. Teacher Edition (`[Exam_Name]_teacher.docx` / `.html`)
- Quick Answer Key Table at the very top (e.g., `1-5: A C B D A | 6-10: ...`).
- In-place red bold answers: `(B) 1. The scientist...`
- Every question includes an explanation card:
  - **【題目中譯】**: Fluent, natural Traditional Chinese translation.
  - **【核心考點】**: 7000-word level (`[Level 4]`), grammar rules, formulas, or historical concepts.
  - **【破題關鍵】**: Direct reasoning steps and evidence.
  - **【盲點與選項排除】**: Why distractors (A), (C), (D) are incorrect.
  - **【閱讀定位】**: Paragraph and line citations for reading comprehension questions.

---

## 🛡️ 自動防呆環境檢測與套件安裝機制 (Fail-Safe Dependency Auto-Installer)

為確保教師研習與教學現場「**零資訊門檻、人人都能成功**」，本技能內建智慧環境探測與防呆安裝機制：

### 1. 終端機與 AI 助手主動防呆 (Agent Proactive Check)
當使用者要求生成 Word (.docx) 考卷或呼叫 Python 工具時，AI 助手與腳本會主動檢查環境依賴：
- **依賴檢查**：檢查 `python-docx` 與 `Pillow` 是否存在。
- **自動主動提示並安裝**：
  若尚未安裝，AI 會主動提示學員：
  > 「⚠️ 偵測到您的環境尚未安裝考卷數位化必備套件（`python-docx`, `Pillow`），請老師放心，系統正在為您自動執行安裝，無需手動輸入指令...」
  並自動在終端機執行：
  ```bash
  pip install python-docx Pillow
  ```
- **腳本自癒**：`scripts/exam_builder.py` 內建前置自動檢測代碼，即使學員直接以 Python 執行該腳本，也會在 5 秒內自動安裝缺失套件並繼續執行，絕不拋出殘酷的 `ModuleNotFoundError`。

### 2. 純網頁版零安裝備援方案 (Web AI Zero-Install Fallback)
若研習學員使用的是純網頁版 AI（ChatGPT、Claude、Gemini 網頁端）或學校公用電腦無 pip 安裝權限：
1. **輸出高相容獨立 HTML**：AI 直接產出符合 B1L1 校本雜誌風之單一 HTML 檔案（內嵌所有樣式與圖片）。
2. **Word 一鍵另存新檔**：
   - 點開 Microsoft Word $\rightarrow$ 「開啟舊檔」選擇該 HTML。
   - 點擊「檔案 $\rightarrow$ 另存新檔」$\rightarrow$ 格式選「Word 文件 (*.docx)」，排版與字體完全保留！
3. **無痛轉 PDF**：在 Chrome / Edge 瀏覽器開啟 HTML，按 `Ctrl + P` 另存為 PDF 即可直接送印。
*(詳細研習步驟請參閱 `references/workshop_quickstart.md`)*。

---

## Common Pitfalls & Quality Checks

| Issue | Prevention Rule |
| :--- | :--- |
| Hand-drawn checks leaking into student sheet | Enforce blank extraction: replace any circled option with clean `(   )`. |
| Jumped columns in B4 scans | Explicitly map column layout before extracting question text. |
| Tiny font unreadable for students | Hard constraint: question font MUST be 11–12 pt. Only explanations use 9–10 pt. |
| Page overflow onto blank 3rd page | Set page margins strictly to 12mm; adjust paragraph spacing before reducing font size. |

---

## 🔒 跨 Agent 執行防漂移鐵律 (Cross-Agent Anti-Drift Protocol)

> **⚡ 適用環境：Google Antigravity、OpenAI Codex CLI、Claude Code、Cursor 等全平台 Agent**

任何 AI Agent 在執行本技能時，**嚴禁依賴各平台大模型的默認輸出習慣自由發揮**，必須 100% 嚴格落實以下防漂移守則：

1. **零自作主張 (Zero Creative Deviation)**：
   - 嚴格沿用本規範定義之排版結構、區塊順序、欄位標籤與樣式。
   - **嚴禁私自「改寫/簡化」架構**（例如擅自將特定 Flex/Grid 佈局改寫為文字列表、將精確卡片改為空泛條列、或將樣式簡化）。
   - **嚴禁自創未經授權的新區塊**（例如擅自新增額外理論講義、發音表或未要求的長篇大論）。
2. **骨架代碼與格式優先 (Template Boilerplate Priority)**：
   - 若本規範提供具體代碼片段（HTML、CSS、JS、Markdown 骨架、卡片容器），必須作為不可變更之「填空基底 (Immutable Slots)」。
   - Agent 的任務僅是將內容精準填入對應的 Slots 容器中，**禁止改動外層容器 class 名稱、DOM 結構與事件綁定機制**。
3. **成品規格不降級 (No Spec Downgrade)**：
   - 嚴禁因 Token 長度限制或內容龐大，而將「圖文並茂互動網頁/雙軌講義」偷工減料降級為「純文字草稿」或「簡短大綱」。
   - 遇長文本時必須完整輸出全課內容或完整分段寫入目標檔案，**絕不省略後半段**。
4. **雙軌/多模態完整性 (Dual-Track Completeness)**：
   - 凡涉及「學生練習版」與「教師紅字解答版」之技能，必須兩套完整產出，答案與詳解必須扎實完整，嚴禁留白。
   - 凡涉及固定卡片數量（如 2 張文法卡片、5 大單字卡片、10 題挖空等），**嚴格維持指定數量，不多不少**。
5. **角色語氣與受眾鎖定 (Persona & Audience Alignment)**：
   - 嚴格維持臺灣高中職英語科專業教師立場，第二人稱「你」或「同學們」具同理心之對話語調，**嚴格杜絕第三人稱論文式說教腔**。

### 🏛️ 考卷雙軌數位化格式鎖定 (Exam Dual Sheet Standards)
1. **雙軌並行**：學生練習版（保留所有填空、選擇、混合題排版）與教師解答版（標註正確答案、翻譯、考點剖析、干擾項排除理由）。
2. **格式支援**：支援 Word (.docx) 與 Print-Safe HTML/PDF 格式。
