diff --git a/app/controllers/graduation_topics_controller.rb b/app/controllers/graduation_topics_controller.rb index bd93401f3..0242bff21 100644 --- a/app/controllers/graduation_topics_controller.rb +++ b/app/controllers/graduation_topics_controller.rb @@ -230,6 +230,7 @@ class GraduationTopicsController < ApplicationController topic_repeat: topic.topic_repeat, province: topic.province, city: topic.city, + topic_type: topic.topic_type, course_list_id: @course.course_list_id) topic_bank.attachments.destroy_all else @@ -241,6 +242,7 @@ class GraduationTopicsController < ApplicationController topic_repeat: topic.topic_repeat, province: topic.province, city: topic.city, + topic_type: topic.topic_type, course_list_id: @course.course_list_id, user_id: current_user.id, graduation_topic_id: topic.id) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 74d1d05e2..4555bd1cf 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -98,6 +98,39 @@ class ShixunsController < ApplicationController .each_with_object({}) { |r, obj| obj[r.shixun_id] = r.name } end + def shixun_list + type = params[:type] || "all" + + # 超级管理员用户显示所有未隐藏的实训、非管理员显示所有已发布的实训(对本单位公开且未隐藏未关闭) + if current_user.admin? + @shixuns = Shixun.unhidden + else + none_shixun_ids = ShixunSchool.where("school_id != #{current_user.school_id}").pluck(:shixun_id) + + @shixuns = Shixun.where.not(id: none_shixun_ids).unhidden + end + + ## 搜索关键字创建者、实训名称、院校名称 + unless params[:search].blank? + keyword = params[:search].strip + @shixuns = @shixuns.joins(user: [user_extenison: :school]). + where("schools.name like '%#{keyword}%' + or concat(lastname, firstname) like '%#{keyword}%' + or shixuns.name like '%#{keyword.split(" ").join("%")}%'").distinct + end + + ## 筛选 难度 + if params[:diff].present? && params[:diff].to_i != 0 + @shixuns = @shixuns.where(trainee: params[:diff]) + end + + @total_count = @shixuns.count + page = params[:page] || 1 + limit = params[:limit] || 15 + + @shixuns = @shixuns.includes(:challenges, user: [user_extension: :school]).page(page).per(limit) + end + ## 获取顶部菜单 def menus @repertoires = Repertoire.includes(sub_repertoires: [:tag_repertoires]).order("updated_at asc")