Initial support for user general remarks

This commit is contained in:
sebastien committed 2026-10-28 13:51:59 +01:00
1 parent a38c1ff4b3
commit 2c9dc65640
16 files changed
+606 -20

No files matched your search

+10 -2
View File
@@ -26,6 +26,7 @@ from copienator.annotation_documents import copy_documents
from copienator.annotation_layout import legacy_layout
from copienator.annotation_read_cache import AnnotationReadCache
from copienator.custom_remarks import apply_custom_remarks
from copienator import general_remarks
from copienator.annotation_modifications import (
BASELINE,
output_removals,
@@ -260,9 +261,16 @@ def apply_actions_and_regenerate(
if incomplete:
return ExitCode.PARTIAL
general = general_remarks.render(workspace.root, student_id,
max((im.width for im in dirty_images.values()), default=800))
if general is not None:
concatenated.insert(0, general)
filtered.insert(0, general)
concat_image = concatenate(concatenated)
filtered_image = concatenate(filtered)
with staged_files(output_dir, remove=(*output_removals(output_dir), BASELINE)) as staging:
if general is not None:
general.save(staging / general_remarks.IMAGE_FILENAME)
for label, image in dirty_images.items():
image.save(staging / f"{label}.jpg")
if not preserve_score_file:
@@ -277,8 +285,8 @@ def apply_actions_and_regenerate(
# Imported here because the grouped reader also uses this module.
from copienator.commands.reading_grouped_annotations import save_checked_pdf
save_checked_pdf(
workspace.root, list(zip(filtered_labels, filtered, strict=True)),
all_labels, staging / "Concat_F.pdf",
workspace.root, [(label, dirty_images[label]) for label in filtered_labels],
all_labels, staging / "Concat_F.pdf", general=general,
)
stage_baseline(workspace.root, "Bnot", output_dir, staging, dirty_images,
header_heights, build_answer_info(scores, labels_data, answer_labels),
@@ -29,6 +29,7 @@ from copienator.annotation_documents import copy_documents, tablet_documents
from copienator.annotation_layout import legacy_layout
from copienator.annotation_read_cache import AnnotationReadCache
from copienator.custom_remarks import apply_custom_remarks
from copienator import general_remarks
from copienator.annotation_modifications import (
BASELINE,
baseline,
@@ -150,9 +151,9 @@ def save_paginated_pdf(
)
def save_checked_pdf(root, labelled_images, all_labels, output_path):
def save_checked_pdf(root, labelled_images, all_labels, output_path, *, general=None):
"""Build the checked-mode return PDF with the same supplements as BGnot."""
groups = []
groups = [[general]] if general is not None else []
seen_contexts = set()
for label, image in labelled_images:
extras = get_extra_pdfs_as_images(
@@ -410,10 +411,17 @@ def apply_actions_and_regenerate_grouped(
filtered_groups.append([*extras, final_image])
touched[label] = annotation_dir == "BGnot"
general = general_remarks.render(workspace.root, student_id,
max((im.width for im in dirty_images.values()), default=800))
if general is not None:
concat_images.insert(0, general)
filtered_groups.insert(0, [general])
concat_image = concatenate(concat_images)
if incomplete:
return ExitCode.PARTIAL, "\n".join(logs)
with staged_files(output_dir, remove=(*output_removals(output_dir), BASELINE)) as staging:
if general is not None:
general.save(staging / general_remarks.IMAGE_FILENAME)
if simple_layout is not None:
simple_layout["replaced"] = sorted(
set(simple_layout["replaced"]) | selected_labels
@@ -440,7 +448,7 @@ def apply_actions_and_regenerate_grouped(
save_checked_pdf(
workspace.root,
[(label, dirty_images[label]) for label in filtered_labels],
all_labels, staging / "Concat_F.pdf",
all_labels, staging / "Concat_F.pdf", general=general,
)
stage_baseline(workspace.root, annotation_dir, output_dir, staging, dirty_images,
header_heights, build_answer_info(scores, labels_data, answer_labels, touched),