|
|
|
@ -61,6 +61,8 @@ class HacksController < ApplicationController
|
|
|
|
|
hack_codes = hack.hack_codes.new(hack_code_params)
|
|
|
|
|
hack_codes.modify_time = Time.now
|
|
|
|
|
hack_codes.save!
|
|
|
|
|
new_item_params = item_params.merge({container: hack, item_type: 'PROGRAM', difficulty: params[:difficult], user_id: current_user.id})
|
|
|
|
|
ItemBank.create!(new_item_params)
|
|
|
|
|
end
|
|
|
|
|
render_ok({identifier: hack.identifier})
|
|
|
|
|
rescue Exception => e
|
|
|
|
@ -90,6 +92,12 @@ class HacksController < ApplicationController
|
|
|
|
|
@hack.hack_codes.first.update_attributes!(code_params)
|
|
|
|
|
@hack.tag_discipline_containers.create!(tag_params) if tag_params
|
|
|
|
|
@hack.tag_discipline_containers.where.not(tag_discipline_id: params[:tags]).destroy_all
|
|
|
|
|
|
|
|
|
|
# 更新题库相关记录
|
|
|
|
|
if @hack.item_bank.present?
|
|
|
|
|
update_item_params = item_params.merge({difficulty: params[:difficult]})
|
|
|
|
|
@hack.item_bank.update!(update_item_params)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
render_ok
|
|
|
|
|
rescue Exception => e
|
|
|
|
@ -189,6 +197,10 @@ class HacksController < ApplicationController
|
|
|
|
|
params.require(:hack).permit(:name, :description, :difficult, :category, :open_or_not, :time_limit, :score, :sub_discipline_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def item_params
|
|
|
|
|
params.require(:hack).permit(:name, :sub_discipline_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def hack_sets_params
|
|
|
|
|
params.permit(hack_sets: [:input, :output, :position])[:hack_sets]
|
|
|
|
|
end
|
|
|
|
|