|
|
|
@ -7,7 +7,7 @@ namespace :sync_program do
|
|
|
|
|
unless Hack.where(name: program.name).exists?
|
|
|
|
|
strip_des = strip_html(program.description, 5000)
|
|
|
|
|
description = strip_des.present? ? strip_des : program.name
|
|
|
|
|
hack_params = {name: program.name[0..59], description: description, difficult: 1, open_or_not: 1, score: 200, sub_discipline_id: program.oj_sub_discipline_id}
|
|
|
|
|
hack_params = {name: program.name[0..59], description: description, difficult: 1, open_or_not: 1, score: 200, status:0, time_limit: 3, sub_discipline_id: program.oj_sub_discipline_id}
|
|
|
|
|
puts "language::::#{program.language}"
|
|
|
|
|
puts "program_bank::::#{program.id}"
|
|
|
|
|
hack = Hack.new(hack_params)
|
|
|
|
@ -24,11 +24,11 @@ namespace :sync_program do
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
# 新建知识点
|
|
|
|
|
hack_code_params = {code: program.standard_code, language: program.oj_language}
|
|
|
|
|
hack_code_params = {code: Base64.encode64(program.standard_code), language: program.oj_language}
|
|
|
|
|
hack_codes = hack.hack_codes.new(hack_code_params)
|
|
|
|
|
hack_codes.modify_time = Time.now
|
|
|
|
|
hack_codes.save!
|
|
|
|
|
new_item_params = {name: program.name, sub_discipline_id: program.oj_sub_discipline_id, container: hack, item_type: 'PROGRAM', public: 1, difficulty: 1, user_id: 1}
|
|
|
|
|
new_item_params = {name: program.name, sub_discipline_id: program.oj_sub_discipline_id, container: hack, item_type: 'PROGRAM', public: 0, difficulty: 1, user_id: 1}
|
|
|
|
|
ItemBank.create!(new_item_params)
|
|
|
|
|
end
|
|
|
|
|
puts hack.id
|
|
|
|
|