Merge branches 'dev_aliyun' and 'develop' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

courseware
杨树明 5 years ago
commit f9098b9154

@ -90,7 +90,6 @@ gem 'rails-i18n', '~> 5.1'
# job
gem 'sidekiq'
gem 'sinatra'
gem "sidekiq-cron", "~> 1.1"
# batch insert
gem 'bulk_insert'

@ -313,12 +313,15 @@ class ChallengesController < ApplicationController
end
rescue => e
tip_exception("上移失败: #{e.message}")
raise ActiveRecord::Rollback
end
end
def destroy
next_challenges = @shixun.challenges.where("position > #{@challenge.position}")
begin
ActiveRecord::Base.transaction do
next_challenges.update_all("position = position - 1")
# Todo: 实训修改后,关卡需要重置
# shixun_modify_status_without_publish(@shixun, 1)
@ -327,6 +330,11 @@ class ChallengesController < ApplicationController
script = modify_shixun_script @shixun, @shixun.evaluate_script
@shixun.shixun_info.update_column(:evaluate_script, script)
end
rescue => e
tip_exception("删除关卡失败: #{e.message}")
raise ActiveRecord::Rollback
end
end
private

@ -518,7 +518,6 @@ H漫画
胡启立
芮杏文
杨白冰
邹家华
谭绍文
王汉斌
任建新
@ -1378,5 +1377,3 @@ B样
傻 逼
真蠢
蠢猪

@ -1,5 +1,3 @@
require 'sidekiq/web'
require 'sidekiq/cron/web'
redis_config = Rails.application.config_for(:redis)
sidekiq_url = redis_config["url"]
@ -10,9 +8,3 @@ end
Sidekiq.configure_client do |config|
config.redis = { url: sidekiq_url }
end
schedule_file = "config/schedule.yml"
if File.exists?(schedule_file) && Sidekiq.server?
Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
end

@ -0,0 +1,31 @@
# 执行示例 bundle exec rake migrate_course_student_work:homework args=2933
desc "创建课堂学生的作业数据"
namespace :migrate_course_student_work do
if ENV['args']
course_id = ENV['args'].split(",")[0] # 对应课堂的id
end
task homework: :environment do
course = Course.find_by(id: course_id)
if course.present?
student_ids = course.students.pluck(:user_id)
# 如果之前存在相关作品则更新is_delete字段
student_works = StudentWork.joins(:homework_common).where(user_id: student_ids, homework_commons: {course_id: course.id})
student_works.update_all(is_delete: 0)
attrs = %i[homework_common_id user_id created_at updated_at]
StudentWork.bulk_insert(*attrs) do |worker|
student_ids.each do |user_id|
same_attrs = {user_id: user_id}
course.homework_commons.where(homework_type: %i[normal group practice]).each do |homework|
next if StudentWork.where(user_id: user_id, homework_common_id: homework.id).any?
worker.add same_attrs.merge(homework_common_id: homework.id)
end
end
end
end
end
end

@ -35,7 +35,8 @@ class Immediatelypublish extends Component{
modalsType:false,
modalsTopval:"",
loadtype:false,
chooseId:undefined
chooseId:undefined,
immediatelyopen:false
}
}
//立即发布
@ -73,6 +74,7 @@ class Immediatelypublish extends Component{
Saves:this.homeworkstartend,
course_groups:response.data.course_groups,
starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time,
immediatelyopen:response.data.course_groups===null||response.data.course_groups.length===0?false:true,
})
}
@ -100,6 +102,7 @@ class Immediatelypublish extends Component{
Saves:this.homeworkstartend,
course_groups:response.data.course_groups,
starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time,
immediatelyopen:response.data.course_groups===null||response.data.course_groups.length===0?false:true,
})
}
}).catch((error) => {
@ -386,6 +389,7 @@ class Immediatelypublish extends Component{
starttimes={this.state.starttimes}
starttimesend={this.state.starttimesend}
typs={this.state.typs}
immediatelyopen={this.state.immediatelyopen}
/>:""}
{/* 公用的提示弹框 */}

Loading…
Cancel
Save