|
|
@ -14,7 +14,7 @@ class CoursesController < ApplicationController
|
|
|
|
before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups,
|
|
|
|
before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups,
|
|
|
|
:left_banner, :top_banner]
|
|
|
|
:left_banner, :top_banner]
|
|
|
|
before_action :check_auth, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups,
|
|
|
|
before_action :check_auth, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups,
|
|
|
|
:left_banner, :top_banner, :apply_to_join_course]
|
|
|
|
:left_banner, :top_banner, :apply_to_join_course, :exit_course]
|
|
|
|
before_action :set_course, :user_course_identity, only: [:show, :update, :destroy, :settings, :set_invite_code_halt,
|
|
|
|
before_action :set_course, :user_course_identity, only: [:show, :update, :destroy, :settings, :set_invite_code_halt,
|
|
|
|
:set_public_or_private, :search_teacher_candidate, :teachers, :apply_teachers,
|
|
|
|
:set_public_or_private, :search_teacher_candidate, :teachers, :apply_teachers,
|
|
|
|
:top_banner, :left_banner, :add_teacher_popup, :add_teacher,
|
|
|
|
:top_banner, :left_banner, :add_teacher_popup, :add_teacher,
|
|
|
@ -891,7 +891,7 @@ class CoursesController < ApplicationController
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
# 创建学生身份
|
|
|
|
# 创建学生身份
|
|
|
|
if params[:student].present?
|
|
|
|
if params[:student].present? && params[:student].to_i == 1
|
|
|
|
existing_student = CourseMember.find_by(course_id: course.id, role: %i[STUDENT], user_id: current_user.id)
|
|
|
|
existing_student = CourseMember.find_by(course_id: course.id, role: %i[STUDENT], user_id: current_user.id)
|
|
|
|
if existing_student.present?
|
|
|
|
if existing_student.present?
|
|
|
|
# 如果在该课堂已经存在学生身份,且邀请码为分班邀请码,则将其直接加入分班
|
|
|
|
# 如果在该课堂已经存在学生身份,且邀请码为分班邀请码,则将其直接加入分班
|
|
|
@ -911,7 +911,7 @@ class CoursesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 创建教师身份
|
|
|
|
# 创建教师身份
|
|
|
|
if params[:professor].present? || params[:assistant_professor].present?
|
|
|
|
if (params[:professor].present? && params[:professor].to_i == 1) || (params[:assistant_professor].present? && params[:assistant_professor].to_i == 1)
|
|
|
|
teacher_already_exist = current_user.teacher_of_course_non_active? course
|
|
|
|
teacher_already_exist = current_user.teacher_of_course_non_active? course
|
|
|
|
unless teacher_already_exist
|
|
|
|
unless teacher_already_exist
|
|
|
|
existing_course_message = CourseMessage.find_by(course_id: course.id, course_message_id: current_user.id,
|
|
|
|
existing_course_message = CourseMessage.find_by(course_id: course.id, course_message_id: current_user.id,
|
|
|
@ -920,8 +920,8 @@ class CoursesController < ApplicationController
|
|
|
|
course_message = CourseMessage.new(course_id: course.id, user_id: course.tea_id, status: 0,
|
|
|
|
course_message = CourseMessage.new(course_id: course.id, user_id: course.tea_id, status: 0,
|
|
|
|
course_message_id: current_user.id, course_message_type: "JoinCourseRequest",
|
|
|
|
course_message_id: current_user.id, course_message_type: "JoinCourseRequest",
|
|
|
|
viewed: false)
|
|
|
|
viewed: false)
|
|
|
|
course_message.content = 2 if params[:professor].present?
|
|
|
|
course_message.content = 2 if params[:professor].present? && params[:professor].to_i == 1
|
|
|
|
course_message.content = 3 if params[:assistant_professor].present?
|
|
|
|
course_message.content = 3 if params[:assistant_professor].present? && params[:assistant_professor].to_i == 1
|
|
|
|
|
|
|
|
|
|
|
|
course_message.save!
|
|
|
|
course_message.save!
|
|
|
|
|
|
|
|
|
|
|
|