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

Display an error message when submitting executable. #268

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/controllers/problems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ def submit
@problem = Problem.find(params[:id])
@submission = Submission.new(submit_params) # create submission
respond_to do |format|
if @submission.save
source_is_valid = @submission.source.valid_encoding? && [email protected]?("\0")
Holmes98 marked this conversation as resolved.
Show resolved Hide resolved
if !source_is_valid
@submission.errors.add :source_file, "- Submission has an invalid text encoding. This was likely caused by submitting a compiled file (.exe, .out, .class, ...) instead of a source code file (.cpp, .c, .java, ...)."
@submission.source = nil; # Prevent submission form from trying to render the source (and erroring)
end

if source_is_valid && @submission.save
@submission.judge
format.html { redirect_to(@submission, :notice => 'Submission was successfully created.') }
format.xml { render :xml => @submission, :status => :created, :location => @submission }
Expand Down