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

dev_local_2
杨树林 5 years ago
commit fc3d56c992

@ -386,10 +386,16 @@ class InitializationDataController < ApplicationController
# 获取关卡附件
def get_attachment_data
task_pass = Challenge.where(id: @challenges).where("task_pass like '%/api/attachments/%'").pluck(:task_pass)
shixun_description = ShixunInfo.where(id: @shixuns).where("description like '%/api/attachments/%'").pluck(:description)
att_ids = []
# 附件的格式为(/api/attachments/ + 附件id的形式因此下面的正文匹配是为了取出附件的id方便迁移attachments
task_pass.each do |tp|
att_ids += tp.scan(/\(\/api\/attachments\/.+\)/).map{|s|s.match(/\d+/)[0]}
att_ids += tp.scan(/\/api\/attachments\/.+\"/).map{|s|s.match(/\d+/)[0]}
end
shixun_description.each do |sd|
att_ids += sd.scan(/\(\/api\/attachments\/.+\)/).map{|s|s.match(/\d+/)[0]}
att_ids += sd.scan(/\/api\/attachments\/.+\"/).map{|s|s.match(/\d+/)[0]}
end
@attachments = Attachment.where(id: att_ids).to_a
end

@ -10,7 +10,7 @@ class QuestionBanksController < ApplicationController
def bank_list
page = params[:page] || 1
limit = params[:limit] || 15
@certification_teacher = current_user.is_teacher || current_user.admin?
@certification_teacher = current_user.is_teacher? || current_user.admin?
@objects = @object_type.classify.constantize.where(@object_filter)
@objects =
if params[:search]
@ -21,7 +21,7 @@ class QuestionBanksController < ApplicationController
#{@objects.table_name}.is_public = 1 and concat(#{@objects.table_name}.name, course_lists.name) like
'%#{params[:search]}%'
}
@objects.where(sql)
@objects.joins(:course_list).where(sql)
else
@objects.none
end
@ -30,7 +30,7 @@ class QuestionBanksController < ApplicationController
#{@objects.table_name}.user_id = #{current_user.id} and concat(#{@objects.table_name}.name, course_lists.name) like
'%#{params[:search]}%'
}
@objects.where(sql)
@objects.joins(:course_list).where(sql)
end
else
if params[:filter] == 'public'

Loading…
Cancel
Save