diff --git a/app/helpers/quality_analysis_helper.rb b/app/helpers/quality_analysis_helper.rb index 68ceb0996..0454a6943 100644 --- a/app/helpers/quality_analysis_helper.rb +++ b/app/helpers/quality_analysis_helper.rb @@ -68,4 +68,11 @@ module QualityAnalysisHelper end end + #统计答题百分比,统计结果保留两位小数 + def statistics_result_percentage(e, t) + e = e.to_f + t = t.to_f + t == 0 ? 0 : format("%.2f", e*100/t) + end + end diff --git a/app/views/quality_analysis/_show.html.erb b/app/views/quality_analysis/_show.html.erb index 522b004a8..d3dc277bc 100644 --- a/app/views/quality_analysis/_show.html.erb +++ b/app/views/quality_analysis/_show.html.erb @@ -55,8 +55,8 @@