|
|
|
@ -85,6 +85,16 @@ class SubjectsController < ApplicationController
|
|
|
|
|
# 合作团队
|
|
|
|
|
@shixuns = @subject.shixuns.published.pluck(:id)
|
|
|
|
|
@courses = @subject.courses if @subject.excellent
|
|
|
|
|
@members = @subject.subject_members.includes(:user)
|
|
|
|
|
|
|
|
|
|
shixuns = @subject.shixuns.published.pluck(:id)
|
|
|
|
|
challenge_ids = Challenge.where(shixun_id: shixuns).pluck(:id)
|
|
|
|
|
# 实训路径中的所有实训标签
|
|
|
|
|
@tags = ChallengeTag.where(challenge_id: challenge_ids).pluck(:name).uniq
|
|
|
|
|
# 用户获取的实训标签
|
|
|
|
|
# @user_tags = @subject.shixuns.map(&:user_tags_name).flatten.uniq
|
|
|
|
|
@user_tags = user_shixun_tags challenge_ids, @user.id
|
|
|
|
|
@my_subject_progress = @subject.my_subject_progress
|
|
|
|
|
# 访问数变更
|
|
|
|
|
@subject.increment!(:visits)
|
|
|
|
|
end
|
|
|
|
@ -149,7 +159,7 @@ class SubjectsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def choose_subject_shixun
|
|
|
|
|
@search = params[:search]
|
|
|
|
|
@search = params[:search].strip if params[:search]
|
|
|
|
|
@type = params[:type]
|
|
|
|
|
# 超级管理员用户显示所有未隐藏的实训、非管理员显示合作团队用户的实训(对本单位公开且未隐藏)
|
|
|
|
|
if current_user.admin?
|
|
|
|
@ -163,8 +173,9 @@ class SubjectsController < ApplicationController
|
|
|
|
|
tag_ids = @shixuns.joins(:shixun_tag_repertoires).pluck(:tag_repertoire_id).uniq
|
|
|
|
|
@tags = TagRepertoire.select([:id, :name]).where(id: tag_ids)
|
|
|
|
|
|
|
|
|
|
if params[:search]
|
|
|
|
|
@shixuns = @shixuns.where("name like ?", "%#{@search}%")
|
|
|
|
|
unless params[:search].blank?
|
|
|
|
|
@shixuns = @shixuns.joins(:user).where("shixuns.name like ? or concat(users.lastname, users.firstname) like ?",
|
|
|
|
|
"%#{@search}%", "%#{@search}%").distinct
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
unless @type.nil? || @type == "" || @type == "all"
|
|
|
|
|