dev_daiao
daiao 5 years ago
parent 630f0b74f9
commit 806cb3d02b

@ -73,14 +73,20 @@ class HackUserLastestCodesController < ApplicationController
def oj_evaluate exec_mode, error_status, error_msg
request_url = "#{edu_setting('cloud_bridge')}/bridge/ojs/evaluate"
testCases = Base64.urlsafe_encode64({input: params[:input]}.to_json)
test_sets =
if exec_mode == "normal"
@hack.hack_sets.map{|set| {input: set.input, output: set.output, caseId: set.id}}
else
{input: params[:input]}
end
testCases = Base64.urlsafe_encode64(test_sets.to_json)
debug_params = {execMode: exec_mode,
tpiID: @my_hack.identifier,
testCases: testCases,
platform: @my_hack.language,
codeFileContent: @my_hack.code,
timeLimit: @hack.time_limit,
sec_key: Time.now.to_s}
sec_key: Time.now.to_i}
interface_post request_url, debug_params, error_status, error_msg
# 每次评测提交数增加
@hack.increment!(:submit_num)

@ -6,6 +6,8 @@ class HacksController < ApplicationController
# 开启编程,如果第一次开启,创建一条记录,如果已经开启过的话,直接返回标识即可
def start
# 未发布的编程题,只能作者、或管理员访问
start_hack_auth
user_hack = @hack.hack_user_lastest_codes.mine(current_user.id)
identifier =
if user_hack.present?
@ -167,5 +169,10 @@ class HacksController < ApplicationController
@hacks = hacks.order("#{sort_by} #{sort_direction}")
end
def start_hack_auth
return true if @hack == 1
require_auth_identity
end
end

Loading…
Cancel
Save