Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve judging errors on the submission page #267

Merged
merged 10 commits into from
May 19, 2024
2 changes: 1 addition & 1 deletion app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def update_test_messages

judge_data = self.judge_data
return if judge_data.status == :pending # incomplete judge_log
return if judge_data.errored? # judge errored - very bad
return if judge_data.data.has_key?('error') # judge errored - very bad
BelgianSalamander marked this conversation as resolved.
Show resolved Hide resolved

errors = []
warnings = []
Expand Down
2 changes: 1 addition & 1 deletion app/models/submission/judge_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def initialize(log, test_sets, test_cases, prerequisite_sets = [])
end

def errored?
data.has_key?('error')
data.has_key?('error') || status == :error
end

def completed?
Expand Down
10 changes: 7 additions & 3 deletions app/views/submissions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

<%= stylesheet_link_tag "submission" %>

<% if @submission.score == nil %>
<% @judge_data = @submission.judge_data %>
<% if @judge_data.errored? %>
<p>
<b>An unexpected error has occurred during judging. Please retry the submission, or contact us at <%= mail_to "[email protected]" %> if the error persists.</b>
</p>
<% elsif @submission.score == nil %>
<p>
<b>This submission has not finished judging. Refresh this page in a minute or two to see the submission's score.</b>
</p>
Expand Down Expand Up @@ -46,7 +51,6 @@
<% end %>
</p>

<% @judge_data = @submission.judge_data %>
<% if @judge_data.compiled? %>
<table class="results">
<tbody class="compilation status_<%= @judge_data.compilation.status %>">
Expand Down Expand Up @@ -76,7 +80,7 @@
</table>
<% end %>
<table class="results">
<% if !@judge_data.compiled? || @judge_data.compilation.status == :success %>
<% if !@judge_data.errored? && (!@judge_data.compiled? || @judge_data.compilation.status == :success) %>
<tbody class="headings">
<th class="test_name"></th>
<th>Time</th>
Expand Down
2 changes: 1 addition & 1 deletion app/workers/judge_submission_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def perform(submission_id)
rescue StandardError => e
unless self.submission.nil?
submission.reload
submission.judge_log = {'error' => {'message' => e.message, 'backtrace' => e.backtrace}}.to_json
submission.judge_log = {'error' => {'message' => e.message, 'backtrace' => e.backtrace}, 'status' => 2}.to_json
submission.save
end
raise
Expand Down