dev_jupyter
daiao 5 years ago
parent d2efc08cda
commit 9c35010dfe

@ -749,6 +749,8 @@ class GamesController < ApplicationController
# 针对web类型的实训
web_route = game_challenge.try(:web_route)
server_url = @game.get_server_url if web_route.present?
mirror_name = @shixun.mirror_name
e_record = EvaluateRecord.where(:identifier => sec_key).first
@ -776,7 +778,7 @@ class GamesController < ApplicationController
@base_date = {grade: grade, gold: score, experience: experience, status: game_status, had_done: had_done,
position: game_challenge.position, port: port, record_consume_time: record_consume_time,
mirror_name: mirror_name, picture: picture, web_route: web_route, star: @game.star,
next_game: next_game, prev_game: prev_game, max_mem: max_mem}
next_game: next_game, prev_game: prev_game, max_mem: max_mem, server_url: server_url}
end
# 记录实训花费的时间

@ -99,6 +99,7 @@ class MyshixunsController < ApplicationController
status = jsonTestDetails['status']
game_id = jsonTestDetails['buildID']
sec_key = jsonTestDetails['sec_key']
server_url = jsonTestDetails['showServer']
uid_logger_dubug("training_task_status start-#{game_id}-1#{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}")
resubmit = jsonTestDetails['resubmit']
@ -117,6 +118,10 @@ class MyshixunsController < ApplicationController
pics = params[:tpiRepoPath]
game.update_column(:picture_path, pics)
end
# 如果启动了服务则存在redis中供前端访问
if server_url.present?
game.set_server_key(server_url)
end
max_query_index = game.outputs ? (game.outputs.first.try(:query_index).to_i + 1) : 1
test_set_score = 0
unless jenkins_testsets.blank?

@ -29,6 +29,19 @@ class Game < ApplicationRecord
validates :identifier, uniqueness: true
# 服务器uri+port的redis的key
def server_key
"game_server_url_#{id}"
end
def set_server_key(server_url)
Rails.cache.write("#{server_key}", server_url, expires_in: 5.minute)
end
def get_server_url
Rails.cache.read(server_key)
end
# 根据得分比例来算实际得分(试卷、实训作业)
def real_score score
((final_score < 0 ? 0 : final_score).to_f / challenge.score) * score

Loading…
Cancel
Save