|
|
@ -44,6 +44,7 @@ class Weapps::AttendancesController < ApplicationController
|
|
|
|
def student_attendances
|
|
|
|
def student_attendances
|
|
|
|
# tip_exception("学生身份的签到列表") if @user_course_identity != Course::STUDENT
|
|
|
|
# tip_exception("学生身份的签到列表") if @user_course_identity != Course::STUDENT
|
|
|
|
member = @course.students.find_by(user_id: current_user.id)
|
|
|
|
member = @course.students.find_by(user_id: current_user.id)
|
|
|
|
|
|
|
|
if member.present?
|
|
|
|
current_date = Date.current
|
|
|
|
current_date = Date.current
|
|
|
|
current_end_time = Time.current.strftime("%H:%M:%S")
|
|
|
|
current_end_time = Time.current.strftime("%H:%M:%S")
|
|
|
|
|
|
|
|
|
|
|
@ -52,7 +53,10 @@ class Weapps::AttendancesController < ApplicationController
|
|
|
|
group_ids = [member&.course_group_id.to_i, 0]
|
|
|
|
group_ids = [member&.course_group_id.to_i, 0]
|
|
|
|
all_attendance_ids = @course.course_attendance_groups.where(course_group_id: group_ids).pluck(:course_attendance_id)
|
|
|
|
all_attendance_ids = @course.course_attendance_groups.where(course_group_id: group_ids).pluck(:course_attendance_id)
|
|
|
|
|
|
|
|
|
|
|
|
@history_attendances = @course.course_attendances.where(id: all_attendance_ids.uniq).
|
|
|
|
# 学生的历史签到只统计加入课堂后创建的签到
|
|
|
|
|
|
|
|
history_attendance_ids = member.course_member_attendances.where(course_id: @course.id).pluck(:course_attendance_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@history_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}')").order("id desc")
|
|
|
|
where("attendance_date < '#{current_date}' or (attendance_date = '#{current_date}' and end_time < '#{current_end_time}')").order("id desc")
|
|
|
|
@current_attendance = @course.course_attendances.where(id: all_attendance_ids.uniq).
|
|
|
|
@current_attendance = @course.course_attendances.where(id: all_attendance_ids.uniq).
|
|
|
|
where("attendance_date = '#{current_date}' and start_time <= '#{current_end_time}' and end_time > '#{current_end_time}'")
|
|
|
|
where("attendance_date = '#{current_date}' and start_time <= '#{current_end_time}' and end_time > '#{current_end_time}'")
|
|
|
@ -75,6 +79,7 @@ class Weapps::AttendancesController < ApplicationController
|
|
|
|
@all_history_count = @history_attendances.size
|
|
|
|
@all_history_count = @history_attendances.size
|
|
|
|
@history_attendances = paginate @history_attendances.includes(:course_member_attendances)
|
|
|
|
@history_attendances = paginate @history_attendances.includes(:course_member_attendances)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
def show
|
|
|
|
@normal_count = @attendance.normal_count
|
|
|
|
@normal_count = @attendance.normal_count
|
|
|
|