socialforge/app/helpers/quality_analysis_helper.rb

98 lines
1.8 KiB
Ruby

# encoding: utf-8
module QualityAnalysisHelper
def sqale_rating_status val
arr = []
if val <= 5
arr << "很好"
arr << "b_green2"
elsif val. > 5 && val <= 10
arr << "较好"
arr << "b_slow_yellow"
elsif val > 10 && val <= 20
arr << "中等"
arr << "b_yellow"
elsif val > 20 && val <= 50
arr << "较差"
arr << "b_slow_red"
elsif val > 20
arr << "很差"
arr << "b_red"
end
end
def complexity_status val
arr = []
if val <= 10
arr << "良好"
arr << "b_green2"
elsif val > 10 && val <= 15
arr << "较高"
arr << "b_yellow"
elsif val > 15
arr << "很高"
arr << "b_red"
end
end
def duplicated_lines_density_status val
arr = []
if val <= 30
arr << "良好"
arr << "b_green2"
elsif val > 30 && val <= 50
arr << "较高"
arr << "b_yellow"
elsif val > 50
arr << "很高"
arr << "b_red"
end
end
def comment_lines_density_status val
arr = []
if val <= 20
arr << "较低"
arr << "b_yellow"
elsif val > 20 && val <= 50
arr << "正常"
arr << "b_green2"
elsif val > 50
arr << "较高"
arr << "b_red"
end
end
def score_sqale_rating val
if val >= 0 && val <= 5
"5"
elsif val > 5 && val <= 10
"4"
elsif val > 10 && val <= 20
"3"
elsif val > 20 && val <= 50
"2"
elsif val > 50
"1"
end
end
def lines_scale val
if val.to_i < 5000
"小型"
elsif val.to_i >5000 && val.to_i < 50000
"中型"
else
"大型"
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