diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 542c33652..7a135b031 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -891,7 +891,7 @@ class CoursesController < ApplicationController # 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) if existing_student.present? # 如果在该课堂已经存在学生身份,且邀请码为分班邀请码,则将其直接加入分班 @@ -911,7 +911,7 @@ class CoursesController < ApplicationController 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 unless teacher_already_exist 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_id: current_user.id, course_message_type: "JoinCourseRequest", viewed: false) - course_message.content = 2 if params[:professor].present? - course_message.content = 3 if params[:assistant_professor].present? + course_message.content = 2 if params[:professor].present? && params[:professor].to_i == 1 + course_message.content = 3 if params[:assistant_professor].present? && params[:assistant_professor].to_i == 1 course_message.save!