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

dev_jupyter
杨树林 5 years ago
commit d678ecb39c

@ -23,19 +23,21 @@ class ApplicationController < ActionController::Base
# 所有请求必须合法签名
def check_sign
Rails.logger.info("66666 #{params}")
suffix = request.url.split(".").last.split("?").first
suffix_arr = ["xls", "xlsx", "pdf"] # excel文件先注释
unless suffix_arr.include?(suffix)
if params[:client_key].present?
randomcode = params[:randomcode]
# tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5)
sign = Digest::MD5.hexdigest("#{OPENKEY}#{randomcode}")
Rails.logger.info("2222 #{sign}")
tip_exception(501, "请求不合理") if sign != params[:client_key]
else
tip_exception(501, "请求不合理")
unless Rails.env.development?
Rails.logger.info("66666 #{params}")
suffix = request.url.split(".").last.split("?").first
suffix_arr = ["xls", "xlsx", "pdf"] # excel文件先注释
unless suffix_arr.include?(suffix)
if params[:client_key].present?
randomcode = params[:randomcode]
# tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5)
sign = Digest::MD5.hexdigest("#{OPENKEY}#{randomcode}")
Rails.logger.info("2222 #{sign}")
tip_exception(501, "请求不合理") if sign != params[:client_key]
else
tip_exception(501, "请求不合理")
end
end
end
end

@ -140,8 +140,8 @@ class GraduationTopicsController < ApplicationController
update_graduation_topic_status
# 拒绝后将该学生移动到未分班中
student_member = @course.course_members.where(:user_id => student_graduation_topic.user_id).first
student_member.update_attributes(:course_group_id => 0) if student_member.present?
# student_member = @course.course_members.where(:user_id => student_graduation_topic.user_id).first
# student_member.update_attributes(:course_group_id => 0) if student_member.present?
student_graduation_topic.tidings.update_all(:status => 1)
Tiding.create(:user_id => student_graduation_topic.user_id, :trigger_user_id => current_user.id,

@ -48,20 +48,17 @@ class HacksController < ApplicationController
hack = Hack.new(hack_params)
hack.user_id = current_user.id
hack.identifier = generate_identifier Hack, 8
tag_params =
params[:tags].each do |tag|
{tag_discipline_id: tag}
end
tag_params = params[:tags].map{|tag| {tag_discipline_id: tag}}
ActiveRecord::Base.transaction do
hack.save!
# 创建测试集与代码
hack.hack_sets.create!(hack_sets_params)
# 新建知识点
hack.tag_discipline_containers.create!(tag_params) if tag_params
hack.tag_discipline_containers.create!(tag_params) if tag_params.present?
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})
new_item_params = item_params.merge(container: hack, item_type: 'PROGRAM', difficulty: params[:hack][:difficult], user_id: current_user.id)
ItemBank.create!(new_item_params)
end
render_ok({identifier: hack.identifier})
@ -76,10 +73,7 @@ class HacksController < ApplicationController
# 知识点
tag_discipline_ids = @hack.tag_discipline_containers.pluck(:tag_discipline_id)
new_tag_ids = params[:tags].to_a - tag_discipline_ids
tag_params =
new_tag_ids.each do |tag|
{tag_discipline_id: tag}
end
tag_params = new_tag_ids.map{|tag| {tag_discipline_id: tag}}
ActiveRecord::Base.transaction do
@hack.update_attributes!(hack_params)
set_ids = @hack.hack_sets.pluck(:id)
@ -95,7 +89,7 @@ class HacksController < ApplicationController
# 更新题库相关记录
if @hack.item_bank.present?
update_item_params = item_params.merge({difficulty: params[:difficult]})
update_item_params = item_params.merge({difficulty: params[:hack][:difficult]})
@hack.item_bank.update!(update_item_params)
end
end
@ -194,7 +188,7 @@ class HacksController < ApplicationController
end
def hack_params
params.require(:hack).permit(:name, :description, :difficult, :category, :open_or_not, :time_limit, :score, :sub_discipline_id)
params.require(:hack).permit(:name, :description, :difficult, :open_or_not, :time_limit, :score, :sub_discipline_id)
end
def item_params

@ -7,7 +7,7 @@ class ItemBanksController < ApplicationController
def index
items = ItemBankQuery.call(params)
@items_count = items.size
@items = paginate items.includes(:item_analysis, :user)
@items = paginate items.includes(:item_analysis, :user, :container)
@item_basket_ids = current_user.item_baskets.pluck(:item_bank_id)
end

@ -16,7 +16,7 @@ class Hack < ApplicationRecord
# 消息
has_many :tidings, as: :container
# 知识点
has_many :tag_discipline_containers, dependent: :destroy
has_many :tag_discipline_containers, as: :container, dependent: :destroy
belongs_to :user
belongs_to :sub_discipline

@ -4,3 +4,8 @@ json.choices item.item_choices do |choice|
json.choice_text choice.choice_text
json.is_answer choice.is_answer
end
if item.item_type == "PROGRAM"
json.program_attr do
json.(item.container, :description, :language, :difficult)
end
end

@ -382,6 +382,7 @@ class Challengesjupyter extends Component {
setTimeout(()=>{
this.setState({
jupyter_url :response.data.url,
jupyter_port:response.data.port,
booljupyterurls:true,
})
},500);

@ -204,7 +204,7 @@ export const saveJupyterTpi = () => {
payload: false
});
});
}, 500)
}, 800)
}
}

Loading…
Cancel
Save