签到调整

PCqiandao
cxt 5 years ago
parent 27766f66f8
commit 1dc9983764

@ -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]
@attendances = @course.course_attendances.where("attendance_date < '#{current_date}' or
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})

Loading…
Cancel
Save