pevaluate 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,358 @@
1
+ Metadata-Version: 2.4
2
+ Name: pevaluate
3
+ Version: 0.1.0
4
+ Summary: Automated correction pipeline for JupyterLab sessions using LLMs
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: openai
8
+ Requires-Dist: python-dotenv
9
+ Requires-Dist: tenacity
10
+ Requires-Dist: jupyter
11
+ Requires-Dist: matplotlib
12
+ Requires-Dist: Markdown
13
+ Requires-Dist: nbconvert
14
+ Requires-Dist: playwright
15
+ Requires-Dist: pymdown-extensions
16
+ Requires-Dist: python-docx
17
+ Requires-Dist: pypdf
18
+ Requires-Dist: PyYAML
19
+
20
+ # pevaluate
21
+
22
+ `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.
23
+
24
+ The package installs as `pevaluate`. The older `autocorrect` command is still available as a CLI alias.
25
+
26
+ ## Installation
27
+
28
+ Install the package in editable mode from this repository:
29
+
30
+ ```bash
31
+ pip install -e .
32
+ ```
33
+
34
+ Install the Playwright browser binaries used for HTML-to-PDF export:
35
+
36
+ ```bash
37
+ playwright install chromium
38
+ ```
39
+
40
+ Create a `.env` file with your OpenRouter API key:
41
+
42
+ ```env
43
+ OPENROUTER_API_KEY=your_api_key_here
44
+ ```
45
+
46
+ ## Moodle Setup
47
+
48
+ For Moodle upload/download workflows, enable the feedback tools in the assignment settings:
49
+
50
+ 1. Open the assignment settings.
51
+ 2. Under **Feedback types**, enable **Feedback files** and **Offline grading worksheet**.
52
+
53
+ ![Enable Feedback Comments](media/moodle.png)
54
+
55
+ 3. Download the Moodle submissions zip and, later, download the grading worksheet or marks CSV.
56
+
57
+ 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.
58
+
59
+ If you already unzipped the Moodle download yourself, use `--no-unzip --students-dir path/to/submissions`.
60
+
61
+ ## Session Folder
62
+
63
+ A representative session folder looks like this:
64
+
65
+ ```text
66
+ my_assignment/
67
+ moodle_submissions.zip
68
+ rubric.txt
69
+ example.txt
70
+ marks.csv
71
+ ```
72
+
73
+ `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`.
74
+
75
+ ## Representative Workflow
76
+
77
+ First run a dry pass. This unpacks submissions, extracts nested zips, converts notebooks for inspection, and does not call the LLM:
78
+
79
+ ```bash
80
+ pevaluate "my_assignment" \
81
+ --extract-nested-zips \
82
+ --no-grade \
83
+ --no-reference \
84
+ --files-regex ".*\.(ipynb|html)$" \
85
+ --prefer-extensions ".ipynb;.html"
86
+ ```
87
+
88
+ After checking the generated files, run grading without unpacking/converting again:
89
+
90
+ ```bash
91
+ pevaluate "my_assignment" \
92
+ --no-unzip \
93
+ --no-convert \
94
+ --no-reference \
95
+ --rubric rubric.txt \
96
+ --example example.txt \
97
+ --files-regex ".*\.(ipynb|html)$" \
98
+ --prefer-extensions ".ipynb;.html" \
99
+ --keep-prompt \
100
+ --model "google/gemini-3.1-pro-preview"
101
+ ```
102
+
103
+ For an already unzipped Moodle download:
104
+
105
+ ```bash
106
+ pevaluate "my_assignment" \
107
+ --no-unzip \
108
+ --students-dir "my_assignment/submissions" \
109
+ --extract-nested-zips \
110
+ --no-reference \
111
+ --files-regex ".*\.(ipynb|html)$" \
112
+ --prefer-extensions ".ipynb;.html"
113
+ ```
114
+
115
+ 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:
116
+
117
+ ```bash
118
+ pevaluate "my_assignment" --no-cleanup-html
119
+ ```
120
+
121
+ `--not-cleanup-html` is accepted as an alias.
122
+
123
+ ## Rubric File
124
+
125
+ 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.
126
+
127
+ Example:
128
+
129
+ ```text
130
+ Grade from 0 to 10. Be brief and assertive.
131
+
132
+ Notebook, 70%:
133
+ - 1.5 points: data understanding and validation.
134
+ - 3.0 points: classical model.
135
+ - 3.0 points: modern model.
136
+ - 1.0 point: experimental comparison.
137
+ - 0.5 points: error analysis and conclusions.
138
+ - 0.5 points: clarity and reproducibility.
139
+
140
+ Challenge, 30%:
141
+ Use the challenge table below. Report the team's challenge mark and combine:
142
+ final_mark = 0.70 * notebook_mark + 0.30 * challenge_mark.
143
+
144
+ Groups:
145
+ | Group | Students |
146
+ | --- | --- |
147
+ | G01 | Ana García López; Luis Pérez Soler |
148
+ | G02 | Marta Ferrer Vidal; Pablo Ruiz Mora |
149
+
150
+ Challenge results:
151
+ | Group | Rank | score | challenge_mark |
152
+ | --- | --- | --- | --- |
153
+ | G01 | 1 | 0.812 | 10.0 |
154
+ | G02 | 2 | 0.790 | 8.5 |
155
+ ```
156
+
157
+ ## Example Feedback File
158
+
159
+ The example file should show the tone and level of detail you want. It does not need to match the assignment exactly.
160
+
161
+ ```text
162
+ Grupo G01:
163
+ - Ana García López
164
+ - Luis Pérez Soler
165
+
166
+ Notebook (70%):
167
+ 0. Errores de código: 0.5/0.5.
168
+ 1. Planteamiento, datos y validación: 1.25/1.5. La validación es razonable, pero faltó justificar mejor la partición.
169
+ 2. Modelo clásico: 2.75/3.0. Buen resultado; faltó comparar algún hiperparámetro adicional.
170
+ 3. Modelo moderno: 3.0/3.0.
171
+ 4. Comparación experimental: 0.75/1.0. La tabla de resultados es clara, pero el análisis es algo superficial.
172
+ 5. Análisis de errores y conclusiones: 0.25/0.5.
173
+ 6. Claridad y reproducibilidad: 0.5/0.5.
174
+
175
+ Challenge (30%): posición 2/20. Nota challenge: 8.5/10.
176
+
177
+ Nota notebook: 8.75/10.
178
+ Nota final: 8.30/10.
179
+ ```
180
+
181
+ ## Structured Feedback YAML
182
+
183
+ 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.
184
+
185
+ ```yaml
186
+ students:
187
+ - full_name: Ana García López
188
+ - full_name: Luis Pérez Soler
189
+ feedback: |
190
+ Grupo G01:
191
+ - Ana García López
192
+ - Luis Pérez Soler
193
+
194
+ Notebook (70%): 8.75/10.
195
+ Challenge (30%): 8.5/10.
196
+
197
+ Buen trabajo. La validación es razonable y los resultados son sólidos; faltó un análisis de errores más concreto.
198
+
199
+ Nota final: 8.30/10.
200
+ mark: 8.3
201
+ submission_file: C:\path\to\submission.ipynb
202
+ source_id: 1a2b3c4d
203
+ ```
204
+
205
+ 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.
206
+
207
+ ## Moodle CSV Export
208
+
209
+ Compile YAML feedback into a Moodle upload CSV:
210
+
211
+ ```bash
212
+ pevaluate moodle-csv "my_assignment/marks.csv" \
213
+ --feedback-dir "my_assignment/feedback" \
214
+ --output "my_assignment/marks_filled.csv" \
215
+ --feedback-format html \
216
+ --partial \
217
+ --clear-timestamps
218
+ ```
219
+
220
+ 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`.
221
+
222
+ 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`.
223
+
224
+ `--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.
225
+
226
+ `--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.
227
+
228
+ For a second pass after downloading the current Moodle worksheet, fill only rows still missing a grade or feedback:
229
+
230
+ ```bash
231
+ pevaluate moodle-csv current_moodle_marks.csv \
232
+ --feedback-dir feedback \
233
+ --output marks_filled_missing_only.csv \
234
+ --feedback-format html \
235
+ --partial \
236
+ --skip-filled \
237
+ --clear-timestamps
238
+ ```
239
+
240
+ If exact matching fails, it uses fuzzy matching with a normalized Levenshtein threshold of `70/100` by default and reports each fuzzy match:
241
+
242
+ ```bash
243
+ pevaluate moodle-csv marks.csv \
244
+ --feedback-dir feedback \
245
+ --output marks_filled.csv \
246
+ --fuzzy-threshold 70
247
+ ```
248
+
249
+ Use `--fuzzy-threshold 0` to disable fuzzy matching. If your Moodle CSV uses different column names, pass them explicitly:
250
+
251
+ ```bash
252
+ pevaluate moodle-csv marks.csv \
253
+ --feedback-dir feedback \
254
+ --output marks_filled.csv \
255
+ --name-column "Full name" \
256
+ --grade-column "Grade" \
257
+ --feedback-column "Feedback comments"
258
+ ```
259
+
260
+ Upload the generated CSV back to Moodle using the assignment grading import/upload option.
261
+
262
+ ## Open-Answer Exam Evaluation
263
+
264
+ `pevaluate exam-open` grades the open-answer crops extracted by `pexams correct`. It expects:
265
+
266
+ - `open_responses_index.csv` from the `pexams` correction output.
267
+ - The original `pexams` exam directory containing `exam_model_*_questions.json`.
268
+ - The crop images referenced from the index CSV.
269
+
270
+ Basic run:
271
+
272
+ ```bash
273
+ pevaluate exam-open \
274
+ --index-csv generated_exam/correction_results/open_responses_index.csv \
275
+ --exam-dir generated_exam \
276
+ --output-dir generated_exam/open_evaluation \
277
+ --model google/gemini-3.1-pro-preview
278
+ ```
279
+
280
+ The editable canonical artifact is:
281
+
282
+ ```text
283
+ open_evaluations.yaml
284
+ ```
285
+
286
+ 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.
287
+
288
+ Useful flags:
289
+
290
+ | Option | Description |
291
+ | :--- | :--- |
292
+ | `--dry-run` | Write prompts and pending YAML/CSV rows without calling an LLM. |
293
+ | `--keep-prompts` | Save the grading prompt for each response. |
294
+ | `--force-regrade` | Ignore existing YAML evaluations and call the model again. |
295
+ | `--post-analysis` | Analyze graded responses, summarize typical errors, and suggest a revised rubric in `post_analysis.yaml`. |
296
+ | `--re-evaluate` | Run a second grading pass in a sibling `reevaluation/` folder after post-analysis. First-pass artifacts are kept. |
297
+ | `--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. |
298
+
299
+ Outputs include:
300
+
301
+ ```text
302
+ open_scores.csv
303
+ open_evaluations.yaml
304
+ model_inputs/*.png
305
+ open_responses_report.html
306
+ open_responses_report.pdf
307
+ student_feedback_pdfs/<student_id>.pdf
308
+ reevaluation/
309
+ open_scores.csv
310
+ open_evaluations.yaml
311
+ post_analysis.yaml
312
+ open_responses_report.html
313
+ open_responses_report.pdf
314
+ ```
315
+
316
+ 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.
317
+ 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.
318
+ Reevaluation reports reuse the first-pass `model_inputs/*.png` highlighted crops instead of copying them.
319
+
320
+ Run the fake full open-answer smoke pipeline without spending tokens:
321
+
322
+ ```bash
323
+ pevaluate test-open --output-dir generated/open_answer_eval_smoke
324
+ ```
325
+
326
+ Run the same smoke test with real OpenRouter calls:
327
+
328
+ ```bash
329
+ pevaluate test-open --real-llm --output-dir generated/open_answer_eval_real
330
+ ```
331
+
332
+ ## Main Options
333
+
334
+ | Option | Description | Default |
335
+ | :--- | :--- | :--- |
336
+ | `session_folder` | Folder containing the assignment materials. | required |
337
+ | `--model` | OpenRouter model. | `google/gemini-3.1-pro-preview` |
338
+ | `--rubric` | Rubric file in the session folder. | `rubric.txt` |
339
+ | `--example` | Example feedback file in the session folder. | `example.txt` |
340
+ | `--reference` | Optional reference file(s), separated by `;`. | empty |
341
+ | `--no-reference` | Do not include a reference solution in the prompt. | false |
342
+ | `--files-regex` | Student files to grade. | `.*\.ipynb$` |
343
+ | `--prefer-extensions` | Extension priority for duplicate submission files. | `.ipynb;.html` |
344
+ | `--students-dir` | Directory containing unpacked student submissions. | `<session_folder>/students` |
345
+ | `--extract-nested-zips` | Extract zip files found inside `students-dir`. | false |
346
+ | `--no-cleanup-html` | Keep HTML styles/scripts/images in prompts. | false |
347
+ | `--keep-prompt` | Save prompts to `prompts/`. | false |
348
+ | `--student` | Filter submissions by filename text. | empty |
349
+ | `--no-unzip` | Skip Moodle zip extraction. | false |
350
+ | `--no-convert` | Skip notebook-to-Markdown conversion. | false |
351
+ | `--no-grade` | Skip LLM grading. | false |
352
+
353
+ ## Notes
354
+
355
+ - Prompt size is printed for each submission in characters and approximate tokens.
356
+ - HTML sanitization removes `<style>`, `<script>`, embedded images, SVGs, comments, and other noisy artifacts.
357
+ - Prompt files are saved in `prompts/` when `--keep-prompt` is used.
358
+ - Feedback files are saved in `feedback/` as YAML and can be compiled into a Moodle marks CSV with `pevaluate moodle-csv`.
@@ -0,0 +1,339 @@
1
+ # pevaluate
2
+
3
+ `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.
4
+
5
+ The package installs as `pevaluate`. The older `autocorrect` command is still available as a CLI alias.
6
+
7
+ ## Installation
8
+
9
+ Install the package in editable mode from this repository:
10
+
11
+ ```bash
12
+ pip install -e .
13
+ ```
14
+
15
+ Install the Playwright browser binaries used for HTML-to-PDF export:
16
+
17
+ ```bash
18
+ playwright install chromium
19
+ ```
20
+
21
+ Create a `.env` file with your OpenRouter API key:
22
+
23
+ ```env
24
+ OPENROUTER_API_KEY=your_api_key_here
25
+ ```
26
+
27
+ ## Moodle Setup
28
+
29
+ For Moodle upload/download workflows, enable the feedback tools in the assignment settings:
30
+
31
+ 1. Open the assignment settings.
32
+ 2. Under **Feedback types**, enable **Feedback files** and **Offline grading worksheet**.
33
+
34
+ ![Enable Feedback Comments](media/moodle.png)
35
+
36
+ 3. Download the Moodle submissions zip and, later, download the grading worksheet or marks CSV.
37
+
38
+ 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.
39
+
40
+ If you already unzipped the Moodle download yourself, use `--no-unzip --students-dir path/to/submissions`.
41
+
42
+ ## Session Folder
43
+
44
+ A representative session folder looks like this:
45
+
46
+ ```text
47
+ my_assignment/
48
+ moodle_submissions.zip
49
+ rubric.txt
50
+ example.txt
51
+ marks.csv
52
+ ```
53
+
54
+ `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`.
55
+
56
+ ## Representative Workflow
57
+
58
+ First run a dry pass. This unpacks submissions, extracts nested zips, converts notebooks for inspection, and does not call the LLM:
59
+
60
+ ```bash
61
+ pevaluate "my_assignment" \
62
+ --extract-nested-zips \
63
+ --no-grade \
64
+ --no-reference \
65
+ --files-regex ".*\.(ipynb|html)$" \
66
+ --prefer-extensions ".ipynb;.html"
67
+ ```
68
+
69
+ After checking the generated files, run grading without unpacking/converting again:
70
+
71
+ ```bash
72
+ pevaluate "my_assignment" \
73
+ --no-unzip \
74
+ --no-convert \
75
+ --no-reference \
76
+ --rubric rubric.txt \
77
+ --example example.txt \
78
+ --files-regex ".*\.(ipynb|html)$" \
79
+ --prefer-extensions ".ipynb;.html" \
80
+ --keep-prompt \
81
+ --model "google/gemini-3.1-pro-preview"
82
+ ```
83
+
84
+ For an already unzipped Moodle download:
85
+
86
+ ```bash
87
+ pevaluate "my_assignment" \
88
+ --no-unzip \
89
+ --students-dir "my_assignment/submissions" \
90
+ --extract-nested-zips \
91
+ --no-reference \
92
+ --files-regex ".*\.(ipynb|html)$" \
93
+ --prefer-extensions ".ipynb;.html"
94
+ ```
95
+
96
+ 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:
97
+
98
+ ```bash
99
+ pevaluate "my_assignment" --no-cleanup-html
100
+ ```
101
+
102
+ `--not-cleanup-html` is accepted as an alias.
103
+
104
+ ## Rubric File
105
+
106
+ 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.
107
+
108
+ Example:
109
+
110
+ ```text
111
+ Grade from 0 to 10. Be brief and assertive.
112
+
113
+ Notebook, 70%:
114
+ - 1.5 points: data understanding and validation.
115
+ - 3.0 points: classical model.
116
+ - 3.0 points: modern model.
117
+ - 1.0 point: experimental comparison.
118
+ - 0.5 points: error analysis and conclusions.
119
+ - 0.5 points: clarity and reproducibility.
120
+
121
+ Challenge, 30%:
122
+ Use the challenge table below. Report the team's challenge mark and combine:
123
+ final_mark = 0.70 * notebook_mark + 0.30 * challenge_mark.
124
+
125
+ Groups:
126
+ | Group | Students |
127
+ | --- | --- |
128
+ | G01 | Ana García López; Luis Pérez Soler |
129
+ | G02 | Marta Ferrer Vidal; Pablo Ruiz Mora |
130
+
131
+ Challenge results:
132
+ | Group | Rank | score | challenge_mark |
133
+ | --- | --- | --- | --- |
134
+ | G01 | 1 | 0.812 | 10.0 |
135
+ | G02 | 2 | 0.790 | 8.5 |
136
+ ```
137
+
138
+ ## Example Feedback File
139
+
140
+ The example file should show the tone and level of detail you want. It does not need to match the assignment exactly.
141
+
142
+ ```text
143
+ Grupo G01:
144
+ - Ana García López
145
+ - Luis Pérez Soler
146
+
147
+ Notebook (70%):
148
+ 0. Errores de código: 0.5/0.5.
149
+ 1. Planteamiento, datos y validación: 1.25/1.5. La validación es razonable, pero faltó justificar mejor la partición.
150
+ 2. Modelo clásico: 2.75/3.0. Buen resultado; faltó comparar algún hiperparámetro adicional.
151
+ 3. Modelo moderno: 3.0/3.0.
152
+ 4. Comparación experimental: 0.75/1.0. La tabla de resultados es clara, pero el análisis es algo superficial.
153
+ 5. Análisis de errores y conclusiones: 0.25/0.5.
154
+ 6. Claridad y reproducibilidad: 0.5/0.5.
155
+
156
+ Challenge (30%): posición 2/20. Nota challenge: 8.5/10.
157
+
158
+ Nota notebook: 8.75/10.
159
+ Nota final: 8.30/10.
160
+ ```
161
+
162
+ ## Structured Feedback YAML
163
+
164
+ 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.
165
+
166
+ ```yaml
167
+ students:
168
+ - full_name: Ana García López
169
+ - full_name: Luis Pérez Soler
170
+ feedback: |
171
+ Grupo G01:
172
+ - Ana García López
173
+ - Luis Pérez Soler
174
+
175
+ Notebook (70%): 8.75/10.
176
+ Challenge (30%): 8.5/10.
177
+
178
+ Buen trabajo. La validación es razonable y los resultados son sólidos; faltó un análisis de errores más concreto.
179
+
180
+ Nota final: 8.30/10.
181
+ mark: 8.3
182
+ submission_file: C:\path\to\submission.ipynb
183
+ source_id: 1a2b3c4d
184
+ ```
185
+
186
+ 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.
187
+
188
+ ## Moodle CSV Export
189
+
190
+ Compile YAML feedback into a Moodle upload CSV:
191
+
192
+ ```bash
193
+ pevaluate moodle-csv "my_assignment/marks.csv" \
194
+ --feedback-dir "my_assignment/feedback" \
195
+ --output "my_assignment/marks_filled.csv" \
196
+ --feedback-format html \
197
+ --partial \
198
+ --clear-timestamps
199
+ ```
200
+
201
+ 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`.
202
+
203
+ 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`.
204
+
205
+ `--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.
206
+
207
+ `--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.
208
+
209
+ For a second pass after downloading the current Moodle worksheet, fill only rows still missing a grade or feedback:
210
+
211
+ ```bash
212
+ pevaluate moodle-csv current_moodle_marks.csv \
213
+ --feedback-dir feedback \
214
+ --output marks_filled_missing_only.csv \
215
+ --feedback-format html \
216
+ --partial \
217
+ --skip-filled \
218
+ --clear-timestamps
219
+ ```
220
+
221
+ If exact matching fails, it uses fuzzy matching with a normalized Levenshtein threshold of `70/100` by default and reports each fuzzy match:
222
+
223
+ ```bash
224
+ pevaluate moodle-csv marks.csv \
225
+ --feedback-dir feedback \
226
+ --output marks_filled.csv \
227
+ --fuzzy-threshold 70
228
+ ```
229
+
230
+ Use `--fuzzy-threshold 0` to disable fuzzy matching. If your Moodle CSV uses different column names, pass them explicitly:
231
+
232
+ ```bash
233
+ pevaluate moodle-csv marks.csv \
234
+ --feedback-dir feedback \
235
+ --output marks_filled.csv \
236
+ --name-column "Full name" \
237
+ --grade-column "Grade" \
238
+ --feedback-column "Feedback comments"
239
+ ```
240
+
241
+ Upload the generated CSV back to Moodle using the assignment grading import/upload option.
242
+
243
+ ## Open-Answer Exam Evaluation
244
+
245
+ `pevaluate exam-open` grades the open-answer crops extracted by `pexams correct`. It expects:
246
+
247
+ - `open_responses_index.csv` from the `pexams` correction output.
248
+ - The original `pexams` exam directory containing `exam_model_*_questions.json`.
249
+ - The crop images referenced from the index CSV.
250
+
251
+ Basic run:
252
+
253
+ ```bash
254
+ pevaluate exam-open \
255
+ --index-csv generated_exam/correction_results/open_responses_index.csv \
256
+ --exam-dir generated_exam \
257
+ --output-dir generated_exam/open_evaluation \
258
+ --model google/gemini-3.1-pro-preview
259
+ ```
260
+
261
+ The editable canonical artifact is:
262
+
263
+ ```text
264
+ open_evaluations.yaml
265
+ ```
266
+
267
+ 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.
268
+
269
+ Useful flags:
270
+
271
+ | Option | Description |
272
+ | :--- | :--- |
273
+ | `--dry-run` | Write prompts and pending YAML/CSV rows without calling an LLM. |
274
+ | `--keep-prompts` | Save the grading prompt for each response. |
275
+ | `--force-regrade` | Ignore existing YAML evaluations and call the model again. |
276
+ | `--post-analysis` | Analyze graded responses, summarize typical errors, and suggest a revised rubric in `post_analysis.yaml`. |
277
+ | `--re-evaluate` | Run a second grading pass in a sibling `reevaluation/` folder after post-analysis. First-pass artifacts are kept. |
278
+ | `--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. |
279
+
280
+ Outputs include:
281
+
282
+ ```text
283
+ open_scores.csv
284
+ open_evaluations.yaml
285
+ model_inputs/*.png
286
+ open_responses_report.html
287
+ open_responses_report.pdf
288
+ student_feedback_pdfs/<student_id>.pdf
289
+ reevaluation/
290
+ open_scores.csv
291
+ open_evaluations.yaml
292
+ post_analysis.yaml
293
+ open_responses_report.html
294
+ open_responses_report.pdf
295
+ ```
296
+
297
+ 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.
298
+ 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.
299
+ Reevaluation reports reuse the first-pass `model_inputs/*.png` highlighted crops instead of copying them.
300
+
301
+ Run the fake full open-answer smoke pipeline without spending tokens:
302
+
303
+ ```bash
304
+ pevaluate test-open --output-dir generated/open_answer_eval_smoke
305
+ ```
306
+
307
+ Run the same smoke test with real OpenRouter calls:
308
+
309
+ ```bash
310
+ pevaluate test-open --real-llm --output-dir generated/open_answer_eval_real
311
+ ```
312
+
313
+ ## Main Options
314
+
315
+ | Option | Description | Default |
316
+ | :--- | :--- | :--- |
317
+ | `session_folder` | Folder containing the assignment materials. | required |
318
+ | `--model` | OpenRouter model. | `google/gemini-3.1-pro-preview` |
319
+ | `--rubric` | Rubric file in the session folder. | `rubric.txt` |
320
+ | `--example` | Example feedback file in the session folder. | `example.txt` |
321
+ | `--reference` | Optional reference file(s), separated by `;`. | empty |
322
+ | `--no-reference` | Do not include a reference solution in the prompt. | false |
323
+ | `--files-regex` | Student files to grade. | `.*\.ipynb$` |
324
+ | `--prefer-extensions` | Extension priority for duplicate submission files. | `.ipynb;.html` |
325
+ | `--students-dir` | Directory containing unpacked student submissions. | `<session_folder>/students` |
326
+ | `--extract-nested-zips` | Extract zip files found inside `students-dir`. | false |
327
+ | `--no-cleanup-html` | Keep HTML styles/scripts/images in prompts. | false |
328
+ | `--keep-prompt` | Save prompts to `prompts/`. | false |
329
+ | `--student` | Filter submissions by filename text. | empty |
330
+ | `--no-unzip` | Skip Moodle zip extraction. | false |
331
+ | `--no-convert` | Skip notebook-to-Markdown conversion. | false |
332
+ | `--no-grade` | Skip LLM grading. | false |
333
+
334
+ ## Notes
335
+
336
+ - Prompt size is printed for each submission in characters and approximate tokens.
337
+ - HTML sanitization removes `<style>`, `<script>`, embedded images, SVGs, comments, and other noisy artifacts.
338
+ - Prompt files are saved in `prompts/` when `--keep-prompt` is used.
339
+ - Feedback files are saved in `feedback/` as YAML and can be compiled into a Moodle marks CSV with `pevaluate moodle-csv`.