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 # job
gem 'sidekiq' gem 'sidekiq'
gem 'sinatra' gem 'sinatra'
gem "sidekiq-cron", "~> 1.1"
# batch insert # batch insert
gem 'bulk_insert' gem 'bulk_insert'

@ -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漫画
胡启立 胡启立
芮杏文 芮杏文
杨白冰 杨白冰
邹家华
谭绍文 谭绍文
王汉斌 王汉斌
任建新 任建新
@ -1378,5 +1377,3 @@ 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

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

Loading…
Cancel
Save