Description:
fixed errors on test request: Rails.root is not a string, no errors.length
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r341:358ad0e58c64 - - 2 files changed: 4 inserted, 4 deleted
@@ -1,118 +1,118 | |||||
|
1 | class TestController < ApplicationController |
|
1 | class TestController < ApplicationController |
|
2 |
|
2 | ||
|
3 | before_filter :authenticate, :check_viewability |
|
3 | before_filter :authenticate, :check_viewability |
|
4 |
|
4 | ||
|
5 | # |
|
5 | # |
|
6 | # COMMENT OUT: filter in each action instead |
|
6 | # COMMENT OUT: filter in each action instead |
|
7 | # |
|
7 | # |
|
8 | # before_filter :verify_time_limit, :only => [:submit] |
|
8 | # before_filter :verify_time_limit, :only => [:submit] |
|
9 |
|
9 | ||
|
10 | verify :method => :post, :only => [:submit], |
|
10 | verify :method => :post, :only => [:submit], |
|
11 | :redirect_to => { :action => :index } |
|
11 | :redirect_to => { :action => :index } |
|
12 |
|
12 | ||
|
13 | def index |
|
13 | def index |
|
14 | prepare_index_information |
|
14 | prepare_index_information |
|
15 | end |
|
15 | end |
|
16 |
|
16 | ||
|
17 | def submit |
|
17 | def submit |
|
18 | @user = User.find(session[:user_id]) |
|
18 | @user = User.find(session[:user_id]) |
|
19 |
|
19 | ||
|
20 | @submitted_test_request = TestRequest.new_from_form_params(@user,params[:test_request]) |
|
20 | @submitted_test_request = TestRequest.new_from_form_params(@user,params[:test_request]) |
|
21 |
|
21 | ||
|
22 |
- if @submitted_test_request.errors. |
|
22 | + if ! @submitted_test_request.errors.empty? |
|
23 | prepare_index_information |
|
23 | prepare_index_information |
|
24 | render :action => 'index' and return |
|
24 | render :action => 'index' and return |
|
25 | end |
|
25 | end |
|
26 |
|
26 | ||
|
27 | if GraderConfiguration.time_limit_mode? |
|
27 | if GraderConfiguration.time_limit_mode? |
|
28 | if @user.contest_finished? |
|
28 | if @user.contest_finished? |
|
29 | @submitted_test_request.errors.add_to_base('Contest is over.') |
|
29 | @submitted_test_request.errors.add_to_base('Contest is over.') |
|
30 | prepare_index_information |
|
30 | prepare_index_information |
|
31 | render :action => 'index' and return |
|
31 | render :action => 'index' and return |
|
32 | end |
|
32 | end |
|
33 |
|
33 | ||
|
34 | if !GraderConfiguration.allow_test_request(@user) |
|
34 | if !GraderConfiguration.allow_test_request(@user) |
|
35 | prepare_index_information |
|
35 | prepare_index_information |
|
36 | flash[:notice] = 'Test request is not allowed during the last 30 minutes' |
|
36 | flash[:notice] = 'Test request is not allowed during the last 30 minutes' |
|
37 | redirect_to :action => 'index' and return |
|
37 | redirect_to :action => 'index' and return |
|
38 | end |
|
38 | end |
|
39 | end |
|
39 | end |
|
40 |
|
40 | ||
|
41 | if @submitted_test_request.save |
|
41 | if @submitted_test_request.save |
|
42 | redirect_to :action => 'index' |
|
42 | redirect_to :action => 'index' |
|
43 | else |
|
43 | else |
|
44 | prepare_index_information |
|
44 | prepare_index_information |
|
45 | render :action => 'index' |
|
45 | render :action => 'index' |
|
46 | end |
|
46 | end |
|
47 | end |
|
47 | end |
|
48 |
|
48 | ||
|
49 | def read |
|
49 | def read |
|
50 | user = User.find(session[:user_id]) |
|
50 | user = User.find(session[:user_id]) |
|
51 | begin |
|
51 | begin |
|
52 | test_request = TestRequest.find(params[:id]) |
|
52 | test_request = TestRequest.find(params[:id]) |
|
53 | rescue |
|
53 | rescue |
|
54 | test_request = nil |
|
54 | test_request = nil |
|
55 | end |
|
55 | end |
|
56 | if test_request==nil or test_request.user_id != user.id |
|
56 | if test_request==nil or test_request.user_id != user.id |
|
57 | flash[:notice] = 'Invalid output' |
|
57 | flash[:notice] = 'Invalid output' |
|
58 | redirect_to :action => 'index' |
|
58 | redirect_to :action => 'index' |
|
59 | return |
|
59 | return |
|
60 | end |
|
60 | end |
|
61 | if test_request.output_file_name!=nil |
|
61 | if test_request.output_file_name!=nil |
|
62 | data = File.open(test_request.output_file_name).read(2048) |
|
62 | data = File.open(test_request.output_file_name).read(2048) |
|
63 | if data==nil |
|
63 | if data==nil |
|
64 | data="" |
|
64 | data="" |
|
65 | end |
|
65 | end |
|
66 | send_data(data, |
|
66 | send_data(data, |
|
67 | {:filename => 'output.txt', |
|
67 | {:filename => 'output.txt', |
|
68 | :type => 'text/plain'}) |
|
68 | :type => 'text/plain'}) |
|
69 | return |
|
69 | return |
|
70 | end |
|
70 | end |
|
71 | redirect_to :action => 'index' |
|
71 | redirect_to :action => 'index' |
|
72 | end |
|
72 | end |
|
73 |
|
73 | ||
|
74 | def result |
|
74 | def result |
|
75 | @user = User.find(session[:user_id]) |
|
75 | @user = User.find(session[:user_id]) |
|
76 | begin |
|
76 | begin |
|
77 | @test_request = TestRequest.find(params[:id]) |
|
77 | @test_request = TestRequest.find(params[:id]) |
|
78 | rescue |
|
78 | rescue |
|
79 | @test_request = nil |
|
79 | @test_request = nil |
|
80 | end |
|
80 | end |
|
81 | if @test_request==nil or @test_request.user_id != @user.id |
|
81 | if @test_request==nil or @test_request.user_id != @user.id |
|
82 | flash[:notice] = 'Invalid request' |
|
82 | flash[:notice] = 'Invalid request' |
|
83 | redirect_to :action => 'index' |
|
83 | redirect_to :action => 'index' |
|
84 | return |
|
84 | return |
|
85 | end |
|
85 | end |
|
86 | end |
|
86 | end |
|
87 |
|
87 | ||
|
88 | protected |
|
88 | protected |
|
89 |
|
89 | ||
|
90 | def prepare_index_information |
|
90 | def prepare_index_information |
|
91 | @user = User.find(session[:user_id]) |
|
91 | @user = User.find(session[:user_id]) |
|
92 | @submissions = Submission.find_last_for_all_available_problems(@user.id) |
|
92 | @submissions = Submission.find_last_for_all_available_problems(@user.id) |
|
93 | all_problems = @submissions.collect { |submission| submission.problem } |
|
93 | all_problems = @submissions.collect { |submission| submission.problem } |
|
94 | @problems = [] |
|
94 | @problems = [] |
|
95 | all_problems.each do |problem| |
|
95 | all_problems.each do |problem| |
|
96 | if problem.test_allowed |
|
96 | if problem.test_allowed |
|
97 | @problems << problem |
|
97 | @problems << problem |
|
98 | end |
|
98 | end |
|
99 | end |
|
99 | end |
|
100 | @test_requests = [] |
|
100 | @test_requests = [] |
|
101 | @user.test_requests.each do |ts| |
|
101 | @user.test_requests.each do |ts| |
|
102 | if ts.problem and ts.problem.available |
|
102 | if ts.problem and ts.problem.available |
|
103 | @test_requests << ts |
|
103 | @test_requests << ts |
|
104 | end |
|
104 | end |
|
105 | end |
|
105 | end |
|
106 | end |
|
106 | end |
|
107 |
|
107 | ||
|
108 | def check_viewability |
|
108 | def check_viewability |
|
109 | user = User.find(session[:user_id]) |
|
109 | user = User.find(session[:user_id]) |
|
110 | if !GraderConfiguration.show_tasks_to?(user) |
|
110 | if !GraderConfiguration.show_tasks_to?(user) |
|
111 | redirect_to :controller => 'main', :action => 'list' |
|
111 | redirect_to :controller => 'main', :action => 'list' |
|
112 | end |
|
112 | end |
|
113 | if (!GraderConfiguration.show_submitbox_to?(user)) and (action_name=='submit') |
|
113 | if (!GraderConfiguration.show_submitbox_to?(user)) and (action_name=='submit') |
|
114 | redirect_to :controller => 'test', :action => 'index' |
|
114 | redirect_to :controller => 'test', :action => 'index' |
|
115 | end |
|
115 | end |
|
116 | end |
|
116 | end |
|
117 |
|
117 | ||
|
118 | end |
|
118 | end |
@@ -1,30 +1,30 | |||||
|
1 | # If you want to manage graders through web interface, set the path to |
|
1 | # If you want to manage graders through web interface, set the path to |
|
2 | # the grader directory below. This dir is where raw, ev, ev-exam, |
|
2 | # the grader directory below. This dir is where raw, ev, ev-exam, |
|
3 | # scripts reside. All grader scripts will be in |
|
3 | # scripts reside. All grader scripts will be in |
|
4 | # #{GRADER_ROOT_DIR}/scripts. |
|
4 | # #{GRADER_ROOT_DIR}/scripts. |
|
5 | GRADER_ROOT_DIR = '' |
|
5 | GRADER_ROOT_DIR = '' |
|
6 |
|
6 | ||
|
7 | # These are where inputs and outputs of test requests are stored |
|
7 | # These are where inputs and outputs of test requests are stored |
|
8 |
- TEST_REQUEST_INPUT_FILE_DIR = Rails.root + ' |
|
8 | + TEST_REQUEST_INPUT_FILE_DIR = (Rails.root + 'data/test_request/input').to_s |
|
9 |
- TEST_REQUEST_OUTPUT_FILE_DIR = Rails.root + ' |
|
9 | + TEST_REQUEST_OUTPUT_FILE_DIR = (Rails.root + 'data/test_request/output').to_s |
|
10 |
|
10 | ||
|
11 | # To use ANALYSIS MODE, provide the testcases/testruns breakdown, |
|
11 | # To use ANALYSIS MODE, provide the testcases/testruns breakdown, |
|
12 | # and the directory of the grading result (usually in judge's dir). |
|
12 | # and the directory of the grading result (usually in judge's dir). |
|
13 |
- TASK_GRADING_INFO_FILENAME = Rails.root + ' |
|
13 | + TASK_GRADING_INFO_FILENAME = Rails.root + 'config/tasks.yml' |
|
14 |
|
14 | ||
|
15 | # TODO: change this to where results are kept. |
|
15 | # TODO: change this to where results are kept. |
|
16 | GRADING_RESULT_DIR = 'RESULT-DIR' |
|
16 | GRADING_RESULT_DIR = 'RESULT-DIR' |
|
17 |
|
17 | ||
|
18 | # Change this to allow importing testdata into database as test-pairs. |
|
18 | # Change this to allow importing testdata into database as test-pairs. |
|
19 | # This is mainly for Code Jom contest. |
|
19 | # This is mainly for Code Jom contest. |
|
20 | ALLOW_TEST_PAIR_IMPORT = false |
|
20 | ALLOW_TEST_PAIR_IMPORT = false |
|
21 |
|
21 | ||
|
22 | # Uncomment so that the system validates user e-mails |
|
22 | # Uncomment so that the system validates user e-mails |
|
23 | # VALIDATE_USER_EMAILS = true |
|
23 | # VALIDATE_USER_EMAILS = true |
|
24 |
|
24 | ||
|
25 | # Uncomment so that Apache X-Sendfile is used when delivering files |
|
25 | # Uncomment so that Apache X-Sendfile is used when delivering files |
|
26 | # (e.g., in /tasks/view). |
|
26 | # (e.g., in /tasks/view). |
|
27 | # USE_APACHE_XSENDFILE = true |
|
27 | # USE_APACHE_XSENDFILE = true |
|
28 |
|
28 | ||
|
29 | # Uncomment so that configuration is read only once when the server is loaded |
|
29 | # Uncomment so that configuration is read only once when the server is loaded |
|
30 | # CONFIGURATION_CACHE_ENABLED = true |
|
30 | # CONFIGURATION_CACHE_ENABLED = true |
You need to be logged in to leave comments.
Login now