json.subject_id @subject.id json.subject_name @subject.name json.learn_count @learn_count json.course_count @course_count json.schools_count @schools_count json.school_total_count @school_total_count json.schools @schools.try(:each) do |school| json.name school[:name] json.course_count school[:course_count] json.student_count school[:student_count] json.homework_count school[:homework_count] end index = 0 json.stage_info @stage_user_info.each do |stage| json.stage_no "第#{index + 1}章" json.value @sum == 0 ? 0 : (stage * 100 / @sum.to_f).round index += 1 end