Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_auth
杨树明 5 years ago
commit e1f8763bc7

@ -682,14 +682,14 @@ class CoursesController < ApplicationController
tip_exception("切换失败") if course_member.STUDENT?
course_student = CourseMember.find_by(user_id: current_user.id, role: %i[STUDENT], course_id: @course.id)
course_member.update_attributes!(is_active: 0)
if course_student
course_student.update_attributes!(is_active: 1)
else
# 学生身份不存在则创建
CourseMember.create!(user_id: current_user.id, role: %i[STUDENT], course_id: @course.id)
CourseMember.create!(user_id: current_user.id, role: 4, course_id: @course.id)
CourseAddStudentCreateWorksJob.perform_later(@course.id, [current_user.id])
end
course_member.update_attributes!(is_active: 0)
normal_status(0, "切换成功")
rescue => e
uid_logger_error("switch_to_student error: #{e.message}")
@ -1133,7 +1133,7 @@ class CoursesController < ApplicationController
def top_banner
@user = current_user
@switch_student = Course::BUSINESS < @user_course_identity < Course::STUDENT
@switch_student = Course::BUSINESS < @user_course_identity && @user_course_identity < Course::STUDENT
@is_student = @user_course_identity == Course::STUDENT
@course.increment!(:visits)
end

Loading…
Cancel
Save