Skip to main content

pevaluate

pevaluate helps grade Moodle submissions with an LLM. It can unpack Moodle downloads, extract nested student zips, convert notebooks to Markdown, prefer notebooks over exported HTML, clean noisy HTML artifacts, save structured feedback as YAML, and compile that feedback back into a Moodle marks CSV.

The package installs as pevaluate. The older autocorrect command is still available as a CLI alias.

AI4Exams ecosystem

Pevaluate is part of the AI4Exams ecosystem together with ptestgen, pexams, and the planned pstudio visual orchestration layer.

AI4Exams ecosystem

Installation

Install the package in editable mode from this repository:

pip install -e .

Install the Playwright browser binaries used for HTML-to-PDF export:

playwright install chromium

Create a .env file with your OpenRouter API key:

OPENROUTER_API_KEY=your_api_key_here

Moodle Setup

For Moodle upload/download workflows, enable the feedback tools in the assignment settings:

  1. Open the assignment settings.
  2. Under Feedback types, enable Feedback files and Offline grading worksheet.

Enable Feedback Comments

  1. Download the Moodle submissions zip and, later, download the grading worksheet or marks CSV.

You do not need to unzip the Moodle submissions zip manually. The simplest workflow is to put the downloaded zip in the session folder and let pevaluate unpack it.

If you already unzipped the Moodle download yourself, use --no-unzip --students-dir path/to/submissions.

Session Folder

A representative session folder looks like this:

my_assignment/
  moodle_submissions.zip
  rubric.txt
  example.txt
  marks.csv

marks.csv is only needed when compiling feedback back into a Moodle upload CSV. If student submissions contain their own zip files, add --extract-nested-zips.

Representative Workflow

First run a dry pass. This unpacks submissions, extracts nested zips, converts notebooks for inspection, and does not call the LLM:

pevaluate "my_assignment" \
  --extract-nested-zips \
  --no-grade \
  --no-reference \
  --files-regex ".*\.(ipynb|html)$" \
  --prefer-extensions ".ipynb;.html"

After checking the generated files, run grading without unpacking/converting again:

pevaluate "my_assignment" \
  --no-unzip \
  --no-convert \
  --no-reference \
  --rubric rubric.txt \
  --example example.txt \
  --files-regex ".*\.(ipynb|html)$" \
  --prefer-extensions ".ipynb;.html" \
  --keep-prompt \
  --model "google/gemini-3.1-pro-preview"

For an already unzipped Moodle download:

pevaluate "my_assignment" \
  --no-unzip \
  --students-dir "my_assignment/submissions" \
  --extract-nested-zips \
  --no-reference \
  --files-regex ".*\.(ipynb|html)$" \
  --prefer-extensions ".ipynb;.html"

For a single submission file, pass the file directly. Use --output-dir when you want prompts and feedback somewhere other than the file's parent folder:

pevaluate "path/to/Memoria_TFG.pdf" \
  --output-dir "generated/tfg_evaluation" \
  --rubric rubric.txt \
  --example example.txt \
  --no-reference \
  --include-images \
  --keep-prompt \
  --no-evaluate

By default, if both .ipynb and .html exist for the same submission, pevaluate grades the .ipynb and reports the skipped .html. HTML artifacts are cleaned from .ipynb, .md, and .html content before prompting. Disable this only when those artifacts are relevant to grading:

pevaluate "my_assignment" --no-cleanup-html

--not-cleanup-html is accepted as an alias.

If submissions include relevant visual material in .pdf, .pptx, .docx, .md, .html, or direct image files, opt in to sending extracted images to the LLM:

pevaluate "my_assignment" \
  --no-unzip \
  --no-convert \
  --no-reference \
  --files-regex ".*\.(pdf|pptx|docx|md|html|png|jpg)$" \
  --include-images

Images are deduplicated by content hash before sending, which avoids repeatedly attaching common logos or reused slide assets. Use --max-images to cap attachments per submission, or --no-dedupe-images when repeated images are intentionally meaningful.

Use --keep-prompt to save the exact prompt as Markdown in prompts/. When --include-images is enabled, the prompt Markdown includes local image references and the extracted images are written to a sibling prompt asset folder. For PDFs, pevaluate uses pymupdf4llm.to_markdown by default with header=False, footer=False, use_ocr=False, and force_text=True, so figures are referenced near their extracted position in the Markdown instead of being collected at the end. Use --markdown-config with a JSON object or JSON file path to override converter options. Use --no-evaluate to prepare prompts and print approximate token consumption without calling the model.

