Merge branch 'dev_item_bank' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_item_bank

dev_jupyter
杨树林 5 years ago
commit 3484f08ed5

@ -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

@ -21,6 +21,8 @@ class Hack < ApplicationRecord
belongs_to :user
belongs_to :sub_discipline
has_one :item_bank, as: :container, dependent: :destroy
scope :published, -> { where(status: 1) }
scope :unpublish, -> { where(status: 0) }
scope :opening, -> {where(open_or_not: 1)}

@ -12,6 +12,8 @@ class ItemBank < ApplicationRecord
has_many :tag_discipline_containers, as: :container, dependent: :destroy
has_many :tag_disciplines, through: :tag_discipline_containers
belongs_to :container, polymorphic: true, optional: true
def analysis
item_analysis&.analysis
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Loading…
Cancel
Save