|
|
@ -8,11 +8,11 @@ class ShixunsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns,
|
|
|
|
before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns,
|
|
|
|
:propaedeutics, :departments, :apply_shixun_mirror,
|
|
|
|
:propaedeutics, :departments, :apply_shixun_mirror,
|
|
|
|
:get_mirror_script, :download_file]
|
|
|
|
:get_mirror_script, :download_file, :shixun_list]
|
|
|
|
|
|
|
|
|
|
|
|
before_action :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns,
|
|
|
|
before_action :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns,
|
|
|
|
:propaedeutics, :departments, :apply_shixun_mirror,
|
|
|
|
:propaedeutics, :departments, :apply_shixun_mirror,
|
|
|
|
:get_mirror_script, :download_file]
|
|
|
|
:get_mirror_script, :download_file, :shixun_list]
|
|
|
|
before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy, :add_file]
|
|
|
|
before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy, :add_file]
|
|
|
|
|
|
|
|
|
|
|
|
before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish,
|
|
|
|
before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish,
|
|
|
@ -99,21 +99,32 @@ class ShixunsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def shixun_list
|
|
|
|
def shixun_list
|
|
|
|
|
|
|
|
# 全部实训/我的实训
|
|
|
|
type = params[:type] || "all"
|
|
|
|
type = params[:type] || "all"
|
|
|
|
|
|
|
|
# 状态:已发布/未发布
|
|
|
|
|
|
|
|
status = params[:status] || "all"
|
|
|
|
|
|
|
|
|
|
|
|
# 超级管理员用户显示所有未隐藏的实训、非管理员显示所有已发布的实训(对本单位公开且未隐藏未关闭)
|
|
|
|
# 超级管理员用户显示所有未隐藏的实训、非管理员显示所有已发布的实训(对本单位公开且未隐藏未关闭)
|
|
|
|
if current_user.admin?
|
|
|
|
if type == "mine"
|
|
|
|
@shixuns = Shixun.unhidden
|
|
|
|
@shixuns = current_user.shixuns.none_closed
|
|
|
|
else
|
|
|
|
else
|
|
|
|
none_shixun_ids = ShixunSchool.where("school_id != #{current_user.school_id}").pluck(:shixun_id)
|
|
|
|
if current_user.admin?
|
|
|
|
|
|
|
|
@shixuns = Shixun.none_closed.where(hidden: 0)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
none_shixun_ids = ShixunSchool.where("school_id != #{current_user.school_id}").pluck(:shixun_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@shixuns = Shixun.where.not(id: none_shixun_ids).none_closed.where(hidden: 0)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@shixuns = Shixun.where.not(id: none_shixun_ids).unhidden
|
|
|
|
unless status == "all"
|
|
|
|
|
|
|
|
@shixuns = status == "published" ? @shixuns.where(status: 2) : @shixuns.where(status: [0, 1])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
## 搜索关键字创建者、实训名称、院校名称
|
|
|
|
## 搜索关键字创建者、实训名称、院校名称
|
|
|
|
unless params[:search].blank?
|
|
|
|
unless params[:search].blank?
|
|
|
|
keyword = params[:search].strip
|
|
|
|
keyword = params[:search].strip
|
|
|
|
@shixuns = @shixuns.joins(user: [user_extenison: :school]).
|
|
|
|
@shixuns = @shixuns.joins(user: [user_extension: :school]).
|
|
|
|
where("schools.name like '%#{keyword}%'
|
|
|
|
where("schools.name like '%#{keyword}%'
|
|
|
|
or concat(lastname, firstname) like '%#{keyword}%'
|
|
|
|
or concat(lastname, firstname) like '%#{keyword}%'
|
|
|
|
or shixuns.name like '%#{keyword.split(" ").join("%")}%'").distinct
|
|
|
|
or shixuns.name like '%#{keyword.split(" ").join("%")}%'").distinct
|
|
|
@ -128,7 +139,7 @@ class ShixunsController < ApplicationController
|
|
|
|
page = params[:page] || 1
|
|
|
|
page = params[:page] || 1
|
|
|
|
limit = params[:limit] || 15
|
|
|
|
limit = params[:limit] || 15
|
|
|
|
|
|
|
|
|
|
|
|
@shixuns = @shixuns.includes(:challenges, user: [user_extension: :school]).page(page).per(limit)
|
|
|
|
@shixuns = @shixuns.order("myshixuns_count desc").page(page).per(limit).includes(:shixun_info, :subjects, user: [user_extension: :school])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
## 获取顶部菜单
|
|
|
|
## 获取顶部菜单
|
|
|
|