|
|
@ -28,19 +28,24 @@ class Weapps::CourseMemberAttendancesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
def create
|
|
|
|
tip_exception("签到码不能为空") if params[:code].blank?
|
|
|
|
tip_exception("签到码不能为空") if params[:attendance_mode] != "QUICK" && params[:code].blank?
|
|
|
|
tip_exception("attendance_mode参数不对") unless ["NUMBER", "QRCODE"].include?(params[:attendance_mode])
|
|
|
|
tip_exception("attendance_mode参数不对") unless ["NUMBER", "QRCODE", "QUICK"].include?(params[:attendance_mode])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if params[:attendance_mode] == "QUICK"
|
|
|
|
|
|
|
|
attendance = CourseAttendance.find_by(id: params[:attendance_id])
|
|
|
|
|
|
|
|
else
|
|
|
|
attendance = CourseAttendance.find_by(attendance_code: params[:code])
|
|
|
|
attendance = CourseAttendance.find_by(attendance_code: params[:code])
|
|
|
|
tip_exception("签到码输入有误") if attendance.blank? || attendance.course.blank?
|
|
|
|
end
|
|
|
|
|
|
|
|
tip_exception("该签到不存在") if attendance.blank? || attendance.course.blank?
|
|
|
|
|
|
|
|
|
|
|
|
member = attendance.course.students.find_by(user_id: current_user.id)
|
|
|
|
member = attendance.course.students.find_by(user_id: current_user.id)
|
|
|
|
tip_exception("签到码输入有误") if member.blank?
|
|
|
|
tip_exception("该签到不存在") if member.blank?
|
|
|
|
|
|
|
|
|
|
|
|
tip_exception("不在签到时间内") unless attendance.current_attendance?
|
|
|
|
tip_exception("不在签到时间内") unless attendance.current_attendance?
|
|
|
|
|
|
|
|
|
|
|
|
tip_exception("只支持数字签到") if attendance.mode != "ALL" && attendance.mode == "NUMBER" && params[:attendance_mode] == "QRCODE"
|
|
|
|
tip_exception("只支持数字签到") if attendance.mode != "ALL" && attendance.mode == "NUMBER" && params[:attendance_mode] != "NUMBER"
|
|
|
|
tip_exception("只支持二维码签到") if attendance.mode != "ALL" && attendance.mode == "QRCODE" && params[:attendance_mode] == "NUMBER"
|
|
|
|
tip_exception("只支持二维码签到") if attendance.mode != "ALL" && attendance.mode == "QRCODE" && params[:attendance_mode] != "QRCODE"
|
|
|
|
|
|
|
|
tip_exception("只支持快捷签到") if attendance.mode == "QUICK" && params[:attendance_mode] != "QUICK"
|
|
|
|
|
|
|
|
|
|
|
|
current_attendance = attendance.course_member_attendances.find_by(user_id: current_user.id)
|
|
|
|
current_attendance = attendance.course_member_attendances.find_by(user_id: current_user.id)
|
|
|
|
if current_attendance.present?
|
|
|
|
if current_attendance.present?
|
|
|
|