Show More
Commit Description:
fixed submission bug: forgot to set problem attribute in case that the problem is set in the submission code....
Commit Description:
fixed submission bug: forgot to set problem attribute in case that the problem is set in the submission code.
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@100 6386c4cd-e34a-4fa8-8920-d93eb39b512e
References:
File last commit:
Show/Diff file:
Action:
app/controllers/test_controller.rb
| 49 lines
| 1.3 KiB
| text/x-ruby
| RubyLexer
|
|
r44 | class TestController < ApplicationController | ||
before_filter :authenticate | ||||
verify :method => :post, :only => [:test_submit], | ||||
:redirect_to => { :action => :index } | ||||
def index | ||||
@user = User.find(session[:user_id]) | ||||
prepare_index_information | ||||
end | ||||
def submit | ||||
@user = User.find(session[:user_id]) | ||||
test_request = TestRequest.new_from_form_params(@user,params[:test_request]) | ||||
if test_request.save | ||||
redirect_to :action => 'index' | ||||
else | ||||
flash[:notice] = 'Error saving your test submission' | ||||
redirect_to :action => 'index' | ||||
end | ||||
end | ||||
def read | ||||
user = User.find(session[:user_id]) | ||||
test_request = TestRequest.find(params[:id]) | ||||
if test_request.user_id != user.id | ||||
flash[:notice] = 'Invalid output' | ||||
redirect_to :action => 'index' | ||||
return | ||||
end | ||||
if test_request.output_file_name!=nil | ||||
data = File.open(test_request.output_file_name).read(2048) | ||||
send_data(data, | ||||
{:filename => 'output.txt', | ||||
:type => 'text/plain'}) | ||||
return | ||||
end | ||||
redirect_to :action => 'index' | ||||
end | ||||
protected | ||||
def prepare_index_information | ||||
@submissions = Submission.find_last_for_all_available_problems(@user.id) | ||||
@problems = @submissions.collect { |submission| submission.problem } | ||||
end | ||||
end | ||||