被除数为0时弹框报错
This commit is contained in:
parent
6c13a682c0
commit
54aae26cbe
|
@ -1931,7 +1931,7 @@ module ApplicationHelper
|
||||||
when 0
|
when 0
|
||||||
@student_size ||= searchStudent(course).size
|
@student_size ||= searchStudent(course).size
|
||||||
@homework_size = bid.homeworks.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"
|
confirm_info = "目前#{@student_size}个学生,总共提交了#{@homework_size}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n"
|
||||||
when 1
|
when 1
|
||||||
@homework_evaluations = 0
|
@homework_evaluations = 0
|
||||||
|
@ -1948,7 +1948,7 @@ module ApplicationHelper
|
||||||
@has_evaluations = 0
|
@has_evaluations = 0
|
||||||
bid.homeworks.map { |homework| @has_evaluations += homework.rates(:quality).where("seems_rateable_rates.rater_id not in #{teachers}").count}
|
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"
|
confirm_info = "目前总共分配了#{@homework_evaluations}份匿评作业,已评价#{@has_evaluations}份作业,占#{number_to_percentage(percent * 100, precision: 1)}\n"
|
||||||
end
|
end
|
||||||
confirm_info
|
confirm_info
|
||||||
|
|
Loading…
Reference in New Issue