|
|
@ -2,6 +2,7 @@ class AttendancesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
before_action :require_login
|
|
|
|
before_action :require_login
|
|
|
|
before_action :find_course, only: [:index, :statistics]
|
|
|
|
before_action :find_course, only: [:index, :statistics]
|
|
|
|
|
|
|
|
before_action :find_attendance, except: [:index, :statistics]
|
|
|
|
before_action :user_course_identity
|
|
|
|
before_action :user_course_identity
|
|
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
def index
|
|
|
@ -66,9 +67,23 @@ class AttendancesController < ApplicationController
|
|
|
|
@avg_leave_rate = data[:avg_leave_rate]
|
|
|
|
@avg_leave_rate = data[:avg_leave_rate]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def edit
|
|
|
|
|
|
|
|
@groups = @course.course_groups.where(id: @attendance.course_attendance_groups.pluck(:course_group_id))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
|
|
|
tip_exception(403, "") unless @user_course_identity < Course::PROFESSOR || @attendance.user_id == current_user.id
|
|
|
|
|
|
|
|
@attendance.update!(update_params)
|
|
|
|
|
|
|
|
render_ok
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
private
|
|
|
|
def find_attendance
|
|
|
|
def find_attendance
|
|
|
|
@attendance = CourseAttendance.find params[:id]
|
|
|
|
@attendance = CourseAttendance.find params[:id]
|
|
|
|
@course = @attendance.course
|
|
|
|
@course = @attendance.course
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_params
|
|
|
|
|
|
|
|
params.permit(:name, :mode, :attendance_date, :start_time, :end_time)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|