|
|
@ -284,7 +284,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
@is_admin = @user_course_identity < Course::PROFESSOR
|
|
|
|
@is_admin = @user_course_identity < Course::PROFESSOR
|
|
|
|
|
|
|
|
|
|
|
|
@applications= CourseMessage.unhandled_join_course_requests_by_course(@course)
|
|
|
|
@applications = @is_admin ? CourseMessage.unhandled_join_course_requests_by_course(@course) : CourseMessage.none
|
|
|
|
|
|
|
|
|
|
|
|
page = params[:page] || 1
|
|
|
|
page = params[:page] || 1
|
|
|
|
limit = params[:limit] || 20
|
|
|
|
limit = params[:limit] || 20
|
|
|
@ -548,6 +548,7 @@ class CoursesController < ApplicationController
|
|
|
|
course_teacher = CourseMember.find_by(user_id: current_user.id, role: %i[CREATOR PROFESSOR ASSISTANT_PROFESSOR], course_id: @course.id)
|
|
|
|
course_teacher = CourseMember.find_by(user_id: current_user.id, role: %i[CREATOR PROFESSOR ASSISTANT_PROFESSOR], course_id: @course.id)
|
|
|
|
course_student.destroy!
|
|
|
|
course_student.destroy!
|
|
|
|
course_teacher.update_attributes(is_active: 1) if course_teacher.present? && !course_teacher.is_active
|
|
|
|
course_teacher.update_attributes(is_active: 1) if course_teacher.present? && !course_teacher.is_active
|
|
|
|
|
|
|
|
CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, [current_user.id])
|
|
|
|
normal_status(0, "退出成功")
|
|
|
|
normal_status(0, "退出成功")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -684,11 +685,16 @@ class CoursesController < ApplicationController
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
students = params[:students]
|
|
|
|
students = params[:students]
|
|
|
|
|
|
|
|
student_ids = []
|
|
|
|
|
|
|
|
|
|
|
|
students.each do |student|
|
|
|
|
students.each do |student|
|
|
|
|
course_member = CourseMember.find_by!(id: student[:course_member_id].to_i, course_id: @course.id)
|
|
|
|
course_member = CourseMember.find_by(id: student[:course_member_id].to_i, course_id: @course.id)
|
|
|
|
course_member.destroy!
|
|
|
|
if course_member.present?
|
|
|
|
|
|
|
|
student_ids << course_member.user_id
|
|
|
|
|
|
|
|
course_member.destroy!
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
CourseDeleteStudentDeleteWorksJob.perform_later(@course.id, student_ids) if student_ids.present?
|
|
|
|
normal_status(0, "操作成功")
|
|
|
|
normal_status(0, "操作成功")
|
|
|
|
rescue => e
|
|
|
|
rescue => e
|
|
|
|
uid_logger(e.message)
|
|
|
|
uid_logger(e.message)
|
|
|
@ -711,7 +717,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
student_ids = []
|
|
|
|
student_ids = []
|
|
|
|
user_ids.each do |user_id|
|
|
|
|
user_ids.each do |user_id|
|
|
|
|
existing_course_member = CourseMember.find_by(user_id: user_id.to_i, course_id: @course.id)
|
|
|
|
existing_course_member = @course.course_members.find_by(user_id: user_id.to_i)
|
|
|
|
new_student = CourseMember.new(user_id: user_id.to_i, course_id: @course.id, course_group_id: course_group_id, role: 4)
|
|
|
|
new_student = CourseMember.new(user_id: user_id.to_i, course_id: @course.id, course_group_id: course_group_id, role: 4)
|
|
|
|
|
|
|
|
|
|
|
|
if existing_course_member.present?
|
|
|
|
if existing_course_member.present?
|
|
|
@ -720,6 +726,7 @@ class CoursesController < ApplicationController
|
|
|
|
else
|
|
|
|
else
|
|
|
|
new_student.is_active = 0 if existing_course_member.is_active
|
|
|
|
new_student.is_active = 0 if existing_course_member.is_active
|
|
|
|
new_student.save!
|
|
|
|
new_student.save!
|
|
|
|
|
|
|
|
student_ids << user_id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
new_student.save!
|
|
|
|
new_student.save!
|
|
|
@ -727,6 +734,7 @@ class CoursesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CourseAddStudentCreateWorksJob.perform_later(@course.id, student_ids) if student_ids.present?
|
|
|
|
TeacherInviteJoinCourseNotifyJob.perform_later(current_user.id, @course.id, 10, student_ids) if student_ids.present?
|
|
|
|
TeacherInviteJoinCourseNotifyJob.perform_later(current_user.id, @course.id, 10, student_ids) if student_ids.present?
|
|
|
|
normal_status(0, "添加成功")
|
|
|
|
normal_status(0, "添加成功")
|
|
|
|
rescue => e
|
|
|
|
rescue => e
|
|
|
@ -868,6 +876,7 @@ class CoursesController < ApplicationController
|
|
|
|
new_student.course_group_id = course_group.id if course_group.present?
|
|
|
|
new_student.course_group_id = course_group.id if course_group.present?
|
|
|
|
new_student.save!
|
|
|
|
new_student.save!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id])
|
|
|
|
StudentJoinCourseNotifyJob.perform_later(current_user.id, course.id)
|
|
|
|
StudentJoinCourseNotifyJob.perform_later(current_user.id, course.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|