Document inputs are first converted to a Markdown intermediate representation:

Input Markdown pipeline Image handling
PDF pymupdf4llm.to_markdown(..., header=False, footer=False, use_ocr=False, force_text=True) using the modern layout backend by default; optional pdf_backend="legacy" only as an escape hatch Extracted to relative Markdown references; only attached to the LLM with --include-images.
DOCX python-docx paragraphs/tables/media Extracted to relative Markdown references; only attached with --include-images.
PPTX PyPI python-pptx, with package-XML fallback Extracted to relative Markdown references; only attached with --include-images.
MD/HTML Native text with local/data image reference rewriting References are kept/rebased; only attached with --include-images.
IPYNB nbconvert.MarkdownExporter Notebook Markdown output is used; embedded images are not sent unless extracted by the selected path.
Direct image Markdown image reference Only attached with --include-images.
TXT/code/SQL UTF-8 text No image extraction.

The modern PyMuPDF4LLM layout backend usually gives better Markdown and is the recommended default. If you explicitly prefer the older RAG backend for a particular file, you can use a JSON config file like:

{
  "pdf_backend": "legacy",
  "ignore_graphics": true,
  "image_size_limit": 0.08
}

The legacy backend exposes ignore_graphics, image_size_limit, and graphics_limit, but it may produce worse layout. pevaluate also normalizes common PDF ligatures and control-code artifacts after extraction, including fi/fl substitutions.

pevaluate depends on the standard PyPI python-pptx package so releases can be uploaded to PyPI. For local work with PPTX files that need improved equation/MathML extraction, you can manually replace it with Oscar's fork after installing pevaluate:

pip install --force-reinstall --no-deps git+https://github.com/OscarPellicer/python-pptx.git

Rubric File

The rubric should explain the grading criteria, expected output style, and any automatic benchmark or competition scores the model should consider. If feedback must name the students, include a roster in the rubric, especially for group assignments.

Example:

Grade from 0 to 10. Be brief and assertive.

Notebook, 70%:
- 1.5 points: data understanding and validation.
- 3.0 points: classical model.
- 3.0 points: modern model.
- 1.0 point: experimental comparison.
- 0.5 points: error analysis and conclusions.
- 0.5 points: clarity and reproducibility.

Challenge, 30%:
Use the challenge table below. Report the team's challenge mark and combine:
final_mark = 0.70 * notebook_mark + 0.30 * challenge_mark.

Groups:
| Group | Students |
| --- | --- |
| G01 | Ana García López; Luis Pérez Soler |
| G02 | Marta Ferrer Vidal; Pablo Ruiz Mora |

Challenge results:
| Group | Rank | score | challenge_mark |
| --- | --- | --- | --- |
| G01 | 1 | 0.812 | 10.0 |
| G02 | 2 | 0.790 | 8.5 |

Example Feedback File

The example file should show the tone and level of detail you want. It does not need to match the assignment exactly.

Grupo G01:
- Ana García López
- Luis Pérez Soler

Notebook (70%):
0. Errores de código: 0.5/0.5.
1. Planteamiento, datos y validación: 1.25/1.5. La validación es razonable, pero faltó justificar mejor la partición.
2. Modelo clásico: 2.75/3.0. Buen resultado; faltó comparar algún hiperparámetro adicional.
3. Modelo moderno: 3.0/3.0.
4. Comparación experimental: 0.75/1.0. La tabla de resultados es clara, pero el análisis es algo superficial.
5. Análisis de errores y conclusiones: 0.25/0.5.
6. Claridad y reproducibilidad: 0.5/0.5.

Challenge (30%): posición 2/20. Nota challenge: 8.5/10.

Nota notebook: 8.75/10.
Nota final: 8.30/10.

Structured Feedback YAML

Each graded submission is saved in feedback/ as YAML. Filenames include a readable name plus a short source hash, so repeated generic filenames do not overwrite each other.

students:
  - full_name: Ana García López
  - full_name: Luis Pérez Soler
feedback: |
  Grupo G01:
  - Ana García López
  - Luis Pérez Soler

  Notebook (70%): 8.75/10.
  Challenge (30%): 8.5/10.

  Buen trabajo. La validación es razonable y los resultados son sólidos; faltó un análisis de errores más concreto.

  Nota final: 8.30/10.
