dev_hs
杨树明 6 years ago
commit 3512917c5b

@ -562,16 +562,16 @@ class ShixunsController < ApplicationController
commit_id = commit["id"]
end
# 如果该实训是金课中的实训,则将当前用户加入到当期开课的课
# if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1))
# subject = Subject.where(excellent: 1, id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id)).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)
# # 为了不影响后续操作用create而不是create!
# CourseMember.create(course_id: course.id, user_id: current_user.id, role: 4)
# CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id])
# end
# end
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)
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)
# 为了不影响后续操作用create而不是create!
CourseMember.create(course_id: course.id, user_id: current_user.id, role: 4)
CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id])
end
end
ActiveRecord::Base.transaction do
begin

@ -149,7 +149,7 @@ class SubjectsController < ApplicationController
end
def choose_subject_shixun
@search = params[:search]
@search = params[:search].strip
@type = params[:type]
# 超级管理员用户显示所有未隐藏的实训、非管理员显示合作团队用户的实训(对本单位公开且未隐藏)
if current_user.admin?
@ -163,7 +163,7 @@ class SubjectsController < ApplicationController
tag_ids = @shixuns.joins(:shixun_tag_repertoires).pluck(:tag_repertoire_id).uniq
@tags = TagRepertoire.select([:id, :name]).where(id: tag_ids)
if params[:search]
unless @search.blank?
@shixuns = @shixuns.where("name like ?", "%#{@search}%")
end

@ -21,7 +21,7 @@ class Subject < ApplicationRecord
# 开放课堂
has_many :courses, -> { order("courses.id ASC") }
validates :name, length: { maximum: 40 }
validates :name, length: { maximum: 60 }
validates :description, length: { maximum: 5000 }
validates :learning_notes, length: { maximum: 500 }

@ -75,7 +75,19 @@ class Elearning extends Component{
};
//开始学习
Startlearning=()=>{
this.Tojoinclass();
let {userlogin} = this.state;
if (userlogin === undefined) {
this.setState({
isRender: true
})
return
}
if (userlogin === "") {
this.setState({
isRender: true
})
return;
}
if(this.props.isNotMember()===true){
this.setState({
yslJointhe:true
@ -221,20 +233,10 @@ class Elearning extends Component{
})
};
Tojoinclass=()=> {
let {userlogin} = this.state;
if (userlogin === undefined) {
this.setState({
isRender: true
})
return
}
if (userlogin === "") {
this.setState({
isRender: true
})
return;
}
}
};
render(){
let{description,whethertoedit,isSpin,start_learning,hidestartshixunsreplacevalues,learned,last_shixun,stages,isRender} =this.state;

@ -34,13 +34,30 @@ class YslDetailCards extends Component{
};
startgameid=(id)=>{
// 上面传过来的方法是用来没登入弹出弹框的
this.props.Tojoinclass();
try {
let {userlogin} = this.props;
if (userlogin === undefined) {
this.props.Tojoinclass();
return
}
if (userlogin === "") {
this.props.Tojoinclass();
return;
}
}catch (e) {
if(this.props.isNotMember()===true){
//这个是外部传过来的
this.props.Startlearningtwo();
return
}
try {
if(this.props.isNotMember()===true){
//这个是外部传过来的
this.props.Startlearningtwo();
return
}
}catch (e) {
}
let url = "/shixuns/" + id + "/shixun_exec.json";
axios.get(url).then((response) => {

Loading…
Cancel
Save