From ef4ddf753c15780b8434fadba92d5b45b3a1c66f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 26 Mar 2020 16:20:55 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90OJ=E3=80=91=E8=B0=83=E8=AF=95=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E5=92=8C=E6=8F=90=E4=BA=A4=E8=AE=B0=E5=BD=95=E4=B8=AD?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E7=BB=93=E6=9E=9C=E8=BE=93=E5=87=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=B2=A1=E6=9C=89=E6=8D=A2=E8=A1=8C=20=E9=AB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 6 ++++++ .../hack_user_lastest_codes/record_detail.json.jbuilder | 3 ++- app/views/hack_user_lastest_codes/result.json.jbuilder | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6d5688078..2770a3739 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -33,6 +33,12 @@ module ApplicationHelper Base64.urlsafe_encode64(content) end + # 替换换行和tab键 + def regexp_msg content + return nil if content.blank? + content.gsub(/\n/, '
').gsub(/\t/, " \; \; \; \; \; \; \; \;") + end + def graduation_navigation graduation graduation.class.to_s == "GraduationTopic" ? "毕设选题" : "毕设任务" end diff --git a/app/views/hack_user_lastest_codes/record_detail.json.jbuilder b/app/views/hack_user_lastest_codes/record_detail.json.jbuilder index d05b6d799..189b51c46 100644 --- a/app/views/hack_user_lastest_codes/record_detail.json.jbuilder +++ b/app/views/hack_user_lastest_codes/record_detail.json.jbuilder @@ -1,8 +1,9 @@ json.status 0 json.message "返回成功" json.data do - json.(@hack_user, :id, :status, :error_line, :error_msg, :expected_output, + json.(@hack_user, :id, :status, :error_line, :expected_output, :input, :output, :execute_time, :execute_memory, :created_at, :code) + json.error_msg regexp_msg(@hack_user.error_msg) json.language @hack_user.language json.name @hack_user.hack.name json.myproblem_identifier @my_hack.identifier diff --git a/app/views/hack_user_lastest_codes/result.json.jbuilder b/app/views/hack_user_lastest_codes/result.json.jbuilder index 0ddd28103..f55ca1d19 100644 --- a/app/views/hack_user_lastest_codes/result.json.jbuilder +++ b/app/views/hack_user_lastest_codes/result.json.jbuilder @@ -3,6 +3,7 @@ json.message "评测完成" json.data do json.(@result, :id, :status, :error_line, :error_msg, :input, :output, :execute_time, :execute_memory) + json.error_msg regexp_msg(@result.error_msg) json.passed @my_hack.passed # 提交模式多了一个预计输出 if @mode == "submit"