Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
cxt 5 years ago
commit 3f933be7dd

@ -488,17 +488,19 @@ class ShixunsController < ApplicationController
tip_show_exception(-3, "#{@shixun.opening_time.strftime('%Y-%m-%d %H:%M:%S')}") tip_show_exception(-3, "#{@shixun.opening_time.strftime('%Y-%m-%d %H:%M:%S')}")
end end
current_myshixun = @shixun.current_myshixun(current_user.id) current_myshixun = @shixun.current_myshixun(current_user.id)
min_challenges = @shixun.challenges.pluck(:id , :st)
if current_myshixun if current_myshixun
games = current_myshixun.games
# 如果TPM和TPI的管卡数不相等或者关卡顺序错了说明实训被极大的改动需要重置 # 如果TPM和TPI的管卡数不相等或者关卡顺序错了说明实训被极大的改动需要重置
if current_myshixun.games.count != @shixun.challenges_count || if games.size != min_challenges.size || games.map(&:challenge_id) != min_challenges.map{|challenge| challenge.first}
current_myshixun.games.reorder(:challenge_id).pluck(:challenge_id) != @shixun.challenges.reorder(:id).pluck(:id)
uid_logger_error("7777777777777777#{current_myshixun.games.count}, #{@shixun.challenges_count}")
# 这里页面弹框要收到 当前用户myshixun的identifier. # 这里页面弹框要收到 当前用户myshixun的identifier.
tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game") tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game")
end end
# 如果存在实训,则直接进入实训 # 如果存在实训,则直接进入实训
@current_task = current_myshixun.current_task @current_task = current_myshixun.current_task(games)
else else
# 如果未创建关卡一定不能开启实训否则TPI没法找到当前的关卡 # 如果未创建关卡一定不能开启实训否则TPI没法找到当前的关卡
if @shixun.challenges_count == 0 if @shixun.challenges_count == 0
@ -506,10 +508,10 @@ class ShixunsController < ApplicationController
end end
# 判断实训是否全为选择题 # 判断实训是否全为选择题
is_choice_type = @shixun.is_choice_type? 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)
Rails.logger.info("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
@ -528,13 +530,13 @@ class ShixunsController < ApplicationController
# fork仓库 # fork仓库
project_fork(myshixun, @repo_path, current_user.login) project_fork(myshixun, @repo_path, current_user.login)
#rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path ) rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path )
#uid_logger("start openGameInstance") uid_logger("start openGameInstance")
#uri = "#{cloud_bridge}/bridge/game/openGameInstance" uri = "#{cloud_bridge}/bridge/game/openGameInstance"
#logger.info("end openGameInstance") logger.info("end openGameInstance")
#params = {tpiID: "#{myshixun.id}", tpmGitURL:rep_url, tpiRepoName: myshixun.repo_name.split("/").last} params = {tpiID: "#{myshixun.id}", tpmGitURL:rep_url, tpiRepoName: myshixun.repo_name.split("/").last}
#uid_logger("openGameInstance params is #{params}") uid_logger("openGameInstance params is #{params}")
# res = interface_post uri, params, 83, "实训云平台繁忙繁忙等级83" interface_post uri, params, 83, "实训云平台繁忙繁忙等级83"
end end
# 其它创建关卡等操作 # 其它创建关卡等操作
challenges = @shixun.challenges challenges = @shixun.challenges
@ -565,6 +567,7 @@ class ShixunsController < ApplicationController
end end
end end
end end
# gameID 及实训ID # gameID 及实训ID
# status: 0 , 1 申请过, 2实训关卡路径未填 3 实训标签未填, 4 实训未创建关卡 # status: 0 , 1 申请过, 2实训关卡路径未填 3 实训标签未填, 4 实训未创建关卡
def publish def publish

@ -39,6 +39,12 @@ class Discuss < ApplicationRecord
shixun.has_manager?(user) ? content : '' shixun.has_manager?(user) ? content : ''
end end
def child_discuss(user)
user.admin? ?
Discuss.where(parent_id: self.id).includes(:user).reorder(created_at: :asc) :
Discuss.where(parent_id: self.id, :hidden => false).includes(:user).reorder(created_at: :asc)
end
private private
def send_tiding def send_tiding

@ -53,14 +53,12 @@ class Myshixun < ApplicationRecord
end end
# 当前任务:一个实训中只可能一个未完成任务(status 0或1只会存在一条记录) # 当前任务:一个实训中只可能一个未完成任务(status 0或1只会存在一条记录)
# status:0 可以测评的,正在测评 # status:0 可以测评的; 1 正在测评的; 2评测通过的 3未开启
# 如果都完成,则当前任务为最后一个任务 # 如果都完成,则当前任务为最后一个任务
def current_task def current_task games
games = self.games
current_game = games.select{|game| game.status == 1 || game.status == 0}.first current_game = games.select{|game| game.status == 1 || game.status == 0}.first
if current_game.blank? if current_game.blank?
current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} current_game = games.last
and g.challenge_id = c.id and g.status = 2 order by c.position desc").first
end end
current_game current_game
end end

@ -33,7 +33,12 @@ class GitService
res = https.request(req) res = https.request(req)
body = res.body body = res.body
logger.info("--uri_exec: .....res is #{body}") logger.info("--uri_exec: .....res is #{body}")
content = JSON.parse(body) content = JSON.parse(body)
if content["code"] != 0
raise("版本库异常")
logger.error("repository error: #{content['msg']}")
end
#raise content["msg"] if content["code"] != 0 #raise content["msg"] if content["code"] != 0
content["data"] content["data"]

@ -2,7 +2,7 @@ json.author do
json.partial! 'users/user', user: discuss.user json.partial! 'users/user', user: discuss.user
end end
json.id discuss.id json.id discuss.id
json.content discuss.contents(container, current_user) json.content discuss.contents
json.time time_from_now(discuss.created_at) json.time time_from_now(discuss.created_at)
json.position discuss.position json.position discuss.position
json.shixun_id discuss.dis_id json.shixun_id discuss.dis_id

@ -2,8 +2,7 @@ json.disscuss_count @disscuss_count
json.all @current_user.admin? json.all @current_user.admin?
json.comments @discusses do |discuss| json.comments @discusses do |discuss|
json.partial! 'discusses/discuss', locals: { discuss: discuss, container: @container, current_user: @current_user } json.partial! 'discusses/discuss', locals: { discuss: discuss, container: @container, current_user: @current_user }
child_discuss = Discuss.children(discuss.id) json.children discuss.child_discuss(current_user) do |c_d|
json.children child_discuss do |c_d|
json.partial! 'discusses/discuss', locals: { discuss: c_d, container: @container, current_user: @current_user } json.partial! 'discusses/discuss', locals: { discuss: c_d, container: @container, current_user: @current_user }
end end
end end

Loading…
Cancel
Save