|
|
@ -555,21 +555,21 @@ class ShixunsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
# 判断实训是否全为选择题
|
|
|
|
# 判断实训是否全为选择题
|
|
|
|
is_choice_type = (min_challenges.size == min_challenges.select{|challenge| challenge.last == 1}.count)
|
|
|
|
is_choice_type = (min_challenges.size == min_challenges.select{|challenge| challenge.last == 1}.count)
|
|
|
|
if !is_choice_type
|
|
|
|
# if !is_choice_type
|
|
|
|
commit = GitService.commits(repo_path: @repo_path).try(:first)
|
|
|
|
# commit = GitService.commits(repo_path: @repo_path).try(:first)
|
|
|
|
uid_logger("First comit########{commit}")
|
|
|
|
# uid_logger("First comit########{commit}")
|
|
|
|
tip_exception("开启实战前请先在版本库中提交代码") if commit.blank?
|
|
|
|
# tip_exception("开启实战前请先在版本库中提交代码") if commit.blank?
|
|
|
|
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(excellent: 1, id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id)).take
|
|
|
|
subject = Subject.where(excellent: 1, id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id)).take
|
|
|
|
if subject.courses.exists?("start_date is not null and start_date <= #{Date.today} and end_date is not null and end_date >= #{Date.today}")
|
|
|
|
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)
|
|
|
|
unless 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)
|
|
|
|
CourseMember.create(course_id: course.id, user_id: current_user.id, role: 4)
|
|
|
|
end
|
|
|
|
CourseAddStudentCreateWorksJob.perform_later(course.id, [current_user.id])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|