Merge branch 'develop' into dev_aliyun

courseware
cxt 5 years ago
commit 8fbac7b54e

@ -90,7 +90,6 @@ gem 'rails-i18n', '~> 5.1'
# job # job
gem 'sidekiq' gem 'sidekiq'
gem 'sinatra' gem 'sinatra'
gem "sidekiq-cron", "~> 1.1"
# batch insert # batch insert
gem 'bulk_insert' gem 'bulk_insert'
@ -113,4 +112,4 @@ gem 'request_store'
# 敏感词汇 # 敏感词汇
gem 'harmonious_dictionary', '~> 0.0.1' gem 'harmonious_dictionary', '~> 0.0.1'
gem 'parallel', '~> 1.19', '>= 1.19.1' gem 'parallel', '~> 1.19', '>= 1.19.1'

@ -313,19 +313,27 @@ class ChallengesController < ApplicationController
end end
rescue => e rescue => e
tip_exception("上移失败: #{e.message}") tip_exception("上移失败: #{e.message}")
raise ActiveRecord::Rollback
end end
end end
def destroy def destroy
next_challenges = @shixun.challenges.where("position > #{@challenge.position}") next_challenges = @shixun.challenges.where("position > #{@challenge.position}")
next_challenges.update_all("position = position - 1") begin
# Todo: 实训修改后,关卡需要重置 ActiveRecord::Base.transaction do
# shixun_modify_status_without_publish(@shixun, 1) next_challenges.update_all("position = position - 1")
@challenge.destroy # Todo: 实训修改后,关卡需要重置
# 关卡位置被删除,需要修改脚本 # shixun_modify_status_without_publish(@shixun, 1)
script = modify_shixun_script @shixun, @shixun.evaluate_script @challenge.destroy
@shixun.shixun_info.update_column(:evaluate_script, script) # 关卡位置被删除,需要修改脚本
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 end

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

@ -1,5 +1,3 @@
require 'sidekiq/web'
require 'sidekiq/cron/web'
redis_config = Rails.application.config_for(:redis) redis_config = Rails.application.config_for(:redis)
sidekiq_url = redis_config["url"] sidekiq_url = redis_config["url"]
@ -10,9 +8,3 @@ end
Sidekiq.configure_client do |config| Sidekiq.configure_client do |config|
config.redis = { url: sidekiq_url } config.redis = { url: sidekiq_url }
end 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
Loading…
Cancel
Save