diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 7ebf7435d..c0c2cda3f 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -796,18 +796,15 @@ class CoursesController < ApplicationController if approval == 1 course_message.pass! - new_teacher = CourseMember.new(course_id: @course.id, user_id: applier_user.id) content = course_message.content.to_i - if content == 3 || content == 7 - tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: 3).any? - new_teacher.ASSISTANT_PROFESSOR! - elsif content == 2 || content == 9 - tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: 2).any? - new_teacher.PROFESSOR! + role = (content == 3 || content == 7) ? 3 : ((content == 2 || content == 9) ? 2 : nil) + if role + tip_exception("已存在教师/助教身份") if CourseMember.where(course_id: @course.id, user_id: applier_user.id, role: [1, 2 ,3]).any? else tip_exception("申请角色错误") end + new_teacher = CourseMember.new(course_id: @course.id, user_id: applier_user.id, role: role) new_teacher.save! # 课堂管理员才有分配权限,且课堂分班数大于0