|
|
|
@ -12,10 +12,10 @@ class CoursesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups,
|
|
|
|
|
:left_banner, :top_banner, :informs, :online_learning]
|
|
|
|
|
:left_banner, :top_banner, :informs, :online_learning, :course_groups]
|
|
|
|
|
before_action :check_account, only: [:new, :create, :apply_to_join_course, :join_excellent_course]
|
|
|
|
|
before_action :check_auth, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups,
|
|
|
|
|
:left_banner, :top_banner, :apply_to_join_course, :exit_course]
|
|
|
|
|
:left_banner, :top_banner, :apply_to_join_course, :exit_course, :course_groups]
|
|
|
|
|
before_action :set_course, only: [:show, :update, :destroy, :settings, :set_invite_code_halt,
|
|
|
|
|
:set_public_or_private, :search_teacher_candidate, :teachers, :apply_teachers,
|
|
|
|
|
:top_banner, :left_banner, :add_teacher_popup, :add_teacher,
|
|
|
|
@ -28,7 +28,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
:switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course,
|
|
|
|
|
:informs, :update_informs, :online_learning, :update_task_position, :tasks_list,
|
|
|
|
|
:join_excellent_course, :export_couser_info, :export_member_act_score, :new_informs,
|
|
|
|
|
:delete_informs, :change_member_role]
|
|
|
|
|
:delete_informs, :change_member_role, :course_groups, :join_course_group]
|
|
|
|
|
before_action :user_course_identity, except: [:join_excellent_course, :index, :create, :new, :apply_to_join_course,
|
|
|
|
|
:search_course_list, :get_historical_course_students, :mine, :search_slim, :board_list]
|
|
|
|
|
before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate,
|
|
|
|
@ -822,6 +822,26 @@ class CoursesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 分班列表
|
|
|
|
|
def course_groups
|
|
|
|
|
@course_groups = @course.course_groups
|
|
|
|
|
@course_groups = @course_groups.where("name like ?", "%#{params[:search]}%") unless params[:search].blank?
|
|
|
|
|
@all_group_count = @course_groups.size
|
|
|
|
|
@teachers = @course.teachers.includes(:user, :teacher_course_groups) if @user_course_identity < Course::NORMAL
|
|
|
|
|
@current_group_id = @course.students.where(user_id: current_user.id).take&.course_group_id if @user_course_identity == Course::STUDENT
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 学生自动加入分班
|
|
|
|
|
def join_course_group
|
|
|
|
|
tip_exception("学生才能加入分班") if @user_course_identity != Course::STUDENT
|
|
|
|
|
course_group = CourseGroup.find_by!(id: params[:course_group_id], course_id: @course.id)
|
|
|
|
|
member = CourseMember.find_by!(user_id: current_user.id, course_id: @course.id, role: 4)
|
|
|
|
|
if course_group && member
|
|
|
|
|
member.update_attributes!(course_group_id: course_group.id)
|
|
|
|
|
normal_status(0, "加入成功")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 将学生批量移动到某个分班
|
|
|
|
|
def transfer_to_course_group
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|