Skip to content

Commit

Permalink
Show evaluator compilation log to staff on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Holmes98 committed Apr 27, 2024
1 parent 8d84fcd commit 34aa091
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/submission.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ table.results {
border-spacing: 0;
border-collapse: collapse;
width: 100%;
margin: 15px 0px;
}

.results th {
Expand Down
8 changes: 8 additions & 0 deletions app/models/submission/judge_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,18 @@ def compiled?
data.has_key?('compile')
end

def evaluator_compiled?
data.has_key?('evaluator_compile')
end

def compilation
@compilation ||= Compilation.new(data['compile'])
end

def evaluator_compilation
@evaluator_compilation ||= Compilation.new(data['evaluator_compile'])
end

def prerequisite_sets
test_sets.slice(@presets)
end
Expand Down
23 changes: 17 additions & 6 deletions app/views/submissions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
</p>

<% @judge_data = @submission.judge_data %>
<table class="results">
<% if @judge_data.compiled? %>
<% if @judge_data.compiled? %>
<table class="results">
<tbody class="compilation status_<%= @judge_data.compilation.status %>">
<tr>
<th class="compile_command" colspan="3">Compilation: <span class="code"><%= @judge_data.compilation.command %></span></th>
Expand All @@ -59,9 +59,22 @@
<td colspan="5"><span class="code"><%= @judge_data.compilation.log %></span></td>
</tr>
</tbody>
<% end %>
</table>
<% end %>
<% if @judge_data.evaluator_compiled? && @submission.problem.evaluator && policy(@submission.problem.evaluator).inspect? %>
<table class="results">
<tbody class="compilation status_<%= @judge_data.evaluator_compilation.status %>">
<tr>
<th class="compile_command" colspan="3">Evaluator Compilation: <span class="code"><%= @judge_data.evaluator_compilation.command %></span></th>
<th class="compile_status"><%= @judge_data.evaluator_compilation.judgement %></th>
<th>&nbsp;</th>
</tr>
<tr>
<td colspan="5"><span class="code"><%= @judge_data.evaluator_compilation.log %></span></td>
</tr>
</tbody>
</table>
&nbsp;
<% end %>
<table class="results">
<% if !@judge_data.compiled? || @judge_data.compilation.status == :success %>
<tbody class="headings">
Expand Down Expand Up @@ -152,8 +165,6 @@
</tr>
</tbody>
</table>
<br>
<br>
<p>
<b>Source:</b>
<%= predisplay(@submission.source || "", language: @submission.language.lexer) %>
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 @@ -87,7 +87,7 @@ def judge

if problem.evaluator.language&.compiled
evaluator_compilation = compile!(problem.evaluator.source, problem.evaluator.language, EvalFileName) # possible caching
raise evaluator_compilation['log'] if evaluator_compilation['stat'] != 0 # error
return result.merge!('evaluator_compile' => evaluator_compilation, 'status' => 2) if evaluator_compilation['stat'] != 0 # error
else
File.open(File.expand_path(EvalFileName, tmpdir),"w") do |file|
file.chmod(0700)
Expand Down

0 comments on commit 34aa091

Please sign in to comment.