导出实训

chromesetting
daiao 5 years ago
parent 7efd52bf22
commit 3dbca55557

@ -65,7 +65,7 @@ class Admins::ShixunSettingsController < Admins::BaseController
sheet1.row(0).default_format = blue sheet1.row(0).default_format = blue
sheet1.row(0).concat(["实训ID","实训名称","技术平台", "Fork源", "实践任务","选择题任务","挑战人数", "通关人数", "状态","创建者", "单位", "职业", "关卡序号","关卡名称","技能标签"]) sheet1.row(0).concat(["实训ID","实训名称","技术平台", "Fork源", "实践任务","选择题任务","挑战人数", "通关人数", "状态","创建者", "单位", "职业", "关卡序号","关卡名称","技能标签"])
count_row = 1 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, 0] = shixun.identifier
sheet1[count_row, 1] = shixun.name sheet1[count_row, 1] = shixun.name
sheet1[count_row, 2] = shixun.mirror_repositories.select{|mr| mr.main_type == "1"}.first&.type_name sheet1[count_row, 2] = shixun.mirror_repositories.select{|mr| mr.main_type == "1"}.first&.type_name

@ -28,6 +28,7 @@ class Shixun < ApplicationRecord
has_one :first_tag_repertoire, through: :first_shixun_tag_repertoire, source: :tag_repertoire has_one :first_tag_repertoire, through: :first_shixun_tag_repertoire, source: :tag_repertoire
has_many :homework_commons_shixuns, class_name: 'HomeworkCommonsShixun' 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 has_many :exercise_shixun_challenges, :dependent => :destroy
@ -97,7 +98,7 @@ class Shixun < ApplicationRecord
end end
def fork_identifier 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 end
def shixun_status def shixun_status
@ -171,7 +172,7 @@ class Shixun < ApplicationRecord
end end
def owner def owner
User.find(self.user_id) User.find_by_id(self.user_id)
end end
def shixun_main_name def shixun_main_name

@ -27,7 +27,7 @@
<%= raw '<br/>' if weappImageExists %> <%= raw '<br/>' 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' } %> <%= 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' } %>
</td> </td>
<td><%= link_to shixun.owner.try(:real_name),"/users/#{shixun.owner.login}",target:'_blank' %></td> <td><%= link_to shixun.owner.try(:real_name),"/users/#{shixun.owner&.login}",target:'_blank' %></td>
<td> <td>
<% if shixun.status.to_i < 3 %> <% if shixun.status.to_i < 3 %>
<%= link_to "关闭", admins_shixun_setting_path(shixun,status:3,page_no:page_no),method: :put, :class => "", :remote => true %> <%= link_to "关闭", admins_shixun_setting_path(shixun,status:3,page_no:page_no),method: :put, :class => "", :remote => true %>

Loading…
Cancel
Save