module Weapps::AttendancesHelper def student_attendance_status attendance, user st_attendance = attendance.course_member_attendances.find_by(user_id: user.id) st_attendance.present? ? st_attendance.attendance_status : "ABSENCE" end def group_attendance_count attendances, group course_member_ids = group.course_members.pluck(:id) attendances.select{|attendance| course_member_ids.include?(attendance.course_member_id) && attendance.attendance_status == "NORMAL"}.size end end