This commit is contained in:
2026-01-03 22:48:38 +08:00
parent 4bec76ab78
commit bcf24085f9

View File

@@ -218,8 +218,9 @@ class ClassPKAPI(APIView):
top_25_avg = statistics.mean(ac_list[:top_25_count]) if top_25_count > 0 else 0 top_25_avg = statistics.mean(ac_list[:top_25_count]) if top_25_count > 0 else 0
bottom_25_avg = statistics.mean(ac_list[-bottom_25_count:]) if bottom_25_count > 0 else 0 bottom_25_avg = statistics.mean(ac_list[-bottom_25_count:]) if bottom_25_count > 0 else 0
# 优秀率AC数 >= 平均值的1.5倍 # 优秀率AC数 >= 中位数 + 标准差
excellent_threshold = avg_ac * 1.5 # 使用中位数+标准差方法,既不受极端值影响,又能反映班级差异
excellent_threshold = median_ac + std_dev if std_dev > 0 else median_ac * 1.5
excellent_count = sum(1 for ac in ac_list if ac >= excellent_threshold) excellent_count = sum(1 for ac in ac_list if ac >= excellent_threshold)
excellent_rate = (excellent_count / user_count * 100) if user_count > 0 else 0 excellent_rate = (excellent_count / user_count * 100) if user_count > 0 else 0