json.normal_count @normal_count json.leave_count @leave_count json.absence_count @absence_count json.all_count @all_count json.code @attendance.attendance_code json.mode @attendance.mode json.edit_auth @user_course_identity < Course::PROFESSOR || @attendance.user_id == User.current.id json.name @attendance.name json.attendance_date @attendance.attendance_date.strftime("%Y-%m-%d") json.start_time @attendance.start_time.strftime("%H:%M") json.end_time @attendance.end_time.strftime("%H:%M") # json.course_groups @group_ids do |group| # json.(group, :id, :name, :course_members_count) # json.attendance_count group_attendance_count(@all_attendances, group) if @_is_current_attendance # end json.course_groups @group_ids do |group_id| if group_id != 0 group = @groups.select{|group| group.id == group_id}.first json.(group, :id, :name, :course_members_count) else json.id 0 json.name "未分班" json.course_members_count @course.none_group_count end if @_is_current_attendance member_ids = @course_members.select{|member| member.course_group_id == group_id}.map(&:id) json.attendance_count group_attendance_count(@all_attendances, member_ids) end end