|
|
|
@ -610,29 +610,6 @@ class User < ApplicationRecord
|
|
|
|
|
admin? || business?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 149课程的评审用户数据创建(包含创建课堂学生)
|
|
|
|
|
def open_class_user
|
|
|
|
|
user = User.find_by(login: "OpenClassUser")
|
|
|
|
|
unless user
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
user_params = {status: 1, login: "OpenClassUser", lastname: "开放课程",
|
|
|
|
|
nickname: "开放课程", professional_certification: 1, certification: 1, grade: 0,
|
|
|
|
|
password: "12345678", phone: "11122223333", profile_completed: 1}
|
|
|
|
|
user = User.create!(user_params)
|
|
|
|
|
|
|
|
|
|
UserExtension.create!(user_id: user.id, gender: 0, school_id: 117, :identity => 1, :student_id => "openclassuser")
|
|
|
|
|
|
|
|
|
|
subject = Subject.find_by(id: 149)
|
|
|
|
|
if subject
|
|
|
|
|
subject.courses.each do |course|
|
|
|
|
|
CourseMember.create!(course_id: course.id, role: 4, user_id: user.id) if !course.course_students.exists?(user_id: user.id)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
user
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
def validate_password_length
|
|
|
|
|
# 管理员的初始密码是5位
|
|
|
|
|