教师由学生身份切换为老师身份时删除学生数据

sso
cxt 5 years ago
parent 66812f3338
commit 77876acff3

@ -749,8 +749,8 @@ class CoursesController < ApplicationController
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
course_student.destroy! course_student.destroy!
course_teacher.update!(is_active: 1) course_teacher.update!(is_active: 1)
CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, [current_user.id])
end end
CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, [current_user.id])
normal_status(0, "切换成功") normal_status(0, "切换成功")
rescue => e rescue => e
uid_logger_error(e.message) uid_logger_error(e.message)
@ -761,12 +761,15 @@ class CoursesController < ApplicationController
# 切换为助教 # 切换为助教
def switch_to_assistant def switch_to_assistant
begin begin
course_member = @course.course_members.find_by!(user_id: current_user.id, is_active: 1) course_student = @course.course_members.find_by!(user_id: current_user.id, is_active: 1)
tip_exception("切换失败") unless course_member.STUDENT? tip_exception("切换失败") unless course_student.present?
course_teacher = CourseMember.find_by!(user_id: current_user.id, role: %i[ASSISTANT_PROFESSOR], course_id: @course.id) course_teacher = CourseMember.find_by!(user_id: current_user.id, role: %i[ASSISTANT_PROFESSOR], course_id: @course.id)
course_member.update!(is_active: 0) ActiveRecord::Base.transaction do
course_teacher.update!(is_active: 1) course_student.destroy!
course_teacher.update!(is_active: 1)
CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, [current_user.id])
end
normal_status(0, "切换成功") normal_status(0, "切换成功")
rescue => e rescue => e
uid_logger_error(e.message) uid_logger_error(e.message)

Loading…
Cancel
Save