添加jupyter url

chromesetting
guange 5 years ago
parent 24fac643cc
commit b74a090510

@ -13,6 +13,9 @@ class ChallengesController < ApplicationController
include ShixunsHelper
include ChallengesHelper
helper_method :jupyter_url
# 新建实践题
def new
@position = @shixun.challenges.count + 1
@ -160,6 +163,23 @@ class ChallengesController < ApplicationController
@shixun.increment!(:visits)
end
def jupyter_url(shixun)
#打开tpm - juypter接口
if shixun.is_jupyter?
shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/jupyter/get"
tpiID = "tpm#{shixun.id}"
params = {tpiID: tpiID, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
logger.info "test_juypter: uri->#{uri}, params->#{params}"
res = uri_post uri, params
logger.info "test_juypter: #{res}"
return "https://#{res['port']}.jupyter.educoder.net/notebooks/data/workspace/myshixun_#{tpiID}/01.ipynb"
end
end
def show
@tab = params[:tab].nil? ? 1 : params[:tab].to_i
challenge_num = @shixun.challenges_count

@ -4,4 +4,7 @@ module ChallengesHelper
str.gsub(/\A\r/, "\r\r")
end
end

@ -5,6 +5,7 @@ json.power @editable
json.shixun_identifier @shixun.identifier
json.shixun_status @shixun.status
json.allow_skip @shixun.task_pass
json.jupyter_url jupyter_url(@shixun)
# 列表
if @challenges.present?

Loading…
Cancel
Save