|
|
|
@ -18,7 +18,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
: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,
|
|
|
|
|
:top_banner, :left_banner, :add_teacher_popup, :add_teacher, :inform_up, :inform_down,
|
|
|
|
|
:graduation_group_list, :create_graduation_group, :join_graduation_group,
|
|
|
|
|
:course_group_list, :set_course_group, :change_course_admin, :change_course_teacher,
|
|
|
|
|
:delete_course_teacher, :teacher_application_review, :students, :all_course_groups,
|
|
|
|
@ -41,7 +41,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
:set_course_group, :create_group_by_importing_file,
|
|
|
|
|
:update_task_position, :tasks_list]
|
|
|
|
|
before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group,
|
|
|
|
|
:change_course_teacher, :course_group_list, :change_member_role,
|
|
|
|
|
:change_course_teacher, :course_group_list, :change_member_role,:inform_up, :inform_down,
|
|
|
|
|
:teacher_application_review, :apply_teachers, :delete_course_teacher]
|
|
|
|
|
before_action :validate_course_name, only: [:create, :update]
|
|
|
|
|
before_action :find_board, only: :board_list
|
|
|
|
@ -281,13 +281,43 @@ class CoursesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def informs
|
|
|
|
|
@informs = @course.informs
|
|
|
|
|
@informs = @course.informs.order("position desc")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def inform_up
|
|
|
|
|
inform = @course.informs.find_by(id: params[:inform_id])
|
|
|
|
|
next_inform = inform.next_inform
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
if next_inform
|
|
|
|
|
render_error('已经到达最底部')
|
|
|
|
|
else
|
|
|
|
|
inform.update_attribute(:position, (position + 1))
|
|
|
|
|
next_inform.update_attribute(:position, last_inform.position - 1)
|
|
|
|
|
render_ok
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def inform_down
|
|
|
|
|
inform = @course.informs.find_by(id: params[:inform_id])
|
|
|
|
|
last_inform = inform.last_inform
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
if last_inform
|
|
|
|
|
render_error('已经到达最顶部')
|
|
|
|
|
else
|
|
|
|
|
inform.update_attribute(:position, (position - 1))
|
|
|
|
|
last_inform.update_attribute(:position, last_inform.position + 1)
|
|
|
|
|
render_ok
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def new_informs
|
|
|
|
|
inform = Inform.new(container: @course)
|
|
|
|
|
inform.name = params[:name]
|
|
|
|
|
inform.description = params[:description]
|
|
|
|
|
inform.position = @course.informs.max(:position).to_i + 1
|
|
|
|
|
inform.save!
|
|
|
|
|
normal_status("创建成功")
|
|
|
|
|
end
|
|
|
|
@ -300,6 +330,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def delete_informs
|
|
|
|
|
inform = @course.informs.find_by(id: params[:inform_id])
|
|
|
|
|
@course.informs.where("position > ?", inform.position).update_all("position = position - 1")
|
|
|
|
|
inform.destroy!
|
|
|
|
|
normal_status("删除成功")
|
|
|
|
|
end
|
|
|
|
|