|
|
|
@ -11,20 +11,24 @@ class AttendancesController < ApplicationController
|
|
|
|
|
if params[:history]
|
|
|
|
|
@attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or
|
|
|
|
|
(attendance_date = '#{current_date}' and end_time < '#{current_end_time}')")
|
|
|
|
|
else
|
|
|
|
|
@attendances = @course.course_attendances.where("attendance_date > '#{current_date}' or
|
|
|
|
|
(attendance_date = '#{current_date}' and end_time > '#{current_end_time}')")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if @user_course_identity == Course::STUDENT
|
|
|
|
|
member = @course.students.find_by(user_id: current_user.id)
|
|
|
|
|
group_ids = [member&.course_group_id.to_i, 0]
|
|
|
|
|
@attendances = @attendances.joins(:course_attendance_groups).where(course_attendance_groups: {course_group_id: group_ids})
|
|
|
|
|
|
|
|
|
|
if params[:history]
|
|
|
|
|
attendance_ids = @attendances.pluck(:id)
|
|
|
|
|
@normal_count = @course.course_member_attendances.where(course_member_id: member&.id, course_attendance_id: attendance_ids, attendance_status: "NORMAL").size
|
|
|
|
|
@leave_count = @course.course_member_attendances.where(course_member_id: member&.id, course_attendance_id: attendance_ids, attendance_status: "LEAVE").size
|
|
|
|
|
@absence_count = @course.course_member_attendances.where(course_member_id: member&.id, course_attendance_id: attendance_ids, attendance_status: "ABSENCE").size
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
@attendances = @course.course_attendances.where("attendance_date > '#{current_date}' or
|
|
|
|
|
(attendance_date = '#{current_date}' and end_time > '#{current_end_time}')")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@attendances_count = @attendances.size
|
|
|
|
|
|
|
|
|
|
@attendances = @attendances.order("attendance_date desc, start_time desc")
|
|
|
|
|