diff --git a/app/report.py b/app/report.py index 2f99288..59b4839 100644 --- a/app/report.py +++ b/app/report.py @@ -44,16 +44,32 @@ def get_score_color(score: float) -> str: def get_rating_symbol(rating: int) -> str: - """Convert numeric rating to symbol.""" - if rating >= 2: + """Convert numeric rating to symbol — gleiche Logik wie in models.py + und v2/components/matrix_mini.html. Skala -5..+5.""" + if rating >= 4: return "++" - if rating == 1: + if rating >= 1: return "+" if rating == 0: return "○" - if rating == -1: - return "−" - return "−−" + if rating <= -4: + return "−−" + return "−" + + +def get_rating_class(rating: int) -> str: + """5-Klassen-Coloring analog zu v2 matrix_mini (m-pp/m-p/m-0/m-n/m-nn) + — vorher hatte das PDF nur 3 Klassen (positive/negative/neutral), + was zu 'gleichfarbig' für + und ++ führte.""" + if rating >= 4: + return "rating-pp" + if rating >= 1: + return "rating-p" + if rating == 0: + return "rating-0" + if rating <= -4: + return "rating-nn" + return "rating-n" def format_redline_html(text: str) -> str: @@ -102,13 +118,13 @@ def build_matrix_html(assessment: Assessment) -> str: entry = rating_map.get(field) if entry: symbol = get_rating_symbol(entry.rating) - css_class = "positive" if entry.rating > 0 else ("negative" if entry.rating < 0 else "neutral") + css_class = get_rating_class(entry.rating) # entry.aspect comes from the LLM and is interpolated into a # title="..." attribute — escape it so a stray double-quote # cannot break out and inject attributes/handlers. html.append(f'{symbol}') else: - html.append('') + html.append('') html.append('') html.append('') @@ -279,21 +295,35 @@ async def generate_html_report( font-size: 8pt; }} - .matrix-table .positive {{ + /* 5-Klassen-Coloring analog zu v2 matrix_mini (#177): ++ und + + müssen visuell deutlich unterscheidbar sein. */ + .matrix-table .rating-pp {{ background: var(--color-green); color: white; font-weight: bold; }} - - .matrix-table .negative {{ + .matrix-table .rating-p {{ + background: #cddaa1; /* heller Grün-Tint */ + color: var(--color-darkgray); + }} + .matrix-table .rating-0 {{ + background: #f6f6f6; + color: #888; + }} + .matrix-table .rating-n {{ + background: #efc9c3; /* heller Rot-Tint */ + color: var(--color-darkgray); + }} + .matrix-table .rating-nn {{ background: var(--color-red); color: white; font-weight: bold; }} - - .matrix-table .neutral {{ - background: #f0f0f0; - }} + /* Backwards-Compat fuer evtl. zwischengespeicherte HTML mit + alten Klassennamen — gleiche Optik wie rating-pp/-nn/-0. */ + .matrix-table .positive {{ background: var(--color-green); color: white; font-weight: bold; }} + .matrix-table .negative {{ background: var(--color-red); color: white; font-weight: bold; }} + .matrix-table .neutral {{ background: #f0f0f0; }} .verbesserung {{ margin: 0.5rem 0;