diff --git a/Gemfile b/Gemfile index 26767b091..f9d9e3c06 100644 --- a/Gemfile +++ b/Gemfile @@ -90,7 +90,6 @@ gem 'rails-i18n', '~> 5.1' # job gem 'sidekiq' gem 'sinatra' -gem "sidekiq-cron", "~> 1.1" # batch insert gem 'bulk_insert' @@ -113,4 +112,4 @@ gem 'request_store' # 敏感词汇 gem 'harmonious_dictionary', '~> 0.0.1' -gem 'parallel', '~> 1.19', '>= 1.19.1' +gem 'parallel', '~> 1.19', '>= 1.19.1' \ No newline at end of file diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 762943183..44fa18f56 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -313,19 +313,27 @@ 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}") - next_challenges.update_all("position = position - 1") - # Todo: 实训修改后,关卡需要重置 - # shixun_modify_status_without_publish(@shixun, 1) - @challenge.destroy - # 关卡位置被删除,需要修改脚本 - script = modify_shixun_script @shixun, @shixun.evaluate_script - @shixun.shixun_info.update_column(:evaluate_script, script) + begin + ActiveRecord::Base.transaction do + next_challenges.update_all("position = position - 1") + # Todo: 实训修改后,关卡需要重置 + # shixun_modify_status_without_publish(@shixun, 1) + @challenge.destroy + # 关卡位置被删除,需要修改脚本 + 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 diff --git a/config/harmonious_dictionary/chinese_dictionary.txt b/config/harmonious_dictionary/chinese_dictionary.txt index 2bd91e8d2..fd7278dfc 100644 --- a/config/harmonious_dictionary/chinese_dictionary.txt +++ b/config/harmonious_dictionary/chinese_dictionary.txt @@ -518,7 +518,6 @@ H漫画 胡启立 芮杏文 杨白冰 -邹家华 谭绍文 王汉斌 任建新 @@ -1377,6 +1376,4 @@ B样 垃 圾 傻 逼 真蠢 -蠢猪 - - +蠢猪 \ No newline at end of file diff --git a/config/harmonious_dictionary/harmonious.hash b/config/harmonious_dictionary/harmonious.hash index 67e985d4c..8d906ec53 100644 Binary files a/config/harmonious_dictionary/harmonious.hash and b/config/harmonious_dictionary/harmonious.hash differ diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 90dedac1b..b3f2d0576 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -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 \ No newline at end of file diff --git a/lib/tasks/migrate_course_student_work.rake b/lib/tasks/migrate_course_student_work.rake new file mode 100644 index 000000000..c795a49ce --- /dev/null +++ b/lib/tasks/migrate_course_student_work.rake @@ -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 diff --git a/lib/tasks/sync_video.rake b/lib/tasks/sync_video.rake new file mode 100644 index 000000000..e69de29bb diff --git a/public/react/src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js b/public/react/src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js index f10474fdf..933ca1996 100644 --- a/public/react/src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js +++ b/public/react/src/modules/courses/poll/pollPublicBtn/ImmediatelyPublish.js @@ -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} />:""} {/* 公用的提示弹框 */}