diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index ee59dc8b5..57f335541 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -611,59 +611,46 @@ end def classroom @menu_type = 2 @sub_type = 1 - @syllabus = Syllabus.where("0=0") + @courselist = CourseList.where("0=0") @sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order] - # major_level_option = params[:major_level] if params[:major_level] - # discipline_category_option = params[:discipline_category_id] if params[:discipline_category_id] - # first_level_discipline_option = params[:first_level_discipline_id] if params[:first_level_discipline_id] - # syllabus_major_option = params[:major_id] if params[:major_id] keyword = params[:keyword] search = params[:search] - # if major_level_option && major_level_option != '0' - # @syllabus = @syllabus.where(:major_level=>major_level_option) - # end - # - # if discipline_category_option && discipline_category_option != '0' - # @syllabus=@syllabus.where(:discipline_category_id=>discipline_category_option) - # end - # - # if first_level_discipline_option && first_level_discipline_option != '0' - # @syllabus=@syllabus.where(:first_level_discipline_id=>first_level_discipline_option) - # end - # - # if syllabus_major_option && syllabus_major_option != '0' - # @syllabus=@syllabus.where(:major_id=>syllabus_major_option) - # end - - # if params[:school_id] && params[:school_id] != '' - # @syllabus = @syllabus.includes(:user => {:user_extensions => []}).where("user_extensions.school_id = #{params[:school_id]}") - # end - + if params[:support_shixuns_search_title] + @courselist = @courselist.where(:support_shixuns_search => params[:support_shixuns_search_title].to_i) + end if search.blank? - @syllabus = @syllabus + @courselist = @courselist else if "u_name" == keyword user_id = User.where("concat(lastname, firstname) like '%#{search}%'") - @syllabus = @syllabus.includes(:user).where("concat(users.lastname, users.firstname) like '%#{search}%'") + @courselist = @courselist.includes(:user).where("concat(users.lastname, users.firstname) like '%#{search}%'") else - @syllabus= @syllabus.where("title like '%#{search}%'") + @courselist= @courselist.where("name like '%#{search}%'") end end - - @syllabus = @syllabus.order("syllabuses.created_at #{@sx_order}") - @syllabus_count = @syllabus.count + @courselist_count = @courselist.count limit = 20 @is_remote = true - @syllabus_pages = Paginator.new @syllabus_count, limit, params['page'] || 1 - @offset ||= @syllabus_pages.offset - @syllabus = paginateHelper @syllabus, limit + @courselist_pages = Paginator.new @courselist_count, limit, params['page'] || 1 + @offset ||= @courselist_pages.offset + @courselist = paginateHelper @courselist, limit + + # @courselist = @courselist.order("courselist.created_at #{@sx_order}") respond_to do |format| format.js format.html end end + # 支撑实训检索 + def support_shixuns_search + if params[:shixun_id] + courselist = CourseList.find params[:shixun_id] + courselist.update_attributes(:support_shixuns_search => !courselist.support_shixuns_search) + end + end + # 课堂列表 def classroom_classment @menu_type = 2 @@ -679,6 +666,7 @@ end @search = params[:search] # 搜索字 @keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索 status = params[:status].to_i + courselist = params[:course_list] if params[:school_id] && params[:school_id] != '' @school_id = params[:school_id] @@ -689,6 +677,9 @@ end @courses = @courses.where(:homepage_show => params[:homepage_show].to_i) end + if params[:course_list] + @courses = @courses.where(:course_list_id => courselist) + end if params[:status] && params[:status]!='' @status = params[:status] @courses =@courses.where(:is_end =>status) @@ -813,7 +804,7 @@ end # 0 全部;1 活动的; 2 已注册; 3 锁定 def users - @menu_type =7 + @menu_type @sub_type = 1 status = params[:user_status].nil? ? 0 : params[:user_status].to_i @us_order = params[:us_order].blank? ? "desc" : params[:us_order] # 排序 @@ -832,9 +823,13 @@ end @users = User.where("status = #{status} and #{condition} like '%#{params[:research_contents]}%'").order("#{@order_key} #{@us_order}").all end end - # if params[:school_id] && params[:school_id] !='' - # @users = @users.find(params[:school_id]) - # end + + school_name = params[:school] + school = School.where("name like '%#{school_name}%'") + school_id = school.map(&:id) + user_id = UserExtensions.where(:school_id => school_id).map(&:user_id) + @users = User.where(:id => user_id) + @users_count = @users.count @limit = 20 @is_remote = true @@ -964,7 +959,7 @@ end def users_trial @menu_type = 7 @sub_type = 2 - @users = User.where(:status => 1).order("created_on desc").all + @users = User.where(:status => 1).order("last_login_on desc").all @users_count = @users.count @limit = 20 @is_remote = true @@ -1161,7 +1156,9 @@ end @type = trial_authorization_status(params[:type]) type = params[:type] || 0 # 存在type 就用type 没有就为 0 user_id = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{params[:name]}%'") - @unapproved_user = ApplyUserAuthentication.where(:status => @type, :user_id => user_id, :auth_type => 1).order("updated_at desc") + + @unapproved_user = ApplyUserAuthentication.where(:status => @type, :user_id => user_id, :auth_type => 1).find_by_sql("SELECT s.*, TIMESTAMPDIFF(SECOND, s.updated_at, now()) diff FROM `apply_user_authentications` s order by diff asc") + # @unapproved_user = ApplyUserAuthentication.where(:status => @type, :user_id => user_id, :auth_type => 1).order("updated_at desc") respond_to do |format| format.html format.js @@ -1174,7 +1171,8 @@ end @type = trial_authorization_status(params[:type]) type = params[:type] || 0 # 存在type 就用type 没有就为 0 user_id = User.find_by_sql("select id from users where concat(lastname,firstname) like '%#{params[:name]}%'") - @unapproved_user = ApplyUserAuthentication.where(:status => @type, :user_id => user_id, :auth_type => 2).order("updated_at desc") + @unapproved_user = ApplyUserAuthentication.where(:status => @type, :user_id => user_id, :auth_type => 2).find_by_sql("SELECT s.*, TIMESTAMPDIFF(SECOND, s.updated_at, now()) diff FROM `apply_user_authentications` s order by diff asc") + # @unapproved_user = ApplyUserAuthentication.where(:status => @type, :user_id => user_id, :auth_type => 2).order("updated_at desc") respond_to do |format| format.html format.js @@ -1316,4 +1314,26 @@ end format.js end end + + # 课程删除 + before_filter :find_courselist, :only => [:destroy] + + # 课程列表的删除 + def destroy + if @courselist + CourseList.where(:id => @courselist.id).destroy_all + respond_to do |format| + format.js + end + end + end + private + # Find courselist of id params[:id] + def find_courselist + @courselist = CourseList.find_by_id(params[:id]) + render_404 if @courselist.nil? + rescue ActiveRecord::RecordNotFound + render_404 + end + end diff --git a/app/models/course_list.rb b/app/models/course_list.rb index acafeb37e..33ef6ca47 100644 --- a/app/models/course_list.rb +++ b/app/models/course_list.rb @@ -3,5 +3,5 @@ class CourseList < ActiveRecord::Base has_many :shixun_major_courses has_many :courses belongs_to :user - attr_accessible :name, :user_id, :is_admin + attr_accessible :name, :user_id, :is_admin,:support_shixuns_search end diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index 49dd1a06e..ae4fb1db9 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -1,14 +1,23 @@
+ One who is anxious to learn, can always learn from others. +