PCqiandao
cxt 5 years ago
parent b9476a4a23
commit b24fc4d16c

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

Loading…
Cancel
Save