Initial support for _old and _new
This commit is contained in:
+23
-22
@@ -34,6 +34,9 @@ def make_dictionary(root_dir, refaire=False, refaire_list=[]):
|
||||
student_id = item['id']
|
||||
result_obj = item['result']
|
||||
|
||||
if result_obj.get("suffix") == "_old":
|
||||
continue
|
||||
|
||||
# Find coordinates
|
||||
coordinates = None
|
||||
height,width= None, None
|
||||
@@ -58,9 +61,11 @@ def make_dictionary(root_dir, refaire=False, refaire_list=[]):
|
||||
if coordinates:
|
||||
break
|
||||
|
||||
# Construct PDF path: Dir/Copie{id}/{label}.pdf
|
||||
pdf_path = Path(root_dir) / "Copies" / f"Copie{student_id}" / f"{label}.pdf"
|
||||
|
||||
suffix = result_obj.get("suffix", "")
|
||||
if suffix == "_new":
|
||||
pdf_path = Path(root_dir) / "Copies" / f"Copie{student_id}" / f"{label}_new.pdf"
|
||||
else:
|
||||
pdf_path = Path(root_dir) / "Copies" / f"Copie{student_id}" / f"{label}.pdf"
|
||||
# Initialize dictionary structure for this ID if missing
|
||||
if student_id not in result_data:
|
||||
result_data[student_id] = {}
|
||||
@@ -91,8 +96,12 @@ def make_dictionary(root_dir, refaire=False, refaire_list=[]):
|
||||
for lbl in labels_to_redo:
|
||||
pdf_path = Path(root_dir) / "Copies" / f"Copie{sid}" / f"{lbl}.pdf"
|
||||
if not Path(pdf_path).exists():
|
||||
print("Debug : asked to refaire", sid, lbl, "but pdf absent")
|
||||
continue
|
||||
pdf_path_new = Path(root_dir) / "Copies" / f"Copie{sid}" / f"{lbl}_new.pdf"
|
||||
if pdf_path_new.exists():
|
||||
pdf_path = pdf_path_new
|
||||
else:
|
||||
print("Debug : asked to refaire", sid, lbl, "but pdf absent")
|
||||
continue
|
||||
result_data[sid][lbl] = {
|
||||
"pdf_path": pdf_path,
|
||||
"result": {
|
||||
@@ -108,8 +117,12 @@ def make_dictionary(root_dir, refaire=False, refaire_list=[]):
|
||||
for lbl in labels_to_redo:
|
||||
pdf_path = Path(root_dir) / "Copies" / f"Copie{sid}" / f"{lbl}.pdf"
|
||||
if not pdf_path.exists():
|
||||
print("Debug : asked to refaire", sid, lbl, "but pdf absent")
|
||||
continue
|
||||
pdf_path_new = Path(root_dir) / "Copies" / f"Copie{sid}" / f"{lbl}_new.pdf"
|
||||
if pdf_path_new.exists():
|
||||
pdf_path = pdf_path_new
|
||||
else:
|
||||
print("Debug : asked to refaire", sid, lbl, "but pdf absent")
|
||||
continue
|
||||
result_data[sid][lbl] = {
|
||||
"pdf_path": pdf_path,
|
||||
"result": {
|
||||
@@ -278,7 +291,7 @@ def render_real_latex_text(text, width_px, bg_color=(255, 255, 255, 255), max_li
|
||||
\\usepackage[T1]{{fontenc}}
|
||||
\\usepackage{{lmodern}} % Enables arbitrary font scaling
|
||||
\\usepackage{{amsmath, amssymb}}
|
||||
\\usepackage{{mathabx}} % larger inline operators.
|
||||
\\usepackage{{mathabx}} % larger inline operators.
|
||||
\\usepackage{{commands}}
|
||||
%\\usepackage{{anyfontsize}} % replaced by lmodern
|
||||
\\begin{{document}}
|
||||
@@ -572,9 +585,9 @@ def process_student(student_id, labels_data, root_dir, all_labels, overwrite):
|
||||
for label, content in sorted_labels:
|
||||
# 1. Find PDF path
|
||||
copie_folder = f"Copie{student_id}"
|
||||
pdf_full_path = Path(root_dir) / "Copies" / copie_folder / f"{label}.pdf"
|
||||
pdf_full_path = content.get('pdf_path')
|
||||
|
||||
if not os.path.exists(pdf_full_path):
|
||||
if not pdf_full_path or not os.path.exists(pdf_full_path):
|
||||
print(f"File not found: {pdf_full_path}")
|
||||
continue
|
||||
|
||||
@@ -616,18 +629,6 @@ def process_student(student_id, labels_data, root_dir, all_labels, overwrite):
|
||||
|
||||
|
||||
def process_correction(root_dir, data, all_labels, overwrite=False):
|
||||
|
||||
# with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
|
||||
# # Create a list of futures
|
||||
# futures = []
|
||||
# for student_id, labels in sorted(data.items()):
|
||||
# futures.append(
|
||||
# executor.submit(process_student, student_id, labels, root_dir, all_labels, overwrite)
|
||||
# )
|
||||
|
||||
# # Wait for all threads to complete
|
||||
# concurrent.futures.wait(futures)
|
||||
|
||||
# Ne pas thread cette application
|
||||
# 1. Il faut protéger les appels à matplotlib
|
||||
# 2. tu vas perdre les erreurs
|
||||
|
||||
Reference in New Issue
Block a user