Move to real LaTeX rendering

This commit is contained in:
2026-03-03 19:25:05 +01:00
parent 6222ba5dac
commit 2677e41b04
4 changed files with 119 additions and 6 deletions
+25 -1
View File
@@ -65,13 +65,15 @@ def apply_actions_and_regenerate_grouped(root_dir, data, student_id, actions, la
# --- 2. Process Images (Regenerate & Concatenate) ---
concat_list = []
concat_list_F = []
d_notes = dict.fromkeys(all_labels, "")
# Iterate over all labels naturally to assemble a complete student profile
sorted_labels = sorted(labels_data.items(), key=lambda x: natural_key(x[0]))
for label, content in sorted_labels:
d_notes[label] = str(content['result'].get('score', 0))
result = content['result']
d_notes[label] = str(result.get('score', 0))
pdf_path = os.path.join(root_dir, f"Copie{student_id}", f"{label}.pdf")
if not os.path.exists(pdf_path): continue
@@ -102,6 +104,16 @@ def apply_actions_and_regenerate_grouped(root_dir, data, student_id, actions, la
concat_list.append(final_img)
perfect_no_comment = True
if float(d_notes[label]) != 4.0:
perfect_no_comment = False
else:
if len(result.get('feedback', [])) != 0:
perfect_no_comment = False
if not perfect_no_comment:
concat_list_F.append(final_img)
# --- 3. Save Final Outputs ---
with open(score_path, "w") as f:
json.dump(d_notes, f, indent=4)
@@ -119,6 +131,18 @@ def apply_actions_and_regenerate_grouped(root_dir, data, student_id, actions, la
full_img.save(os.path.join(output_dir, "Concat.jpg"))
print(f" Saved regenerated Concat.jpg")
if concat_list_F:
max_w = max(i.width for i in concat_list_F)
total_h = sum(i.height for i in concat_list_F)
full_img = Image.new("RGB", (max_w, total_h), "white")
y = 0
for img in concat_list_F:
full_img.paste(img, (0, y))
y += img.height
full_img.save(os.path.join(output_dir, "Concat_F.jpg"))
print(f" Saved regenerated Concat_F.jpg")
if __name__ == "__main__":