Using folders "Copies" and "Par label", hopefully
This commit is contained in:
@@ -85,7 +85,8 @@ def save_paginated_pdf(image_groups, output_path):
|
||||
if pages:
|
||||
pages[0].save(output_path, "PDF", resolution=100.0, save_all=True, append_images=pages[1:])
|
||||
|
||||
def apply_actions_and_regenerate_grouped(root_dir, data, student_id, actions, label_notes, all_labels):
|
||||
def apply_actions_and_regenerate_grouped(root_dir, data, student_id,
|
||||
actions, label_notes, all_labels):
|
||||
"""
|
||||
Modifies data based on actions, pastes label-specific note crops,
|
||||
regenerates label images for consistency, saves dirty ones,
|
||||
@@ -161,7 +162,7 @@ def apply_actions_and_regenerate_grouped(root_dir, data, student_id, actions, la
|
||||
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")
|
||||
pdf_path = Path(root_dir) / "Copies" / f"Copie{student_id}" / f"{label}.pdf"
|
||||
if not os.path.exists(pdf_path): continue
|
||||
|
||||
(base_img, _, _) = annotating.make_base_image(pdf_path)
|
||||
@@ -204,13 +205,15 @@ 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:
|
||||
if float(d_notes[label]) < 4.0:
|
||||
perfect_no_comment = False
|
||||
else:
|
||||
if len(result.get('feedback', [])) != 0:
|
||||
perfect_no_comment = False
|
||||
lfb = result.get('feedback', [])
|
||||
for e in lfb:
|
||||
if "to_delete" not in e or not e["to_delete"]:
|
||||
perfect_no_comment = False
|
||||
|
||||
if not perfect_no_comment:
|
||||
if not perfect_no_comment or has_notes:
|
||||
extras = get_extra_pdfs_as_images(root_dir, label, annotating)
|
||||
extras.append(final_img)
|
||||
concat_list_F.append(extras)
|
||||
@@ -333,7 +336,8 @@ if __name__ == "__main__":
|
||||
if hmax > hmin:
|
||||
crop = notes_img.crop((0, hmin, notes_img.width, hmax))
|
||||
if has_significant_notes(crop):
|
||||
notes_by_student[sid][lbl] = {'img': crop, 'old_header_h': img_info.get("header_height", 0)}
|
||||
notes_by_student[sid][lbl] = {'img': crop,
|
||||
'old_header_h': img_info.get("header_height", 0)}
|
||||
|
||||
|
||||
def process_refaire_entry(sid, r_labels):
|
||||
@@ -364,7 +368,9 @@ if __name__ == "__main__":
|
||||
if hmax > hmin:
|
||||
crop = b_notes_img.crop((0, hmin, b_notes_img.width, hmax))
|
||||
if has_significant_notes(crop):
|
||||
notes_by_student[sid][lbl] = {'img': crop, 'old_header_h': img_info.get("header_height", 0)}
|
||||
notes_by_student[sid][lbl] = \
|
||||
{'img': crop,
|
||||
'old_header_h': img_info.get("header_height", 0)}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user