|
|
|
@ -61,29 +61,7 @@ class GamesController < ApplicationController
|
|
|
|
|
tomcat_url: edu_setting('cloud_tomcat_php'), is_teacher: is_teacher,
|
|
|
|
|
myshixun_manager: myshixun_manager, git_url: (@shixun.vnc ? repo_url(@myshixun.repo_path) : "")}
|
|
|
|
|
if @shixun.vnc
|
|
|
|
|
begin
|
|
|
|
|
shixun_tomcat = edu_setting('cloud_bridge')
|
|
|
|
|
service_host = edu_setting('vnc_url')
|
|
|
|
|
uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
|
|
|
|
|
params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}"}
|
|
|
|
|
res = uri_post uri, params
|
|
|
|
|
logger.info("###############---- ")
|
|
|
|
|
if res && res['code'].to_i != 0
|
|
|
|
|
raise("实训云平台繁忙(繁忙等级:99)")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if request.subdomain == "pre-newweb"
|
|
|
|
|
# 无域名版本
|
|
|
|
|
@vnc_url = "http://#{service_host}:#{res['port']}/vnc_lite.html?password=headless"
|
|
|
|
|
else
|
|
|
|
|
# 有域名版本
|
|
|
|
|
@vnc_url = "https://#{res['port']}.#{service_host}/vnc_lite.html?password=headless"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@vnc_evaluate = @shixun.vnc_evaluate
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
Rails.logger.error(e.message)
|
|
|
|
|
end
|
|
|
|
|
get_vnc_link(@game)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 区分选择题和编程题,st:0编程题;
|
|
|
|
@ -110,6 +88,21 @@ class GamesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def reset_vnc_link
|
|
|
|
|
begin
|
|
|
|
|
# 删除vnc的pod
|
|
|
|
|
delete_vnc(@game)
|
|
|
|
|
# 重新连接
|
|
|
|
|
get_vnc_link(@game)
|
|
|
|
|
|
|
|
|
|
render :json => {status: 1, message: "重置VNC成功", data: {vnc_url: @vnc_url, vnc_evaluate: @vnc_evaluate}}
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
logger.error("############'#{e.message}'")
|
|
|
|
|
tip_exception("实训云平台繁忙")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 查看效果
|
|
|
|
|
# todo : 这块代码有很大的改进空间
|
|
|
|
|
# todo : 中文排序问题
|
|
|
|
@ -880,7 +873,7 @@ class GamesController < ApplicationController
|
|
|
|
|
choose.challenge_questions.each do |question|
|
|
|
|
|
position = question.position
|
|
|
|
|
option_name = question.option_name
|
|
|
|
|
challenge_question << {:positon => position, :option_name => option_name}
|
|
|
|
|
challenge_question <<{:positon => position, :option_name => option_name}
|
|
|
|
|
end
|
|
|
|
|
# actual_output为空表示暂时没有评测答题,不允许查看
|
|
|
|
|
actual_output = output.try(:actual_output).try(:strip)
|
|
|
|
@ -941,4 +934,47 @@ class GamesController < ApplicationController
|
|
|
|
|
game.myshixun.update_column(:updated_at, Time.now)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# vnc连接
|
|
|
|
|
def get_vnc_link game
|
|
|
|
|
begin
|
|
|
|
|
shixun = game.myshixun.shixun
|
|
|
|
|
shixun_tomcat = edu_setting('cloud_bridge')
|
|
|
|
|
service_host = edu_setting('vnc_url')
|
|
|
|
|
uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
|
|
|
|
|
params = {tpiID: game.myshixun.id, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
|
|
|
|
|
res = uri_post uri, params
|
|
|
|
|
if res && res['code'].to_i != 0
|
|
|
|
|
raise("实训云平台繁忙(繁忙等级:99)")
|
|
|
|
|
end
|
|
|
|
|
@vnc_url =
|
|
|
|
|
if request.subdomain == "pre-newweb"
|
|
|
|
|
# 无域名版本
|
|
|
|
|
"http://#{service_host}:#{res['port']}/vnc_lite.html?password=headless"
|
|
|
|
|
else
|
|
|
|
|
# 有域名版本
|
|
|
|
|
"https://#{res['port']}.#{service_host}/vnc_lite.html?password=headless"
|
|
|
|
|
end
|
|
|
|
|
@vnc_evaluate = shixun.vnc_evaluate
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
Rails.logger.error(e.message)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 删除pod
|
|
|
|
|
def delete_vnc game
|
|
|
|
|
myshixun_id = game.myshixun_id
|
|
|
|
|
digest = game.identifier + edu_setting('bridge_secret_key')
|
|
|
|
|
digest_key = Digest::SHA1.hexdigest("#{digest}")
|
|
|
|
|
begin
|
|
|
|
|
shixun_tomcat = edu_setting('cloud_bridge')
|
|
|
|
|
uri = "#{shixun_tomcat}/bridge/vnc/delete"
|
|
|
|
|
Rails.logger.info("#{current_user} => cloese_webssh digest is #{digest}")
|
|
|
|
|
params = {:tpiID => myshixun_id, :digestKey => digest_key, :identifier => game.identifier}
|
|
|
|
|
res = uri_post uri, params
|
|
|
|
|
if res && res['code'].to_i != 0
|
|
|
|
|
raise("实训云平台繁忙(繁忙等级:110)")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|