Remove errors in final copie

master
Sébastien Miquel 2026-02-27 11:52:47 +01:00
parent 04a1ef447e
commit b0d20eb653
2 changed files with 9 additions and 5 deletions

View File

@ -215,7 +215,8 @@ def render_latex_text(text, width_px, bg_color=(255, 255, 255, 255), max_lines=N
return final_img
def render_score_text(label, score, error, width_px, fontsize=18,
bg_color=(255, 255, 255, 255)):
bg_color=(255, 255, 255, 255)
with_error=True):
# 1. Calculate Color Gradient (0.0=DarkRed -> 4.0=Green)
# Clamp score between 0 and 4
t = max(0.0, min(1.0, float(score) / 4.0))
@ -229,7 +230,7 @@ def render_score_text(label, score, error, width_px, fontsize=18,
# We use \color{hex} to color specific parts in Matplotlib
score_str = f"{label} ; Note : \\color{{{hex_color}}}{{{score}}}"
if error and error != "null":
if error and error != "null" and with_error:
# Uses standard Matplotlib color name 'orange'
score_str += f" | \\color{{orange}}{{Error: {error}}}"
@ -268,7 +269,8 @@ def render_score_text(label, score, error, width_px, fontsize=18,
def compose_label_image(base_img, label, result, hmin,
render_fn=render_latex_text,
draw_callback=None):
draw_callback=None,
with_error=True):
"""
Composes the final image with annotations.
@ -295,7 +297,8 @@ def compose_label_image(base_img, label, result, hmin,
# 1. Prepare Headers
header_elements = []
img_score = render_score_text(label, score, error, base_img.width // 2, fontsize=18)
img_score = render_score_text(label, score, error, base_img.width // 2,
fontsize=18, with_error)
header_elements.append({"type": "score", "img": img_score, "data": result})
# Global Feedbacks

View File

@ -249,7 +249,8 @@ def apply_actions_and_regenerate(root_dir, data, student_id, actions, notes_laye
# Compose uses the result object we modified in step 1
final_img, _ = annotating.compose_label_image(
base_img, label, content['result'], content['coordinates'][0]
base_img, label, content['result'], content['coordinates'][0],
with_error=False
)
# Overlay manual notes