|
|
|
@ -8,16 +8,24 @@ class AttendancesController < ApplicationController
|
|
|
|
|
current_date = Date.current
|
|
|
|
|
current_end_time = Time.current.strftime("%H:%M:%S")
|
|
|
|
|
|
|
|
|
|
member = @course.students.find_by(user_id: current_user.id)
|
|
|
|
|
|
|
|
|
|
if params[:history]
|
|
|
|
|
if @user_course_identity == Course::STUDENT
|
|
|
|
|
history_attendance_ids = member.course_member_attendances.where(course_id: @course.id).pluck(:course_attendance_id)
|
|
|
|
|
|
|
|
|
|
@attendances = @course.course_attendances.where(id: history_attendance_ids.uniq).
|
|
|
|
|
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
|
|
|
|
|
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})
|
|
|
|
|
|
|
|
|
|