Bnot fixes ; Missing énoncés fixes.
This commit is contained in:
1 parent
f39868207d
commit
55d5cf16c9
18 files changed
+486
-44
No files matched your search
@@ -59,16 +59,20 @@ def copy_return_artifacts(source_dir: Path, destination_dir: Path) -> None:
|
||||
shutil.copytree(answers_source, answers_destination)
|
||||
|
||||
|
||||
def copy_histogram(output_dir: Path) -> None:
|
||||
def copy_histogram(output_dir: Path, *, copy_merged_histogramme: bool = False) -> None:
|
||||
"""Copy the score histogram beside the per-student output folders."""
|
||||
if not HISTOGRAM_PATH.is_file():
|
||||
print(f"Warning: Missing histogram '{HISTOGRAM_PATH}'.")
|
||||
return
|
||||
destination = output_dir / "histogramme.pdf"
|
||||
shutil.copy2(HISTOGRAM_PATH, destination)
|
||||
print(f"Copied histogram: {destination}")
|
||||
sources = [(HISTOGRAM_PATH, "histogramme.pdf")]
|
||||
if copy_merged_histogramme:
|
||||
sources.append((HISTOGRAM_PATH.with_name("merged_histogramme.pdf"), "merged_histogramme.pdf"))
|
||||
for source, filename in sources:
|
||||
if not source.is_file():
|
||||
print(f"Warning: Missing histogram '{source}'.")
|
||||
continue
|
||||
destination = output_dir / filename
|
||||
shutil.copy2(source, destination)
|
||||
print(f"Copied histogram: {destination}")
|
||||
|
||||
def process_images(base_dir, output_dir):
|
||||
def process_images(base_dir, output_dir, *, copy_merged_histogramme=False):
|
||||
# 1. Load Data
|
||||
try:
|
||||
# header=None assumes the file starts directly with data.
|
||||
@@ -148,18 +152,20 @@ def process_images(base_dir, output_dir):
|
||||
for pdf_path in pdf_paths:
|
||||
shutil.copy2(pdf_path, student_output / pdf_path.name)
|
||||
|
||||
copy_histogram(output_dir)
|
||||
copy_histogram(output_dir, copy_merged_histogramme=copy_merged_histogramme)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
parser = argparse.ArgumentParser(description="Stamp scores on exam copies.")
|
||||
parser.add_argument("dir", type=Path, help="Root directory containing 'A Rendre' folder")
|
||||
parser.add_argument("--copy-merged-histogramme", action="store_true",
|
||||
help="Also copy merged_histogramme.pdf from the histogram staging directory")
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
base_dir = args.dir.expanduser().resolve()
|
||||
output_dir = OUTPUT_DIR / base_dir.name
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
process_images(base_dir, output_dir)
|
||||
process_images(base_dir, output_dir, copy_merged_histogramme=args.copy_merged_histogramme)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user