diff --git a/annotating_with_checks.py b/annotating_with_checks.py
index 6d9a2c9..f56719f 100644
--- a/annotating_with_checks.py
+++ b/annotating_with_checks.py
@@ -198,7 +198,7 @@ def process_student(args):
c.drawImage(temp_img_path, 0, 0, width=w, height=h)
c.save()
- print("Debug : size", w, h)
+ # print("Debug : size", w, h)
# Ancien code, avec du drift
# concat_img.save(os.path.join(output_dir, "Concat.pdf"), "PDF", resolution=DPI)
# concat_img.save(os.path.join(output_dir, "Reference.png"))
@@ -209,12 +209,34 @@ def process_student(args):
if __name__ == "__main__":
if len(sys.argv) < 2:
- print("Usage: python annotating_with_checks.py
")
+ print("Usage: python annotating_with_checks.py or ")
sys.exit(1)
- root_dir = sys.argv[1]
+ input_path = sys.argv[1]
+ target_id = None
+
+ # Detect if input is a specific file
+ if os.path.isfile(input_path):
+ root_dir = os.path.dirname(input_path) or "."
+ # Extract ID from filename (e.g., Copie40.pdf -> 40)
+ match = re.search(r'Copie(\d+)', os.path.basename(input_path))
+ if match:
+ target_id = match.group(1)
+ else:
+ print("Error: Could not extract student ID from filename.")
+ sys.exit(1)
+ else:
+ root_dir = input_path
+
results = annotating.make_dictionary(root_dir)
+ # Filter results if a specific target ID was requested
+ if target_id:
+ if target_id in results:
+ results = {target_id: results[target_id]}
+ else:
+ print(f"Student ID {target_id} not found in directory scan.")
+ results = {}
tasks = [(root_dir, sid, lbls) for sid, lbls in results.items()]
diff --git a/update_ods.py b/update_ods.py
index 866c8a1..63b0b27 100644
--- a/update_ods.py
+++ b/update_ods.py
@@ -2,6 +2,7 @@ import os
import sys
import json
import ezodf
+from pathlib import Path
# Configuration
ODS_PATH = "/home/sebastien/Rust/gestion_classe/Staging/current_eval.ods"
@@ -14,6 +15,7 @@ def main():
else:
work_dir = os.path.abspath(sys.argv[1])
+ all_labels = [l for l in (Path(work_dir) / "labels").read_text().split("\n") if l!=""]
a_rendre_path = os.path.join(work_dir, TARGET_DIR_NAME)
if not os.path.isdir(a_rendre_path):
@@ -95,14 +97,18 @@ def main():
# Start filling from Row 2 (index 2), immediately below the name line
start_row = 2
- for i, key in enumerate(scores_data.keys()):
+ # for i, key in enumerate(scores_data.keys()):
+ for i, key in enumerate(all_labels):
row_idx = start_row + i
# Ensure we don't go out of bounds
if row_idx >= sheet.nrows():
sheet.append_rows(1)
- val_str = str(scores_data[key])
+ if key in scores_data:
+ val_str = str(scores_data[key])
+ else:
+ val_str = ""
# Logic: if "" -> "NT"
new_val = "NT" if val_str == "" else val_str