Initial commit for finalisation web interface

This commit is contained in:
sebastien committed 2026-11-01 08:41:37 +01:00
1 parent b295f871a7
commit c36642e8de
33 files changed
+2745 -138

No files matched your search

+11 -2
View File
@@ -1,5 +1,8 @@
from __future__ import annotations
from copy import deepcopy
from copienator import review_snapshot
import argparse
from collections.abc import Sequence
from pathlib import Path
@@ -160,6 +163,7 @@ def apply_actions_and_regenerate(
*,
update_score: bool = False,
label_notes: dict[str, Image.Image] | None = None,
review_metadata: dict | None = None,
) -> ExitCode:
"""Apply annotations and atomically merge the regenerated student files."""
output_dir = workspace.annotation_dir("checks") / f"Copie{student_id}"
@@ -168,15 +172,17 @@ def apply_actions_and_regenerate(
content["result"].get("error") == "empty-answer"
for content in data[student_id].values()
)
if not bnote_path.is_file() and not only_empty:
if review_metadata is None and not bnote_path.is_file() and not only_empty:
print(f" Missing {bnote_path}")
return ExitCode.PARTIAL
bnote_data = read_json(bnote_path) if bnote_path.is_file() else {"images": []}
bnote_data = review_metadata if review_metadata is not None else (read_json(bnote_path) if bnote_path.is_file() else {"images": []})
if not isinstance(bnote_data, dict):
raise TypeError(f"Expected a JSON object in {bnote_path}")
labels_data = data[student_id]
apply_checkbox_actions(labels_data, actions, print)
reviewed_data = deepcopy(labels_data)
captured_notes = {}
apply_custom_remarks(workspace.root, student_id, labels_data)
score_path = output_dir / "score.json"
preserve_score_file = update_score and score_path.is_file()
@@ -217,6 +223,8 @@ def apply_actions_and_regenerate(
hmin = int(image_info.get("hmin", 0))
hmax = int(image_info.get("hmax", 0))
sub_note = notes_layer.crop((0, hmin, notes_layer.width, hmax))
if sub_note is not None:
captured_notes[label] = {"img": sub_note}
has_notes = has_significant_notes(sub_note)
pdf_path = Path(content["pdf_path"])
@@ -288,6 +296,7 @@ def apply_actions_and_regenerate(
workspace.root, [(label, dirty_images[label]) for label in filtered_labels],
all_labels, staging / "Concat_F.pdf", general=general,
)
review_snapshot.stage(output_dir, staging, reviewed_data, captured_notes, engine="standard", bnote=bnote_data)
stage_baseline(workspace.root, "Bnot", output_dir, staging, dirty_images,
header_heights, build_answer_info(scores, labels_data, answer_labels),
filtered_labels, scores)