diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 43e9ef82..c2132bf1 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1533,6 +1533,16 @@ class CoursesController < ApplicationController end end + # 删除实训作业子目录 + def delete_homework_category + category = @course.course_homework_categories.where(:id => params[:category_id]).first + if category.present? + category.homework_commons.update_all(:course_homework_category_id => nil) + category.destroy + end + redirect_to homework_common_index_path(:course => @course.id, :homework_type => 4) + end + def toggleCourse @course_prefs = Course.find_by_extra(@course.extra) unless (User.current.allowed_to?(:as_teacher,@course_prefs) || User.current.admin?) diff --git a/app/models/course_homework_category.rb b/app/models/course_homework_category.rb index 6a1f900e..6e27de18 100644 --- a/app/models/course_homework_category.rb +++ b/app/models/course_homework_category.rb @@ -1,5 +1,5 @@ class CourseHomeworkCategory < ActiveRecord::Base belongs_to :course - has_many :shixun_homework_categories + has_many :homework_commons attr_accessible :name end diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index b03e56dd..931537a7 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -11,6 +11,7 @@ <%= link_to '选用实训', shixuns_homework_common_index_path(:course => @course.id, :category_id => @category.try(:id)), :remote => true, :class => "white-btn edu-orangeback-btn fr mr20 mt2", :title => "新建作业" %> <% if @category.present? %> 子栏目重命名 + 删除子目录 <% else %> 添加子栏目 <% end %> diff --git a/config/routes.rb b/config/routes.rb index 7babc7c2..50e70c25 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2393,6 +2393,7 @@ RedmineApp::Application.routes.draw do post 'assign_teacher_groups' post 'create_homework_category' match 'rename_homework_category', :via => [:get, :post] + delete 'delete_homework_category' post 'import_course_group' end collection do