You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
845 B

class HackUserCode < ApplicationRecord
# error_test_set_id: 错误的测试集id
# 用户编程题的信息
belongs_to :hack
belongs_to :hack_user_lastest_code
scope :created_order, ->{ order("created_at desc")}
scope :passed, -> { find_by(status: 0)}
def error_msg_show
if error_msg.blank?
if status == -1
Base64.encode64("测试用例结果不匹配")
elsif status == 2
Base64.encode64("代码提交超时")
else
Base64.encode64("代码执行失败")
end
else
error_msg
end
end
# 预计输出先默认是隐藏的
def expected_output
test_check_power ? self[:expected_output] : Base64.urlsafe_encode64("隐藏测试集,暂不支持查看")
end
def input
test_check_power ? self[:input] : "隐藏测试集,暂不支持查看"
end
end