|
|
|
@ -5,7 +5,7 @@ class SubjectsController < ApplicationController
|
|
|
|
|
before_action :find_subject, except: [:index, :create, :new, :append_to_stage]
|
|
|
|
|
before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish,
|
|
|
|
|
:search_members, :add_subject_members, :statistics, :shixun_report, :school_report,
|
|
|
|
|
:up_member_position, :down_member_position, :update_team_title]
|
|
|
|
|
:up_member_position, :down_member_position, :update_team_title, :add_shixun_to_stage]
|
|
|
|
|
before_action :require_admin, only: [:copy_subject]
|
|
|
|
|
|
|
|
|
|
include ApplicationHelper
|
|
|
|
@ -212,6 +212,16 @@ class SubjectsController < ApplicationController
|
|
|
|
|
@shixuns = Shixun.where(id: params[:shixun_id]).order("id desc")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 添加实训项目
|
|
|
|
|
def add_shixun_to_stage
|
|
|
|
|
identifier = generate_identifier Shixun, 8
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
@shixun = Shixun.create!(name: params[:name], user_id: current_user.id, identifier: identifier)
|
|
|
|
|
# 添加合作者
|
|
|
|
|
@shixun.shixun_members.create!(user_id: current_user.id, role: 1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def choose_course
|
|
|
|
|
course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m
|
|
|
|
|
WHERE m.course_id = c.id AND m.role in (1,2,3)
|
|
|
|
|