mark: 8.3
submission_file: C:\path\to\submission.ipynb
source_id: 1a2b3c4d

The LLM is instructed to return this schema. If it returns plain text, pevaluate saves the text under feedback and tries to extract a numeric mark.

Moodle CSV Export

Compile YAML feedback into a Moodle upload CSV:

pevaluate moodle-csv "my_assignment/marks.csv" \
  --feedback-dir "my_assignment/feedback" \
  --output "my_assignment/marks_filled.csv" \
  --feedback-format html \
  --partial \
  --clear-timestamps

The converter writes the same group mark and feedback to every student listed in a YAML file. It matches students by normalized full name, handling both Nombre Apellido and Apellido, Nombre.

Moodle column headers vary by site language. pevaluate moodle-csv resolves common Catalan, Spanish, and English headers automatically for full name, grade, feedback comments, and timestamp columns. If your Moodle uses custom names, pass them explicitly with --name-column, --grade-column, --feedback-column, --submission-modified-column, and --grade-modified-column.

--feedback-format html escapes the feedback text and converts newlines to <br>, which is useful when Moodle flattens raw CSV newlines during import. Use --feedback-format plain to keep literal newlines.

--partial writes only the rows that pevaluate updated. This is safer for Moodle offline grading worksheets because a full worksheet can unintentionally clear existing feedback in rows that are blank in the uploaded file. --clear-timestamps sets Moodle's last-modified columns to - for updated rows; this helps when Moodle refuses rows whose worksheet timestamps are older or already populated.

For a second pass after downloading the current Moodle worksheet, fill only rows still missing a grade or feedback:

pevaluate moodle-csv current_moodle_marks.csv \
  --feedback-dir feedback \
  --output marks_filled_missing_only.csv \
  --feedback-format html \
  --partial \
  --skip-filled \
  --clear-timestamps

If exact matching fails, it uses fuzzy matching with a normalized Levenshtein threshold of 70/100 by default and reports each fuzzy match:

pevaluate moodle-csv marks.csv \
  --feedback-dir feedback \
  --output marks_filled.csv \
  --fuzzy-threshold 70

Use --fuzzy-threshold 0 to disable fuzzy matching. If your Moodle CSV uses different column names, pass them explicitly:

pevaluate moodle-csv marks.csv \
  --feedback-dir feedback \
  --output marks_filled.csv \
  --name-column "Full name" \
  --grade-column "Grade" \
  --feedback-column "Feedback comments"

Upload the generated CSV back to Moodle using the assignment grading import/upload option.

Open-Answer Exam Evaluation

pevaluate exam-open grades the open-answer crops extracted by pexams correct. It expects:

  • open_responses_index.csv from the pexams correction output.
  • The original pexams exam directory containing exam_model_*_questions.json.
  • The crop images referenced from the index CSV.

Basic run:

pevaluate exam-open \
  --index-csv generated_exam/correction_results/open_responses_index.csv \
  --exam-dir generated_exam \
  --output-dir generated_exam/open_evaluation \
  --model google/gemini-3.1-pro-preview

The editable canonical artifact is:

open_evaluations.yaml

It combines the previous per-response JSON, converted Markdown, feedback, score, warnings, and paths into one multiline-friendly file. Edit this YAML to manually adjust scores, feedback, or converted Markdown, then rerun pevaluate exam-open without --force-regrade to reuse the edited artifacts and regenerate reports.

Useful flags:

Option Description
--dry-run Write prompts and pending YAML/CSV rows without calling an LLM.
--keep-prompts Save the grading prompt for each response.
--force-regrade Ignore existing YAML evaluations and call the model again.
--post-analysis Analyze graded responses, summarize typical errors, and suggest a revised rubric in post_analysis.yaml.
--re-evaluate Run a second grading pass in a sibling reevaluation/ folder after post-analysis. First-pass artifacts are kept.
--mc-correction-dir Optional pexams correction directory. Adds corrected MC template PNGs to student PDFs and includes stats_report.html in the global report when present.

Outputs include:

