Show More
Commit Description:
[web] fix time.new, time.now to use gmtime...
Commit Description:
[web] fix time.new, time.now to use gmtime git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@249 6386c4cd-e34a-4fa8-8920-d93eb39b512e
File last commit:
Show/Diff file:
Action:
app/controllers/test_controller.rb | 95 lines | 2.3 KiB | text/x-ruby | RubyLexer |
jittat
moved test interface functionality to test_controller...
r44 class TestController < ApplicationController
before_filter :authenticate
jittat
[web] added site and time out basic functionality...
r85 #
# COMMENT OUT: filter in each action instead
#
# before_filter :verify_time_limit, :only => [:submit]
jittat
[web] add test result page...
r79 verify :method => :post, :only => [:submit],
jittat
moved test interface functionality to test_controller...
r44 :redirect_to => { :action => :index }
def index
prepare_index_information
end
def submit
@user = User.find(session[:user_id])
jittat
[web] added site and time out basic functionality...
r85
jittat
[web] fixed test_request error when user does not put in any file...
r86 @submitted_test_request = TestRequest.new_from_form_params(@user,params[:test_request])
if @submitted_test_request.errors.length != 0
prepare_index_information
render :action => 'index' and return
jittat
[web] added site and time out basic functionality...
r85 end
jittat
[web] fixed test_request error when user does not put in any file...
r86 if @user.site!=nil and @user.site.finished?
@submitted_test_request.errors.add_to_base('Contest is over.')
prepare_index_information
render :action => 'index' and return
end
if @submitted_test_request.save
jittat
moved test interface functionality to test_controller...
r44 redirect_to :action => 'index'
else
jittat
[web] fixed test_request error when user does not put in any file...
r86 prepare_index_information
render :action => 'index'
jittat
moved test interface functionality to test_controller...
r44 end
end
def read
user = User.find(session[:user_id])
jittat
[web] add test result page...
r79 begin
test_request = TestRequest.find(params[:id])
rescue
test_request = nil
end
if test_request==nil or test_request.user_id != user.id
jittat
moved test interface functionality to test_controller...
r44 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)
jittat
fix bug: test_request: read empty output file...
r49 if data==nil
data=""
end
jittat
moved test interface functionality to test_controller...
r44 send_data(data,
{:filename => 'output.txt',
:type => 'text/plain'})
return
end
redirect_to :action => 'index'
end
jittat
[web] add test result page...
r79
def result
@user = User.find(session[:user_id])
begin
@test_request = TestRequest.find(params[:id])
rescue
@test_request = nil
end
if @test_request==nil or @test_request.user_id != @user.id
flash[:notice] = 'Invalid request'
redirect_to :action => 'index'
return
end
end
jittat
moved test interface functionality to test_controller...
r44
protected
def prepare_index_information
jittat
[web] fixed test_request error when user does not put in any file...
r86 @user = User.find(session[:user_id])
jittat
moved test interface functionality to test_controller...
r44 @submissions = Submission.find_last_for_all_available_problems(@user.id)
jittat
[web] added test_allowed flag to problems...
r94 all_problems = @submissions.collect { |submission| submission.problem }
@problems = []
all_problems.each do |problem|
if problem.test_allowed
@problems << problem
end
end
jittat
[web] fixed test_request error when user does not put in any file...
r86 @test_requests = @user.test_requests
jittat
moved test interface functionality to test_controller...
r44 end
end