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"