被除数为0时弹框报错

This commit is contained in:
sw 2014-11-06 17:23:43 +08:00
parent 6c13a682c0
commit 54aae26cbe
1 changed files with 2 additions and 2 deletions

View File

@ -1931,7 +1931,7 @@ module ApplicationHelper
when 0
@student_size ||= searchStudent(course).size
@homework_size = bid.homeworks.size
percent = @homework_size.to_f / @student_size
percent = @homework_size.to_f / (@student_size == 0 ? 1 : @student_size)
confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n"
when 1
@homework_evaluations = 0
@ -1948,7 +1948,7 @@ module ApplicationHelper
@has_evaluations = 0
bid.homeworks.map { |homework| @has_evaluations += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
percent = @has_evaluations.to_f / @homework_evaluations
percent = @has_evaluations.to_f / (@homework_evaluations == 0 ? 1 : @homework_evaluations)
confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作业,已评价#{@has_evaluations}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n"
end
confirm_info