diff --git a/main.py b/main.py index 873a190..78000bf 100644 --- a/main.py +++ b/main.py @@ -1069,7 +1069,7 @@ async def print_program_score(program_sn: str): FROM scores WHERE judge_id = ? AND program_sn = ?""", (judge['id'], program_sn), ).fetchone() - total = 0 + total = None has_score = False comment = '' if score: @@ -1079,23 +1079,29 @@ async def print_program_score(program_sn: str): has_score = True else: # 计算明细分之和 + sum_score = 0 if score['content_score'] is not None: - total += score['content_score'] + sum_score += score['content_score'] has_score = True if score['stage_score'] is not None: - total += score['stage_score'] + sum_score += score['stage_score'] has_score = True if score['art_score'] is not None: - total += score['art_score'] + sum_score += score['art_score'] has_score = True if score['overall_score'] is not None: - total += score['overall_score'] + sum_score += score['overall_score'] has_score = True + if has_score: + total = sum_score comment = score['comment'] or '' - # 只有已评分的评委才计入统计(包括0分) if has_score: all_scores.append(total) - scores_data[judge['name']] = {'total': total, 'comment': comment} + scores_data[judge['name']] = { + 'total': total, + 'comment': comment, + 'has_score': has_score, + } max_score = max(all_scores) if all_scores else 0 min_score = min(all_scores) if all_scores else 0 avg_score = round(sum(all_scores) / len(all_scores), 3) if all_scores else 0 @@ -1183,7 +1189,12 @@ def render_print_program_template(
| 评委姓名 | 总分(100分) | 评委点评 |
|---|---|---|
| {judge['name']} | {s.get('total') if s.get('total') is not None else '-'} | {s.get('comment', '')} |
| {judge['name']} | {total_display} | {s.get('comment', '')} |
评委组签名:____________________
日期:{datetime.now().strftime('%Y年%m月%d日')}