Merge remote-tracking branch 'origin/dev_Ysm' into dev_Ysm

dev_hs
杨树明 6 years ago
commit e9db30ace1

@ -152,7 +152,7 @@ class CoursesController < ApplicationController
end end
rescue => e rescue => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("课堂创建失败!") tip_exception(e.message)
raise ActiveRecord::Rollback raise ActiveRecord::Rollback
end end
end end

@ -562,9 +562,9 @@ class ShixunsController < ApplicationController
commit_id = commit["id"] commit_id = commit["id"]
end end
# 如果该实训是金课中的实训,则将当前用户加入到当期开课的课
if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1)) if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1))
subject = Subject.where(id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id), excellent: 1).take(1) subject = Subject.find_by(id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id), excellent: 1)
course = subject.courses.where("start_date is not null and start_date <= '#{Date.today}' and end_date is not null and end_date >= '#{Date.today}'").take course = subject.courses.where("start_date is not null and start_date <= '#{Date.today}' and end_date is not null and end_date >= '#{Date.today}'").take
if course.present? && !CourseMember.exists?(course_id: course.id, user_id: current_user.id) if course.present? && !CourseMember.exists?(course_id: course.id, user_id: current_user.id)
# 为了不影响后续操作用create而不是create! # 为了不影响后续操作用create而不是create!

@ -42,7 +42,7 @@ namespace :public_course do
begin begin
CourseMember.create!(course_id: course_id, user_id: user_id, role: 4) CourseMember.create!(course_id: course_id, user_id: user_id, role: 4)
rescue Exception => e rescue Exception => e
Rails.logger() Rails.logger(e.message)
end end
end end
end end
@ -68,12 +68,15 @@ namespace :public_course do
case type.to_i case type.to_i
when 1 when 1
# 讨论区 # 讨论区
created_on = random_time start_time, end_time
puts created_on
messages = Message.where(board_id: course.boards) messages = Message.where(board_id: course.boards)
messages.each do |message| messages.each do |message|
created_on = random_time start_time, end_time
puts created_on
message.update_columns(created_on: created_on, updated_on: created_on) message.update_columns(created_on: created_on, updated_on: created_on)
MessageDetail.where(message_id: message.id).update_all(created_at: created_on, updated_at: created_on) MessageDetail.where(message_id: message.id).each do |detail|
rand_created_on = random_time start_time, end_time
detail.update_columns(created_at: rand_created_on, updated_at: rand_created_on)
end
end end
when 2 when 2
# 作业 # 作业
@ -134,5 +137,4 @@ namespace :public_course do
end end
large_time large_time
end end
end end

@ -43,12 +43,18 @@ namespace :sync do
is_test: true is_test: true
} }
user = User.create!(edit_params) user = User.create!(edit_params)
puts "aa" user.password = "edu12345678"
user.save!
UserExtension.create!(user_id: user.id, school_id: 117) UserExtension.create!(user_id: user.id, school_id: 117)
puts i puts i
end end
end end
task :password => :environment do
end
# 随机生成字符 # 随机生成字符
def generate_identifier(container, num) def generate_identifier(container, num)
code = DCODES.sample(num).join code = DCODES.sample(num).join

Loading…
Cancel
Save