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

dev_jupyter
杨树林 5 years ago
commit d678ecb39c

@ -23,6 +23,7 @@ class ApplicationController < ActionController::Base
# 所有请求必须合法签名 # 所有请求必须合法签名
def check_sign def check_sign
unless Rails.env.development?
Rails.logger.info("66666 #{params}") Rails.logger.info("66666 #{params}")
suffix = request.url.split(".").last.split("?").first suffix = request.url.split(".").last.split("?").first
suffix_arr = ["xls", "xlsx", "pdf"] # excel文件先注释 suffix_arr = ["xls", "xlsx", "pdf"] # excel文件先注释
@ -39,6 +40,7 @@ class ApplicationController < ActionController::Base
end end
end end
end end
end
# 全局配置参数 # 全局配置参数
# 返回name对应的value # 返回name对应的value

@ -140,8 +140,8 @@ class GraduationTopicsController < ApplicationController
update_graduation_topic_status update_graduation_topic_status
# 拒绝后将该学生移动到未分班中 # 拒绝后将该学生移动到未分班中
student_member = @course.course_members.where(:user_id => student_graduation_topic.user_id).first # 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.update_attributes(:course_group_id => 0) if student_member.present?
student_graduation_topic.tidings.update_all(:status => 1) student_graduation_topic.tidings.update_all(:status => 1)
Tiding.create(:user_id => student_graduation_topic.user_id, :trigger_user_id => current_user.id, 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 = Hack.new(hack_params)
hack.user_id = current_user.id hack.user_id = current_user.id
hack.identifier = generate_identifier Hack, 8 hack.identifier = generate_identifier Hack, 8
tag_params = tag_params = params[:tags].map{|tag| {tag_discipline_id: tag}}
params[:tags].each do |tag|
{tag_discipline_id: tag}
end
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
hack.save! hack.save!
# 创建测试集与代码 # 创建测试集与代码
hack.hack_sets.create!(hack_sets_params) 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 = hack.hack_codes.new(hack_code_params)
hack_codes.modify_time = Time.now hack_codes.modify_time = Time.now
hack_codes.save! 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) ItemBank.create!(new_item_params)
end end
render_ok({identifier: hack.identifier}) render_ok({identifier: hack.identifier})
@ -76,10 +73,7 @@ class HacksController < ApplicationController
# 知识点 # 知识点
tag_discipline_ids = @hack.tag_discipline_containers.pluck(:tag_discipline_id) tag_discipline_ids = @hack.tag_discipline_containers.pluck(:tag_discipline_id)
new_tag_ids = params[:tags].to_a - tag_discipline_ids new_tag_ids = params[:tags].to_a - tag_discipline_ids
tag_params = tag_params = new_tag_ids.map{|tag| {tag_discipline_id: tag}}
new_tag_ids.each do |tag|
{tag_discipline_id: tag}
end
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
@hack.update_attributes!(hack_params) @hack.update_attributes!(hack_params)
set_ids = @hack.hack_sets.pluck(:id) set_ids = @hack.hack_sets.pluck(:id)
@ -95,7 +89,7 @@ class HacksController < ApplicationController
# 更新题库相关记录 # 更新题库相关记录
if @hack.item_bank.present? 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) @hack.item_bank.update!(update_item_params)
end end
end end
@ -194,7 +188,7 @@ class HacksController < ApplicationController
end end
def hack_params 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 end
def item_params def item_params

@ -7,7 +7,7 @@ class ItemBanksController < ApplicationController
def index def index
items = ItemBankQuery.call(params) items = ItemBankQuery.call(params)
@items_count = items.size @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) @item_basket_ids = current_user.item_baskets.pluck(:item_bank_id)
end end

@ -16,7 +16,7 @@ class Hack < ApplicationRecord
# 消息 # 消息
has_many :tidings, as: :container 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 :user
belongs_to :sub_discipline belongs_to :sub_discipline

@ -4,3 +4,8 @@ json.choices item.item_choices do |choice|
json.choice_text choice.choice_text json.choice_text choice.choice_text
json.is_answer choice.is_answer json.is_answer choice.is_answer
end 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(()=>{ setTimeout(()=>{
this.setState({ this.setState({
jupyter_url :response.data.url, jupyter_url :response.data.url,
jupyter_port:response.data.port,
booljupyterurls:true, booljupyterurls:true,
}) })
},500); },500);

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

Loading…
Cancel
Save