Description:
added codejom controller, show status in public
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r254:dff48a9ca2cd - - 8 files changed: 54 inserted, 3 deleted
@@ -0,0 +1,13 | |||||
|
|
1 | + class CodejomController < ApplicationController | ||
|
|
2 | + | ||
|
|
3 | + before_filter :admin_authorization | ||
|
|
4 | + before_filter :authenticate | ||
|
|
5 | + | ||
|
|
6 | + def index | ||
|
|
7 | + @user = User.find(session[:user_id]) | ||
|
|
8 | + @problems = Problem.find(:all) | ||
|
|
9 | + @available_problems = @problems.find_all {|p| not p.available } | ||
|
|
10 | + @activated_problems = @problems.find_all {|p| p.available } | ||
|
|
11 | + end | ||
|
|
12 | + | ||
|
|
13 | + end |
@@ -0,0 +1,11 | |||||
|
|
1 | + %h1 Code Jom Control Panel | ||
|
|
2 | + | ||
|
|
3 | + %h2= "Available problems (#{@available_problems.length})" | ||
|
|
4 | + %ul | ||
|
|
5 | + - @available_problems.each do |problem| | ||
|
|
6 | + %li= problem.name | ||
|
|
7 | + | ||
|
|
8 | + %h2= "Activated problems (#{@activated_problems.length})" | ||
|
|
9 | + - @activated_problems.each do |problem| | ||
|
|
10 | + = problem.name | ||
|
|
11 | + |
@@ -0,0 +1,8 | |||||
|
|
1 | + require 'test_helper' | ||
|
|
2 | + | ||
|
|
3 | + class CodejomControllerTest < ActionController::TestCase | ||
|
|
4 | + # Replace this with your real tests. | ||
|
|
5 | + test "the truth" do | ||
|
|
6 | + assert true | ||
|
|
7 | + end | ||
|
|
8 | + end |
@@ -0,0 +1,4 | |||||
|
|
1 | + require 'test_helper' | ||
|
|
2 | + | ||
|
|
3 | + class CodejomHelperTest < ActionView::TestCase | ||
|
|
4 | + end |
@@ -1,27 +1,38 | |||||
|
1 | class StatusesController < ApplicationController |
|
1 | class StatusesController < ApplicationController |
|
2 |
|
2 | ||
|
3 | - # protect the statuses, for now |
|
3 | + def index |
|
4 | - before_filter :admin_authorization |
|
4 | + if not SHOW_CONTEST_STATUS |
|
|
5 | + render :status => 403 and return | ||
|
|
6 | + end | ||
|
5 |
|
7 | ||
|
6 | - def index |
|
||
|
7 | problem_count = Problem.available_problem_count |
|
8 | problem_count = Problem.available_problem_count |
|
8 |
|
9 | ||
|
9 | @dead_users = [] |
|
10 | @dead_users = [] |
|
10 | @level_users = {} |
|
11 | @level_users = {} |
|
11 | @levels = (0..CODEJOM_MAX_ALIVE_LEVEL) |
|
12 | @levels = (0..CODEJOM_MAX_ALIVE_LEVEL) |
|
12 | @levels.each { |l| @level_users[l] = [] } |
|
13 | @levels.each { |l| @level_users[l] = [] } |
|
13 | User.find(:all).each do |user| |
|
14 | User.find(:all).each do |user| |
|
14 | if user.codejom_status==nil |
|
15 | if user.codejom_status==nil |
|
15 | user.update_codejom_status |
|
16 | user.update_codejom_status |
|
16 | user.codejom_status(true) # reload |
|
17 | user.codejom_status(true) # reload |
|
17 | end |
|
18 | end |
|
18 |
|
19 | ||
|
19 | if not user.codejom_status.alive |
|
20 | if not user.codejom_status.alive |
|
20 | @dead_users << user |
|
21 | @dead_users << user |
|
21 | else |
|
22 | else |
|
22 | @level_users[user.codejom_level] << user |
|
23 | @level_users[user.codejom_level] << user |
|
23 | end |
|
24 | end |
|
24 | end |
|
25 | end |
|
|
26 | + | ||
|
|
27 | + respond_to do |format| | ||
|
|
28 | + format.html | ||
|
|
29 | + format.xml do | ||
|
|
30 | + render :xml => { | ||
|
|
31 | + :levels => @level_users, | ||
|
|
32 | + :dead_users => @dead_users | ||
|
|
33 | + } | ||
|
|
34 | + end | ||
|
|
35 | + end | ||
|
25 | end |
|
36 | end |
|
26 |
|
37 | ||
|
27 | end |
|
38 | end |
@@ -1,110 +1,111 | |||||
|
1 | # Be sure to restart your web server when you modify this file. |
|
1 | # Be sure to restart your web server when you modify this file. |
|
2 |
|
2 | ||
|
3 | # Uncomment below to force Rails into production mode when |
|
3 | # Uncomment below to force Rails into production mode when |
|
4 | # you don't control web/app server and can't set it the proper way |
|
4 | # you don't control web/app server and can't set it the proper way |
|
5 | # ENV['RAILS_ENV'] ||= 'production' |
|
5 | # ENV['RAILS_ENV'] ||= 'production' |
|
6 |
|
6 | ||
|
7 | # Specifies gem version of Rails to use when vendor/rails is not present |
|
7 | # Specifies gem version of Rails to use when vendor/rails is not present |
|
8 | RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION |
|
8 | RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION |
|
9 |
|
9 | ||
|
10 | # Bootstrap the Rails environment, frameworks, and default configuration |
|
10 | # Bootstrap the Rails environment, frameworks, and default configuration |
|
11 | require File.join(File.dirname(__FILE__), 'boot') |
|
11 | require File.join(File.dirname(__FILE__), 'boot') |
|
12 |
|
12 | ||
|
13 | Rails::Initializer.run do |config| |
|
13 | Rails::Initializer.run do |config| |
|
14 | # Settings in config/environments/* take precedence over those specified here |
|
14 | # Settings in config/environments/* take precedence over those specified here |
|
15 |
|
15 | ||
|
16 | # Skip frameworks you're not going to use (only works if using vendor/rails) |
|
16 | # Skip frameworks you're not going to use (only works if using vendor/rails) |
|
17 | # config.frameworks -= [ :action_web_service, :action_mailer ] |
|
17 | # config.frameworks -= [ :action_web_service, :action_mailer ] |
|
18 |
|
18 | ||
|
19 | # Only load the plugins named here, by default all plugins in vendor/plugins are loaded |
|
19 | # Only load the plugins named here, by default all plugins in vendor/plugins are loaded |
|
20 | # config.plugins = %W( exception_notification ssl_requirement ) |
|
20 | # config.plugins = %W( exception_notification ssl_requirement ) |
|
21 |
|
21 | ||
|
22 | # Add additional load paths for your own custom dirs |
|
22 | # Add additional load paths for your own custom dirs |
|
23 | # config.load_paths += %W( #{RAILS_ROOT}/extras ) |
|
23 | # config.load_paths += %W( #{RAILS_ROOT}/extras ) |
|
24 |
|
24 | ||
|
25 | # Force all environments to use the same logger level |
|
25 | # Force all environments to use the same logger level |
|
26 | # (by default production uses :info, the others :debug) |
|
26 | # (by default production uses :info, the others :debug) |
|
27 | # config.log_level = :debug |
|
27 | # config.log_level = :debug |
|
28 |
|
28 | ||
|
29 | # Use the database for sessions instead of the file system |
|
29 | # Use the database for sessions instead of the file system |
|
30 | # (create the session table with 'rake db:sessions:create') |
|
30 | # (create the session table with 'rake db:sessions:create') |
|
31 | config.action_controller.session_store = :active_record_store |
|
31 | config.action_controller.session_store = :active_record_store |
|
32 |
|
32 | ||
|
33 | # Use SQL instead of Active Record's schema dumper when creating the test database. |
|
33 | # Use SQL instead of Active Record's schema dumper when creating the test database. |
|
34 | # This is necessary if your schema can't be completely dumped by the schema dumper, |
|
34 | # This is necessary if your schema can't be completely dumped by the schema dumper, |
|
35 | # like if you have constraints or database-specific column types |
|
35 | # like if you have constraints or database-specific column types |
|
36 | # config.active_record.schema_format = :sql |
|
36 | # config.active_record.schema_format = :sql |
|
37 |
|
37 | ||
|
38 | # Activate observers that should always be running |
|
38 | # Activate observers that should always be running |
|
39 | # config.active_record.observers = :cacher, :garbage_collector |
|
39 | # config.active_record.observers = :cacher, :garbage_collector |
|
40 |
|
40 | ||
|
41 | # Make Active Record use UTC-base instead of local time |
|
41 | # Make Active Record use UTC-base instead of local time |
|
42 | config.time_zone = 'UTC' |
|
42 | config.time_zone = 'UTC' |
|
43 |
|
43 | ||
|
44 | # Setting locales |
|
44 | # Setting locales |
|
45 | config.i18n.default_locale = 'en' |
|
45 | config.i18n.default_locale = 'en' |
|
46 |
|
46 | ||
|
47 | # See Rails::Configuration for more options |
|
47 | # See Rails::Configuration for more options |
|
48 |
|
48 | ||
|
49 | # ------------- |
|
49 | # ------------- |
|
50 | # Required gems |
|
50 | # Required gems |
|
51 | # ------------- |
|
51 | # ------------- |
|
52 | config.gem "haml" |
|
52 | config.gem "haml" |
|
53 | config.gem "tmail" |
|
53 | config.gem "tmail" |
|
54 | config.gem "rdiscount", :lib => "rdiscount" |
|
54 | config.gem "rdiscount", :lib => "rdiscount" |
|
55 |
|
55 | ||
|
56 | # NOTES on rspec: if you wan to test with rspec, you have to install |
|
56 | # NOTES on rspec: if you wan to test with rspec, you have to install |
|
57 | # rspec yourself, just call: [sudo] gem install rspec-rails |
|
57 | # rspec yourself, just call: [sudo] gem install rspec-rails |
|
58 |
|
58 | ||
|
59 | end |
|
59 | end |
|
60 |
|
60 | ||
|
61 | # Add new inflection rules using the following format |
|
61 | # Add new inflection rules using the following format |
|
62 | # (all these examples are active by default): |
|
62 | # (all these examples are active by default): |
|
63 | # Inflector.inflections do |inflect| |
|
63 | # Inflector.inflections do |inflect| |
|
64 | # inflect.plural /^(ox)$/i, '\1en' |
|
64 | # inflect.plural /^(ox)$/i, '\1en' |
|
65 | # inflect.singular /^(ox)en/i, '\1' |
|
65 | # inflect.singular /^(ox)en/i, '\1' |
|
66 | # inflect.irregular 'person', 'people' |
|
66 | # inflect.irregular 'person', 'people' |
|
67 | # inflect.uncountable %w( fish sheep ) |
|
67 | # inflect.uncountable %w( fish sheep ) |
|
68 | # end |
|
68 | # end |
|
69 |
|
69 | ||
|
70 | # Add new mime types for use in respond_to blocks: |
|
70 | # Add new mime types for use in respond_to blocks: |
|
71 | # Mime::Type.register "text/richtext", :rtf |
|
71 | # Mime::Type.register "text/richtext", :rtf |
|
72 | # Mime::Type.register "application/x-mobile", :mobile |
|
72 | # Mime::Type.register "application/x-mobile", :mobile |
|
73 |
|
73 | ||
|
74 | # Include your application configuration below |
|
74 | # Include your application configuration below |
|
75 |
|
75 | ||
|
76 | # If you want to manage graders through web interface, set the path to |
|
76 | # If you want to manage graders through web interface, set the path to |
|
77 | # the grader directory below. This dir is where raw, ev, ev-exam, |
|
77 | # the grader directory below. This dir is where raw, ev, ev-exam, |
|
78 | # scripts reside. All grader scripts will be in |
|
78 | # scripts reside. All grader scripts will be in |
|
79 | # #{GRADER_ROOT_DIR}/scripts. |
|
79 | # #{GRADER_ROOT_DIR}/scripts. |
|
80 | GRADER_ROOT_DIR = '' |
|
80 | GRADER_ROOT_DIR = '' |
|
81 |
|
81 | ||
|
82 | # These are where inputs and outputs of test requests are stored |
|
82 | # These are where inputs and outputs of test requests are stored |
|
83 | TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input' |
|
83 | TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input' |
|
84 | TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output' |
|
84 | TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output' |
|
85 |
|
85 | ||
|
86 | # To use ANALYSIS MODE, provide the testcases/testruns breakdown, |
|
86 | # To use ANALYSIS MODE, provide the testcases/testruns breakdown, |
|
87 | # and the directory of the grading result (usually in judge's dir). |
|
87 | # and the directory of the grading result (usually in judge's dir). |
|
88 | TASK_GRADING_INFO_FILENAME = RAILS_ROOT + '/config/tasks.yml' |
|
88 | TASK_GRADING_INFO_FILENAME = RAILS_ROOT + '/config/tasks.yml' |
|
89 |
|
89 | ||
|
90 | # TODO: change this to where results are kept. |
|
90 | # TODO: change this to where results are kept. |
|
91 | GRADING_RESULT_DIR = 'RESULT-DIR' |
|
91 | GRADING_RESULT_DIR = 'RESULT-DIR' |
|
92 |
|
92 | ||
|
93 | # Change this to allow importing testdata into database as test-pairs. |
|
93 | # Change this to allow importing testdata into database as test-pairs. |
|
94 | # This is mainly for Code Jom contest. |
|
94 | # This is mainly for Code Jom contest. |
|
95 | ALLOW_TEST_PAIR_IMPORT = false |
|
95 | ALLOW_TEST_PAIR_IMPORT = false |
|
96 |
|
96 | ||
|
97 | # Uncomment so that the system validates user e-mails |
|
97 | # Uncomment so that the system validates user e-mails |
|
98 | # VALIDATE_USER_EMAILS = true |
|
98 | # VALIDATE_USER_EMAILS = true |
|
99 |
|
99 | ||
|
100 | # Uncomment so that Apache X-Sendfile is used when delivering files |
|
100 | # Uncomment so that Apache X-Sendfile is used when delivering files |
|
101 | # (e.g., in /tasks/view). |
|
101 | # (e.g., in /tasks/view). |
|
102 | # USE_APACHE_XSENDFILE = true |
|
102 | # USE_APACHE_XSENDFILE = true |
|
103 |
|
103 | ||
|
104 | # Uncomment so that configuration is read only once when the server is loaded |
|
104 | # Uncomment so that configuration is read only once when the server is loaded |
|
105 | # Configuration.enable_caching |
|
105 | # Configuration.enable_caching |
|
106 |
|
106 | ||
|
107 | # OPTIONS FOR CODE JOM |
|
107 | # OPTIONS FOR CODE JOM |
|
108 | # -------------------- |
|
108 | # -------------------- |
|
109 | CODEJOM_MAX_ALIVE_LEVEL = 10 |
|
109 | CODEJOM_MAX_ALIVE_LEVEL = 10 |
|
110 | TEST_ASSIGNMENT_EXPIRATION_DURATION = 5.minute |
|
110 | TEST_ASSIGNMENT_EXPIRATION_DURATION = 5.minute |
|
|
111 | + SHOW_CONTEST_STATUS = false |
@@ -1,28 +1,29 | |||||
|
1 | ActionController::Routing::Routes.draw do |map| |
|
1 | ActionController::Routing::Routes.draw do |map| |
|
2 | map.resources :announcements |
|
2 | map.resources :announcements |
|
3 | map.resources :sites |
|
3 | map.resources :sites |
|
|
4 | + map.resources :statuses | ||
|
4 |
|
5 | ||
|
5 | # The priority is based upon order of creation: first created -> highest priority. |
|
6 | # The priority is based upon order of creation: first created -> highest priority. |
|
6 |
|
7 | ||
|
7 | # Sample of regular route: |
|
8 | # Sample of regular route: |
|
8 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' |
|
9 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' |
|
9 | # Keep in mind you can assign values other than :controller and :action |
|
10 | # Keep in mind you can assign values other than :controller and :action |
|
10 |
|
11 | ||
|
11 | # Sample of named route: |
|
12 | # Sample of named route: |
|
12 | # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' |
|
13 | # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' |
|
13 | # This route can be invoked with purchase_url(:id => product.id) |
|
14 | # This route can be invoked with purchase_url(:id => product.id) |
|
14 |
|
15 | ||
|
15 | # You can have the root of your site routed by hooking up '' |
|
16 | # You can have the root of your site routed by hooking up '' |
|
16 | # -- just remember to delete public/index.html. |
|
17 | # -- just remember to delete public/index.html. |
|
17 | map.connect '', :controller => 'main', :action => 'login' |
|
18 | map.connect '', :controller => 'main', :action => 'login' |
|
18 |
|
19 | ||
|
19 | # Allow downloading Web Service WSDL as a file with an extension |
|
20 | # Allow downloading Web Service WSDL as a file with an extension |
|
20 | # instead of a file named 'wsdl' |
|
21 | # instead of a file named 'wsdl' |
|
21 | map.connect ':controller/service.wsdl', :action => 'wsdl' |
|
22 | map.connect ':controller/service.wsdl', :action => 'wsdl' |
|
22 |
|
23 | ||
|
23 | map.connect 'tasks/view/:file.:ext', :controller => 'tasks', :action => 'view' |
|
24 | map.connect 'tasks/view/:file.:ext', :controller => 'tasks', :action => 'view' |
|
24 |
|
25 | ||
|
25 | # Install the default route as the lowest priority. |
|
26 | # Install the default route as the lowest priority. |
|
26 | map.connect ':controller/:action/:id.:format' |
|
27 | map.connect ':controller/:action/:id.:format' |
|
27 | map.connect ':controller/:action/:id' |
|
28 | map.connect ':controller/:action/:id' |
|
28 | end |
|
29 | end |
You need to be logged in to leave comments.
Login now