|
|
@ -13,7 +13,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, :left_banner, :top_banner]
|
|
|
|
before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, :left_banner, :top_banner]
|
|
|
|
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,
|
|
|
|
: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,
|
|
|
|
:graduation_group_list, :create_graduation_group, :join_graduation_group,
|
|
|
|
:graduation_group_list, :create_graduation_group, :join_graduation_group,
|
|
|
|
:course_group_list, :set_course_group, :change_course_admin, :change_course_teacher,
|
|
|
|
:course_group_list, :set_course_group, :change_course_admin, :change_course_teacher,
|
|
|
@ -26,10 +26,10 @@ class CoursesController < ApplicationController
|
|
|
|
:transfer_to_course_group, :delete_from_course,
|
|
|
|
:transfer_to_course_group, :delete_from_course,
|
|
|
|
:search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, :add_teacher]
|
|
|
|
:search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, :add_teacher]
|
|
|
|
before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :change_course_admin,
|
|
|
|
before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :change_course_admin,
|
|
|
|
:set_course_group, :delete_course_teacher, :teacher_application_review,
|
|
|
|
:set_course_group, :delete_course_teacher, :create_group_by_importing_file]
|
|
|
|
:create_group_by_importing_file]
|
|
|
|
|
|
|
|
before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group,
|
|
|
|
before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group,
|
|
|
|
:change_course_teacher, :export_member_scores_excel, :course_group_list]
|
|
|
|
:change_course_teacher, :export_member_scores_excel, :course_group_list,
|
|
|
|
|
|
|
|
:teacher_application_review, :apply_teachers]
|
|
|
|
before_action :validate_course_name, only: [:create, :update]
|
|
|
|
before_action :validate_course_name, only: [:create, :update]
|
|
|
|
before_action :find_board, only: :board_list
|
|
|
|
before_action :find_board, only: :board_list
|
|
|
|
before_action :validate_page_size, only: :mine
|
|
|
|
before_action :validate_page_size, only: :mine
|
|
|
@ -251,46 +251,52 @@ class CoursesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
if @course.try(:id) != 1309 || current_user.admin? || current_user.try(:id) == 15582
|
|
|
|
if @course.try(:id) != 1309 || current_user.admin? || current_user.try(:id) == 15582
|
|
|
|
@teacher_list = @course.course_members.joins(:user).where("course_members.role in (1, 2, 3)
|
|
|
|
@teacher_list = @course.course_members.joins(:user).where("course_members.role in (1, 2, 3)
|
|
|
|
and LOWER(concat(users.lastname, users.firstname)) LIKE '%#{@search_str}%'")
|
|
|
|
and LOWER(concat(users.lastname, users.firstname)) LIKE ?", "%#{@search_str}%")
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@teacher_list = @course.course_members.joins(:user).where("(course_members.role in (1, 3) or (course_members.user_id = #{current_user.id}
|
|
|
|
@teacher_list = @course.course_members.joins(:user).where("(course_members.role in (1, 3) or (course_members.user_id = #{current_user.id}
|
|
|
|
and course_members.role = 2)) and LOWER(concat(users.lastname, users.firstname))
|
|
|
|
and course_members.role = 2)) and LOWER(concat(users.lastname, users.firstname))
|
|
|
|
LIKE '%#{@search_str}%'")
|
|
|
|
LIKE ?", "%#{@search_str}%")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@teacher_list_size = @teacher_list.size
|
|
|
|
@teacher_list_size = @teacher_list.size
|
|
|
|
|
|
|
|
|
|
|
|
@has_graduation_design = @course.course_modules.graduation_module_not_hidden.any?
|
|
|
|
@has_graduation_design = @course.course_modules.graduation_module_not_hidden.any?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sort = params[:sort] || "desc"
|
|
|
|
@order = params[:order].to_i
|
|
|
|
@order = params[:order].to_i
|
|
|
|
if @order.present?
|
|
|
|
if @order.present?
|
|
|
|
case @order
|
|
|
|
case @order
|
|
|
|
when 1
|
|
|
|
when 1
|
|
|
|
@teacher_list = @teacher_list.includes(:user).order("CONVERT(CONCAT(users.lastname, users.firstname) USING gbk) COLLATE gbk_chinese_ci asc")
|
|
|
|
@teacher_list = @teacher_list.order("role #{sort}")
|
|
|
|
when 2
|
|
|
|
when 2
|
|
|
|
@teacher_list = @teacher_list.order("created_at")
|
|
|
|
@teacher_list = @teacher_list.includes(:user).order("CONVERT(CONCAT(users.lastname, users.firstname) USING gbk) COLLATE gbk_chinese_ci #{sort}")
|
|
|
|
when 3
|
|
|
|
when 3
|
|
|
|
@teacher_list = @teacher_list.includes(:course, :graduation_group).order("graduation_groups.name")
|
|
|
|
@teacher_list = @teacher_list.includes(:course, :graduation_group).order("graduation_groups.name #{sort}")
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@teacher_list = @teacher_list.order("created_at")
|
|
|
|
@teacher_list = @teacher_list.order("role #{sort}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if @has_graduation_design
|
|
|
|
@teacher_list = @teacher_list.order("role #{sort}")
|
|
|
|
@teacher_list = @teacher_list.includes(:course, :graduation_group).order("graduation_groups.name")
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
@teacher_list = @teacher_list.order("created_at")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@is_admin = @user_course_identity < Course::PROFESSOR
|
|
|
|
@is_admin = @user_course_identity < Course::PROFESSOR
|
|
|
|
|
|
|
|
|
|
|
|
@applications = @is_admin ? CourseMessage.unhandled_join_course_requests_by_course(@course) : CourseMessage.none
|
|
|
|
@applications_size = CourseMessage.unhandled_join_course_requests_by_course(@course).size
|
|
|
|
|
|
|
|
|
|
|
|
page = params[:page] || 1
|
|
|
|
page = params[:page] || 1
|
|
|
|
limit = params[:limit] || 20
|
|
|
|
limit = params[:limit] || 20
|
|
|
|
@teacher_list = @teacher_list.page(page).per(limit)
|
|
|
|
@teacher_list = @teacher_list.page(page).per(limit)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def apply_teachers
|
|
|
|
|
|
|
|
search_str = params[:search].present? ? params[:search].strip : ""
|
|
|
|
|
|
|
|
@applications = CourseMessage.unhandled_join_course_requests_by_course(@course).joins(:user).
|
|
|
|
|
|
|
|
where("LOWER(concat(users.lastname, users.firstname)) LIKE ?", "%#{search_str}%")
|
|
|
|
|
|
|
|
@teacher_list_size = @course.teachers.size
|
|
|
|
|
|
|
|
@applications_size = CourseMessage.unhandled_join_course_requests_by_course(@course).size
|
|
|
|
|
|
|
|
@is_admin = @user_course_identity < Course::PROFESSOR
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 打开添加教师或助教弹窗时访问的接口(需要返回该课堂所有答辩组和所有)
|
|
|
|
# 打开添加教师或助教弹窗时访问的接口(需要返回该课堂所有答辩组和所有)
|
|
|
|
def add_teacher_popup
|
|
|
|
def add_teacher_popup
|
|
|
|
@graduation_groups = @course.graduation_groups
|
|
|
|
@graduation_groups = @course.graduation_groups
|
|
|
@ -577,6 +583,18 @@ class CoursesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
new_teacher.save!
|
|
|
|
new_teacher.save!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 课堂管理员才有分配权限,且课堂分班数大于0
|
|
|
|
|
|
|
|
if @user_course_identity < Course::PROFESSOR && @course.course_groups_count > 0 && params[:group_id] && params[:group_id].size > 0
|
|
|
|
|
|
|
|
# 分班全选则是不限,不需要做处理
|
|
|
|
|
|
|
|
unless @course.course_groups.where(id: params[:group_id]).size == @course.course_groups_count
|
|
|
|
|
|
|
|
@course.course_groups.where(id: params[:group_id]).each do |group|
|
|
|
|
|
|
|
|
unless TeacherCourseGroup.where(course_id: @course.id, user_id: applier_user.id, course_group_id: group.id, course_member_id: new_teacher.id).exists?
|
|
|
|
|
|
|
|
TeacherCourseGroup.create(course_id: @course.id, user_id: applier_user.id, course_member_id: new_teacher.id, course_group_id: group.id)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
elsif approval == 2
|
|
|
|
elsif approval == 2
|
|
|
|
course_message.reject!
|
|
|
|
course_message.reject!
|
|
|
|
else
|
|
|
|
else
|
|
|
|