diff --git a/app/controllers/admins/shixun_settings_controller.rb b/app/controllers/admins/shixun_settings_controller.rb
index 822bc2bdf..216c9d909 100644
--- a/app/controllers/admins/shixun_settings_controller.rb
+++ b/app/controllers/admins/shixun_settings_controller.rb
@@ -65,7 +65,7 @@ class Admins::ShixunSettingsController < Admins::BaseController
sheet1.row(0).default_format = blue
sheet1.row(0).concat(["实训ID","实训名称","技术平台", "Fork源", "实践任务","选择题任务","挑战人数", "通关人数", "状态","创建者", "单位", "职业", "关卡序号","关卡名称","技能标签"])
count_row = 1
- shixuns.includes(:challenges, :user, :myshixuns, :mirror_repositories).find_each do |shixun|
+ shixuns.includes(:fork_shixuns, :myshixuns, :mirror_repositories, challenges: [:challenge_tags], user: [user_extension: :school]).find_each do |shixun|
sheet1[count_row, 0] = shixun.identifier
sheet1[count_row, 1] = shixun.name
sheet1[count_row, 2] = shixun.mirror_repositories.select{|mr| mr.main_type == "1"}.first&.type_name
diff --git a/app/models/shixun.rb b/app/models/shixun.rb
index a0f88260b..e8aa1b186 100644
--- a/app/models/shixun.rb
+++ b/app/models/shixun.rb
@@ -28,6 +28,7 @@ class Shixun < ApplicationRecord
has_one :first_tag_repertoire, through: :first_shixun_tag_repertoire, source: :tag_repertoire
has_many :homework_commons_shixuns, class_name: 'HomeworkCommonsShixun'
+ has_many :fork_shixuns, foreign_key: "fork_from", class_name: 'Shixun'
#实训的关卡
has_many :exercise_shixun_challenges, :dependent => :destroy
@@ -97,7 +98,7 @@ class Shixun < ApplicationRecord
end
def fork_identifier
- self.fork_from.nil? ? "--" : Shixun.where(id: self.fork_from).first.try(:identifier)
+ self.fork_from.nil? ? "--" : fork_shixuns.first&.identifier
end
def shixun_status
@@ -171,7 +172,7 @@ class Shixun < ApplicationRecord
end
def owner
- User.find(self.user_id)
+ User.find_by_id(self.user_id)
end
def shixun_main_name
diff --git a/app/views/admins/shixun_settings/shared/_td.html.erb b/app/views/admins/shixun_settings/shared/_td.html.erb
index ddbbdff02..f4a05f178 100644
--- a/app/views/admins/shixun_settings/shared/_td.html.erb
+++ b/app/views/admins/shixun_settings/shared/_td.html.erb
@@ -27,7 +27,7 @@
<%= raw '
' if weappImageExists %>
<%= javascript_void_link weappImageExists ? '重新上传' : '上传图片', class: 'action upload-shixun-weapp-image-action', data: { source_id: shixun.id, source_type: 'Shixun', suffix: '_weapp', toggle: 'modal', target: '.admin-upload-file-modal' } %>
-