dev_hs
cxt 6 years ago
parent de30ae0cd9
commit 7d49c25d4b

@ -240,7 +240,7 @@ class ApplicationController < ActionController::Base
uid_logger("user_setup: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous"))
if !User.current.logged? && Rails.env.development?
User.current = User.find 12
User.current = User.find 1
end

@ -992,13 +992,15 @@ class HomeworkCommonsController < ApplicationController
@total_count = @subjects.size
if reorder != "myshixun_count"
@subjects = @subjects.page(page).per(limit).includes(:shixuns, user: [user_extension: :school])
# @subjects = @subjects.page(page).per(limit).includes(:shixuns, user: [user_extension: :school])
@subjects = @subjects.page(page).per(limit).includes(:shixuns)
else
@subjects = @subjects[offset, limit]
unless @subjects.blank?
subject_ids = @subjects.pluck(:id)
order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1
@subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, user: [user_extension: :school])
# @subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, user: [user_extension: :school])
@subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns)
end
end
end

@ -87,14 +87,6 @@ class SubjectsController < ApplicationController
@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

@ -6,12 +6,12 @@ end
json.subject_list @subjects do |subject|
json.subject_id subject.id
json.subject_name subject.name
json.challenge_tags subject.shixun_tags
# json.challenge_tags subject.shixun_tags
json.shixun_count subject.shixuns.unhidden.size
json.myshixun_count subject.shixuns.pluck(:myshixuns_count).sum
json.creator subject.user&.full_name
json.creator_login subject.user&.login
json.school subject.user&.school_name
# json.creator subject.user&.full_name
# json.creator_login subject.user&.login
# json.school subject.user&.school_name
end
json.subjects_count @total_count

@ -23,26 +23,4 @@ if @subject.excellent
json.course_identity @user.course_identity(course)
json.course_status subject_course_status course
end
end
json.members @members do |member|
json.partial! 'subject_member', locals: { user: member.user }
json.role member.role
end
# 技能标签
json.tags @tags do |tag|
unless tag.blank?
json.tag_name tag
json.status @user_tags.include?(tag)
end
end
# 我的进展
json.progress do
json.my_score @subject.my_subject_score
json.all_score @subject.all_score
json.learned @subject.my_subject_progress
json.time @subject.my_consume_time
end
Loading…
Cancel
Save