|
|
|
@ -11,15 +11,15 @@ class Weapps::AttendancesController < ApplicationController
|
|
|
|
|
attendance = @course.course_attendances.create!(create_params.merge(user_id: current_user.id))
|
|
|
|
|
group_ids = params[:group_ids] || []
|
|
|
|
|
group_ids = group_ids.blank? ? @course.charge_group_ids(current_user) : @course.charge_group_ids(current_user) & params[:group_ids].map(&:to_i)
|
|
|
|
|
unless group_ids.blank? || @course.course_groups.where(id: group_ids).count == @course.course_groups.count
|
|
|
|
|
if group_ids.blank? || (params[:group_ids].blank? && @course.course_groups.where(id: group_ids).count == @course.course_groups.count)
|
|
|
|
|
@course.course_attendance_groups.create!(course_group_id: 0, course_attendance: attendance)
|
|
|
|
|
CreateStudentAttendanceRecordJob.perform_now(attendance.id, [0])
|
|
|
|
|
else
|
|
|
|
|
# group_ids = @course.charge_group_ids(current_user) & params[:group_ids].map(&:to_i)
|
|
|
|
|
group_ids.each do |group_id|
|
|
|
|
|
@course.course_attendance_groups.create!(course_group_id: group_id, course_attendance: attendance)
|
|
|
|
|
end
|
|
|
|
|
CreateStudentAttendanceRecordJob.perform_now(attendance.id, group_ids)
|
|
|
|
|
else
|
|
|
|
|
@course.course_attendance_groups.create!(course_group_id: 0, course_attendance: attendance)
|
|
|
|
|
CreateStudentAttendanceRecordJob.perform_now(attendance.id, [0])
|
|
|
|
|
end
|
|
|
|
|
render_ok({attendance_id: attendance.id})
|
|
|
|
|
end
|
|
|
|
|