|
|
|
@ -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
|
|
|
|
|