---
name: create-clean-practice-sheets-from-filled-school-tests
description: Create clean printable practice worksheets and solution sheets from filled/photographed school tests when direct cleanup would damage readability.
---

# Create clean practice sheets from filled school tests

Use this when the user has photographed/scanned filled school tests and wants reusable practice material for a child/sibling. If removing handwriting/red corrections from the original makes the page unreadable, recreate the worksheet cleanly instead of overpainting the scan.

## Trigger conditions

- Filled school tests contain pencil/pen answers, solution paths, teacher corrections, grades, or red notes.
- The user wants a blank practice version.
- Image cleanup causes any of these problems:
  - printed task text becomes hard to read or pixelated,
  - white masks cover parts of the exercise,
  - scan quality is too low,
  - handwriting overlaps too heavily with printed material.

## Recommended workflow

1. **Locate the source PDFs and OCR/index files**
   - Search by known title/subject/LZK number.
   - Prefer existing structured folders under the learning area, e.g. `family/Lernen/...`.
   - Read README/OCR files to understand page count, topic, and likely task types.

2. **Extract only the task structure, not the answers**
   - Use OCR text first: Tesseract/Docling/Paddle index if available.
   - Use LLM vision sparingly on contact sheets or selected pages only when OCR is insufficient.
   - Do not transcribe child handwriting unless needed and explicitly appropriate.
   - Identify:
     - exercise numbers,
     - instructions,
     - mathematical operations/topics,
     - approximate difficulty,
     - layout needs such as grids, answer lines, multi-column tasks.

3. **Decide: cleanup vs recreation**
   - If scan cleanup harms readability, stop trying to erase handwriting.
   - Recreate a clean worksheet with same or very similar task types.
   - Keep it pedagogically equivalent, not necessarily identical.
   - Preserve the school level and topic vocabulary.

4. **Create clean PDFs**
   - Use a deterministic PDF generator such as Python `reportlab`.
   - Use A4 page size, readable fonts, clean margins.
   - Add title/header, child-neutral naming, and page numbering.
   - For math work areas, draw light grid/Häuschen lines instead of using the scan background.
   - Avoid image-based text where possible; vector text keeps output sharp.
   - Name files clearly, e.g.:
     - `Mathe_Valerie_Uebungsblatt_LZK_4_12_..._neu.pdf`
     - `Mathe_Valerie_Loesungsblatt_LZK_4_12_..._neu.pdf`

5. **Calculate and verify solutions with tools**
   - Never calculate manually in the response.
   - Use Python/terminal for arithmetic, divisions with remainder, and puzzle checks.
   - Watch for accidentally ambiguous generated tasks. If an exercise has multiple valid solutions, either fix the worksheet or clearly note it in the solution sheet.

6. **Create solution sheets**
   - Separate PDFs are better than embedding solutions in the worksheet.
   - Include stepwise decompositions where useful, especially for:
     - Rechenprotokoll,
     - written multiplication/division,
     - division with remainder,
     - inverse/word-number tasks.

7. **Verify output before delivery**
   - Run `pdfinfo` or equivalent to verify page count, A4 size, and file existence.
   - Render a contact sheet with `pdftoppm` and inspect visually.
   - Vision check should confirm:
     - readable text,
     - no handwriting/red corrections,
     - no white masks/overlapping blocks,
     - no cut-off task instructions,
     - grids/answer spaces are usable.

8. **Deliver artifacts**
   - Send the final worksheet PDFs and solution PDFs via `MEDIA:` paths.
   - Briefly mention any known caveat, e.g. ambiguous task or deliberately similar rather than identical numbers.

## Tool notes from successful run

- `reportlab` worked well for sharp, clean PDFs.
- `pdftoppm` can render PDFs to PNGs for contact-sheet verification.
- A contact sheet is efficient for a sparse vision check: render all pages at moderate DPI, thumbnail them into one image, then ask vision to check layout/readability.
- For 4th-grade math sheets, use light blue grid lines and clear headings; avoid recreating noisy scan backgrounds.

## Pitfalls

- Do not keep overpainting original scans if text becomes pixelated or masks hide parts of tasks.
- OCR of filled worksheets may mix printed text with handwriting; treat it as a guide, not ground truth.
- Long exercise headings may overlap the points column; wrap titles before PDF generation or inspect with a contact sheet.
- Some generated missing-digit puzzles can have more than one solution; brute-force verify them before finalizing.
- Avoid sending child test images to external APIs unless the user explicitly approves the privacy implications.

## Example verification commands

```bash
pdfinfo worksheet.pdf | grep -E 'Pages|Page size|File size'
pdftoppm -r 110 -png worksheet.pdf /tmp/render_prefix
```

Then build a contact sheet with PIL and inspect it using vision.
