You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/helpers/weapps/attendances_helper.rb

22 lines
993 B

module Weapps::AttendancesHelper
def student_attendance_status attendance, user
st_attendance = attendance.course_member_attendances.find_by(user_id: user.id)
attendance_status = st_attendance.present? ? st_attendance.attendance_status : "ABSENCE"
attendance_mode = st_attendance.present? ? st_attendance.attendance_mode : "DEFAULT"
{attendance_status: attendance_status, attendance_mode: attendance_mode}
end
def group_attendance_count attendances, member_ids
# course_member_ids = group.course_members.pluck(:id)
attendances.select{|attendance| member_ids.include?(attendance.course_member_id) && attendance.attendance_status == "NORMAL"}.size
end
def history_member_count member_attendances, status, attendance_id
member_attendances.select{|member_attendance| member_attendance.attendance_status == status && member_attendance.course_attendance_id == attendance_id}.size
end
def cal_rate base, sum
sum == 0 ? 0 : (base.to_f / sum)
end
end