local to shixun

dev_local
jingquan huang 6 years ago
parent 59ff646a4f
commit 98c5bcca6e

@ -73,7 +73,7 @@ class WelcomeController < ApplicationController
if shixun.challenges.present? if shixun.challenges.present?
shixun.challenges.each do |challenge| shixun.challenges.each do |challenge|
new_challenge = LocalChallenge.new new_challenge = LocalChallenge.new
new_challenge.attributes = challenge.attributes.dup.except("id","shixun_id","user_id") new_challenge.attributes = challenge.attributes.dup.except("id","shixun_id","user_id", "test_set_score")
new_challenge.local_shixun_id = local_shixun.id new_challenge.local_shixun_id = local_shixun.id
new_challenge.save! new_challenge.save!
# 评测题,选择题暂时不考虑 # 评测题,选择题暂时不考虑
@ -109,6 +109,7 @@ class WelcomeController < ApplicationController
def local_to_shixun def local_to_shixun
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
shixun_list = []
LocalShixun.find_each do |local_shixun| LocalShixun.find_each do |local_shixun|
identifier = generate_identifier identifier = generate_identifier
shixun = Shixun.create!(name: local_shixun.name, description: local_shixun.description, user_id: User.current.id, shixun = Shixun.create!(name: local_shixun.name, description: local_shixun.description, user_id: User.current.id,
@ -177,8 +178,9 @@ class WelcomeController < ApplicationController
end end
end end
end end
render :json => {status: 0, message: "success", identifier: shixun.identifier} shixun_list << shixun.identifier
end end
render :json => {status: 0, message: "success", identifier: shixun_list}
end end
end end

Loading…
Cancel
Save