open_scores.csv
open_evaluations.yaml
model_inputs/*.png
open_responses_report.html
open_responses_report.pdf
student_feedback_pdfs/<student_id>.pdf
reevaluation/
  open_scores.csv
  open_evaluations.yaml
  post_analysis.yaml
  open_responses_report.html
  open_responses_report.pdf

The report starts with an overall mark page and distribution. When --mc-correction-dir points at a pexams correction directory with stats_report.html, the multiple-choice report is included before the open-answer section. The open-answer section includes one score-distribution histogram per open question, plus percentile examples at p0, p25, p75, and p100. Each sample shows the highlighted crop passed to the model, rendered Markdown, Markdown source, score, feedback, and conversion warnings. Rendered responses support MathJax formulas and Mermaid diagrams. Per-student PDFs include the corrected multiple-choice template PNG from scanned_pages/ when available, plus unhighlighted open-answer response crops with score and feedback. Reevaluation reports reuse the first-pass model_inputs/*.png highlighted crops instead of copying them.

Run the fake full open-answer smoke pipeline without spending tokens:

pevaluate test-open --output-dir generated/open_answer_eval_smoke

Run the same smoke test with real OpenRouter calls:

pevaluate test-open --real-llm --output-dir generated/open_answer_eval_real

Main Options

Option Description Default
session_folder Folder containing the assignment materials, or a single submission file. required
--model OpenRouter model. google/gemini-3.1-pro-preview
--rubric Rubric file in the session folder. rubric.txt
--example Example feedback file in the session folder. example.txt
--reference Optional reference file(s), separated by ;. empty
--no-reference Do not include a reference solution in the prompt. false
--files-regex Student files to grade. .*\.ipynb$
--prefer-extensions Extension priority for duplicate submission files. .ipynb;.html
--students-dir Directory containing unpacked student submissions. <session_folder>/students
--output-dir Output/session folder for single-file inputs. input file parent
--extract-nested-zips Extract zip files found inside students-dir. false
--no-cleanup-html Keep HTML styles/scripts/images in prompts. false
--include-images Extract supported images and attach them to the LLM request. false
--no-dedupe-images Keep duplicate extracted images instead of deduplicating by content hash. false
--max-images Maximum extracted images attached per LLM request. Use 0 for no limit. 20
--markdown-config JSON object or JSON file path with document-to-Markdown converter options. PDF options are passed to pymupdf4llm.to_markdown. empty
--keep-prompt Save prompts as Markdown to prompts/, with image assets when --include-images is used. false
--no-evaluate Prepare prompts and token estimates without calling the LLM. false
--student Filter submissions by filename text. empty
--no-unzip Skip Moodle zip extraction. false
--no-convert Skip notebook-to-Markdown conversion. false
--no-grade Skip grading entirely, including prompt preparation. false

Notes

  • Prompt size is printed for each submission in characters and approximate tokens.
  • PDF extraction uses PyMuPDF4LLM for Markdown/layout-aware output. Pandoc remains useful for DOCX/HTML/Markdown workflows, but it is not used for PDF extraction because it does not provide comparable PDF layout recovery.
  • HTML sanitization removes <style>, <script>, embedded images, SVGs, comments, and other noisy artifacts.
  • Prompt files are saved in prompts/ when --keep-prompt is used.
  • Feedback files are saved in feedback/ as YAML and can be compiled into a Moodle marks CSV with pevaluate moodle-csv.

Metadata

Release files for pevaluate 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pevaluate 0.1.8
File Size Uploaded Provenance Actions
pevaluate-0.1.8.tar.gz 55.1 kB With provenance Details for pevaluate-0.1.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pevaluate 0.1.8
File Interpreter ABI Platform Actions
pevaluate-0.1.8-py3-none-any.whl Python 3 none any Details for pevaluate-0.1.8-py3-none-any.whl

Total release size: 100.3 kB

Release files / pevaluate-0.1.8.tar.gz

Download URL pevaluate-0.1.8.tar.gz
Size 55.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8f433cc009bc4086d88d782c97807383c64424b74b916ab0b03e788cc6e5497f
BLAKE2b-256 checksum
How to use checksums
5ba299b574c04f40f4e18901dd7a34ce801061848e06f712e27bf1f78a137b11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2026.

Transparency log

Release files / pevaluate-0.1.8-py3-none-any.whl

Download URL pevaluate-0.1.8-py3-none-any.whl
Size 45.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
89bdcdfac22fd95ceccafaf1be0e18628c5be7087349a2890ec00854fca03a18
BLAKE2b-256 checksum
How to use checksums
3542ed14ad5fe3ad867913ae4636935ec56c5d60e791e25a53cb1fe4844e532a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2026.

Transparency log

Security for pevaluate 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pevaluate-0.1.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page