- get_rating_symbol nutzt jetzt -5..+5-Skala (vorher: rating>=2 → ++, was bei rating=2 oder 3 falsche '++' gab; jetzt: rating>=4 → ++). - PDF-Tabelle nutzt 5 Klassen (rating-pp/-p/-0/-n/-nn) statt 3 (positive/negative/neutral). Heller Grün/Rot-Tint für mid-strength ratings, kräftiges Grün/Rot für Extreme. Visuell deutlich unterscheidbar. - Beibehaltung der alten Klassennamen für Backwards-Compat falls irgendwo zwischengespeicherte HTML-Reports liegen. Damit ist die v2/PDF-Konsistenz fuer NRW/18/18246 (#176) bezüglich Matrix-Symbole und -Farben hergestellt. Refs: #175, #176 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ee93fcd76a
commit
c268d889fa
@ -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'<td class="{css_class}" title="{_e(entry.aspect)}">{symbol}</td>')
|
||||
else:
|
||||
html.append('<td></td>')
|
||||
html.append('<td class="rating-0"></td>')
|
||||
html.append('</tr>')
|
||||
|
||||
html.append('</tbody></table>')
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user