Skip to content

Commit

Permalink
Improve judging errors on the submission page (#267)
Browse files Browse the repository at this point in the history
This adds a proper error message and hides test cases on the
submission page when judging fails.
  • Loading branch information
Holmes98 authored May 19, 2024
1 parent ee7d417 commit 51571c5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
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

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

0 comments on commit 51571c5

Please sign in to comment.