|
|
|
@ -79,7 +79,7 @@ class Subjects::CopySubjectService < ApplicationService
|
|
|
|
|
copy_shixun_service_configs_data!(shixun, to_shixun)
|
|
|
|
|
copy_challenges_data!(shixun, to_shixun)
|
|
|
|
|
copy_shixun_members_data!(to_shixun)
|
|
|
|
|
|
|
|
|
|
copy_jupyter_data_sets(shixun, to_shixun) if shixun.is_jupyter?
|
|
|
|
|
# 云上实验室
|
|
|
|
|
if laboratory
|
|
|
|
|
laboratory.laboratory_shixuns.create(shixun: to_shixun)
|
|
|
|
@ -87,6 +87,25 @@ class Subjects::CopySubjectService < ApplicationService
|
|
|
|
|
to_shixun
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 复制jupyter的数据集
|
|
|
|
|
def copy_jupyter_data_sets(shixun, to_shixun)
|
|
|
|
|
return unless shixun.is_jupyter?
|
|
|
|
|
folder = EduSetting.get('shixun_folder')
|
|
|
|
|
raise "存储目录未定义" unless folder.present?
|
|
|
|
|
path = "#{folder}/#{to_shixun.identifier}"
|
|
|
|
|
FileUtils.mkdir_p(path, :mode => 0777) unless File.directory?(path)
|
|
|
|
|
# 复制数据集
|
|
|
|
|
save_path = File.join(folder, shixun.identifier)
|
|
|
|
|
shixun.data_sets.each do |set|
|
|
|
|
|
new_date_set = Attachment.new
|
|
|
|
|
new_date_set.attributes = set.attributes.dup.except("id", "container_id", "disk_directory")
|
|
|
|
|
new_date_set.container_id = to_shixun.id
|
|
|
|
|
new_date_set.disk_directory = to_shixun.identifier
|
|
|
|
|
new_date_set.save!
|
|
|
|
|
FileUtils.cp("#{save_path}/#{set.relative_path_filename}", path)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 创建实训长字段内容
|
|
|
|
|
def copy_shixun_info_data!(shixun, to_shixun)
|
|
|
|
|
to_shixun_info = ShixunInfo.new
|
|
|
|
|