Description:
merge update to rail 4.2
Commit status:
[Not Reviewed]
References:
merge java
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r623:0e5f52b4f443 - - 101 files changed: 461 inserted, 2007 deleted

@@ -0,0 +1,3
1 + :javascript
2 + $("#compiler_msg").html("#{j @submissionhcompiler_msg}")
3 +
@@ -0,0 +1,8
1 + development:
2 + secret_key_base: '444f426d08add8e2d7cbd76e2057e521e06091231eb4d5472af6ba5654ea1124ce6a636f549be6827ce09561c314181226ad840d44e4677e1077942ee0dc82bd'
3 +
4 + test:
5 + secret_key_base: 'd52f411b06a79cc9f56d92e10d27e670cf0f0c3357e7caf9018ec23091b5c452ea9266c03a5c9e37b72c358702d4d460e957f90dcc553c9fc73a98adb520e781'
6 +
7 + production:
8 + secret_key_base: '7f85485d3d652fc6336dfe3cd98917d9bd7a323b32096bf7635d26b98ccd0480816cc2d12b5c10805cecf7d8fb322104e2bda71eb60dd871c5c537e56a063038'
@@ -0,0 +1,13
1 + require 'test_helper'
2 +
3 + class LoginTest < ActionDispatch::IntegrationTest
4 + # test "the truth" do
5 + # assert true
6 + # end
7 +
8 + test "login with valid information" do
9 + get root_path
10 + assert_response :success
11 +
12 + end
13 + end
@@ -1,59 +1,60
1 source 'https://rubygems.org'
1 source 'https://rubygems.org'
2
2
3 - gem 'rails', '~>3.2'
3 + gem 'rails', '~>4.2.0'
4 + gem 'activerecord-session_store'
4
5
5 gem 'select2-rails'
6 gem 'select2-rails'
6
7
7 # Bundle edge Rails instead:
8 # Bundle edge Rails instead:
8 # gem 'rails', :git => 'git://github.com/rails/rails.git'
9 # gem 'rails', :git => 'git://github.com/rails/rails.git'
9
10
10 gem 'mysql2'
11 gem 'mysql2'
12 + gem 'sqlite3'
11
13
12 # Gems used only for assets and not required
14 # Gems used only for assets and not required
13 # in production environments by default.
15 # in production environments by default.
14 - group :assets do
16 + gem 'sass-rails'
15 - gem 'sass-rails', '~> 3.2.6'
17 + gem 'coffee-rails'
16 - gem 'coffee-rails', '~> 3.2.2'
17
18
18 # See https://github.com/sstephenson/execjs#readme for more supported runtimes
19 # See https://github.com/sstephenson/execjs#readme for more supported runtimes
19 # gem 'therubyracer', :platforms => :ruby
20 # gem 'therubyracer', :platforms => :ruby
20
21
21 gem 'uglifier'
22 gem 'uglifier'
22 - end
23 +
23
24
24 - gem 'prototype-rails'
25 + # gem 'prototype-rails'
25
26
26 # To use ActiveModel has_secure_password
27 # To use ActiveModel has_secure_password
27 # gem 'bcrypt-ruby', '~> 3.0.0'
28 # gem 'bcrypt-ruby', '~> 3.0.0'
28
29
29 # To use Jbuilder templates for JSON
30 # To use Jbuilder templates for JSON
30 # gem 'jbuilder'
31 # gem 'jbuilder'
31
32
32 # Use unicorn as the app server
33 # Use unicorn as the app server
33 # gem 'unicorn'
34 # gem 'unicorn'
34
35
35 # Deploy with Capistrano
36 # Deploy with Capistrano
36 # gem 'capistrano'
37 # gem 'capistrano'
37
38
38 # To use debugger
39 # To use debugger
39 # gem 'debugger'
40 # gem 'debugger'
40 #
41 #
41
42
42 #in-place editor
43 #in-place editor
43 gem 'best_in_place', '~> 3.0.1'
44 gem 'best_in_place', '~> 3.0.1'
44
45
45 # jquery addition
46 # jquery addition
46 gem 'jquery-rails'
47 gem 'jquery-rails'
47 - gem 'jquery-ui-sass-rails'
48 + gem 'jquery-ui-rails'
48 gem 'jquery-timepicker-addon-rails'
49 gem 'jquery-timepicker-addon-rails'
49 gem 'jquery-tablesorter'
50 gem 'jquery-tablesorter'
50 gem 'jquery-countdown-rails'
51 gem 'jquery-countdown-rails'
51
52
52 #syntax highlighter
53 #syntax highlighter
53 gem 'rouge'
54 gem 'rouge'
54
55
55 #add bootstrap
56 #add bootstrap
56 gem 'bootstrap-sass', '~> 3.2.0'
57 gem 'bootstrap-sass', '~> 3.2.0'
57 gem 'bootstrap-switch-rails'
58 gem 'bootstrap-switch-rails'
58 gem 'bootstrap-toggle-rails'
59 gem 'bootstrap-toggle-rails'
59 gem 'autoprefixer-rails'
60 gem 'autoprefixer-rails'
@@ -66,15 +67,12
66 gem 'ace-rails-ap'
67 gem 'ace-rails-ap'
67
68
68 gem 'haml'
69 gem 'haml'
69 gem 'haml-rails'
70 gem 'haml-rails'
70 gem 'mail'
71 gem 'mail'
71 gem 'rdiscount'
72 gem 'rdiscount'
72 gem 'test-unit'
73 gem 'test-unit'
73 gem 'will_paginate', '~> 3.0.7'
74 gem 'will_paginate', '~> 3.0.7'
74 gem 'dynamic_form'
75 gem 'dynamic_form'
75 gem 'in_place_editing'
76 gem 'in_place_editing'
76 gem 'verification', :git => 'https://github.com/sikachu/verification.git'
77 gem 'verification', :git => 'https://github.com/sikachu/verification.git'
77
78
78 - group :test, :development do
79 - gem 'rspec-rails', '~> 2.99.0'
80 - end
@@ -1,208 +1,221
1 GIT
1 GIT
2 remote: https://github.com/sikachu/verification.git
2 remote: https://github.com/sikachu/verification.git
3 - revision: 76eaf51b13276ecae54bd9cd115832595d2ff56d
3 + revision: ff31697b940d7b0e2ec65f08764215c96104e76d
4 specs:
4 specs:
5 verification (1.0.3)
5 verification (1.0.3)
6 - actionpack (>= 3.0.0, < 5.0)
6 + actionpack (>= 3.0.0, < 5.1)
7 - activesupport (>= 3.0.0, < 5.0)
7 + activesupport (>= 3.0.0, < 5.1)
8
8
9 GEM
9 GEM
10 remote: https://rubygems.org/
10 remote: https://rubygems.org/
11 specs:
11 specs:
12 - ace-rails-ap (4.0.2)
12 + ace-rails-ap (4.1.1)
13 - actionmailer (3.2.22.5)
13 + actionmailer (4.2.7.1)
14 - actionpack (= 3.2.22.5)
14 + actionpack (= 4.2.7.1)
15 - mail (~> 2.5.4)
15 + actionview (= 4.2.7.1)
16 - actionpack (3.2.22.5)
16 + activejob (= 4.2.7.1)
17 - activemodel (= 3.2.22.5)
17 + mail (~> 2.5, >= 2.5.4)
18 - activesupport (= 3.2.22.5)
18 + rails-dom-testing (~> 1.0, >= 1.0.5)
19 - builder (~> 3.0.0)
19 + actionpack (4.2.7.1)
20 + actionview (= 4.2.7.1)
21 + activesupport (= 4.2.7.1)
22 + rack (~> 1.6)
23 + rack-test (~> 0.6.2)
24 + rails-dom-testing (~> 1.0, >= 1.0.5)
25 + rails-html-sanitizer (~> 1.0, >= 1.0.2)
26 + actionview (4.2.7.1)
27 + activesupport (= 4.2.7.1)
28 + builder (~> 3.1)
20 erubis (~> 2.7.0)
29 erubis (~> 2.7.0)
21 - journey (~> 1.0.4)
30 + rails-dom-testing (~> 1.0, >= 1.0.5)
22 - rack (~> 1.4.5)
31 + rails-html-sanitizer (~> 1.0, >= 1.0.2)
23 - rack-cache (~> 1.2)
32 + activejob (4.2.7.1)
24 - rack-test (~> 0.6.1)
33 + activesupport (= 4.2.7.1)
25 - sprockets (~> 2.2.1)
34 + globalid (>= 0.3.0)
26 - activemodel (3.2.22.5)
35 + activemodel (4.2.7.1)
27 - activesupport (= 3.2.22.5)
36 + activesupport (= 4.2.7.1)
28 - builder (~> 3.0.0)
37 + builder (~> 3.1)
29 - activerecord (3.2.22.5)
38 + activerecord (4.2.7.1)
30 - activemodel (= 3.2.22.5)
39 + activemodel (= 4.2.7.1)
31 - activesupport (= 3.2.22.5)
40 + activesupport (= 4.2.7.1)
32 - arel (~> 3.0.2)
41 + arel (~> 6.0)
33 - tzinfo (~> 0.3.29)
42 + activerecord-session_store (1.0.0)
34 - activeresource (3.2.22.5)
43 + actionpack (>= 4.0, < 5.1)
35 - activemodel (= 3.2.22.5)
44 + activerecord (>= 4.0, < 5.1)
36 - activesupport (= 3.2.22.5)
45 + multi_json (~> 1.11, >= 1.11.2)
37 - activesupport (3.2.22.5)
46 + rack (>= 1.5.2, < 3)
38 - i18n (~> 0.6, >= 0.6.4)
47 + railties (>= 4.0, < 5.1)
39 - multi_json (~> 1.0)
48 + activesupport (4.2.7.1)
40 - arel (3.0.3)
49 + i18n (~> 0.7)
41 - autoprefixer-rails (6.0.3)
50 + json (~> 1.7, >= 1.7.7)
51 + minitest (~> 5.1)
52 + thread_safe (~> 0.3, >= 0.3.4)
53 + tzinfo (~> 1.1)
54 + arel (6.0.4)
55 + autoprefixer-rails (6.6.0)
42 execjs
56 execjs
43 - json
44 best_in_place (3.0.3)
57 best_in_place (3.0.3)
45 actionpack (>= 3.2)
58 actionpack (>= 3.2)
46 railties (>= 3.2)
59 railties (>= 3.2)
47 bootstrap-sass (3.2.0.2)
60 bootstrap-sass (3.2.0.2)
48 sass (~> 3.2)
61 sass (~> 3.2)
49 bootstrap-switch-rails (3.3.3)
62 bootstrap-switch-rails (3.3.3)
50 bootstrap-toggle-rails (2.2.1.0)
63 bootstrap-toggle-rails (2.2.1.0)
51 - builder (3.0.4)
64 + builder (3.2.2)
52 - coffee-rails (3.2.2)
65 + coffee-rails (4.2.1)
53 coffee-script (>= 2.2.0)
66 coffee-script (>= 2.2.0)
54 - railties (~> 3.2.0)
67 + railties (>= 4.0.0, < 5.2.x)
55 - coffee-script (2.3.0)
68 + coffee-script (2.4.1)
56 coffee-script-source
69 coffee-script-source
57 execjs
70 execjs
58 - coffee-script-source (1.9.0)
71 + coffee-script-source (1.12.2)
59 - diff-lcs (1.2.5)
72 + concurrent-ruby (1.0.4)
60 dynamic_form (1.1.4)
73 dynamic_form (1.1.4)
61 erubis (2.7.0)
74 erubis (2.7.0)
62 - execjs (2.3.0)
75 + execjs (2.7.0)
63 - haml (4.0.6)
76 + globalid (0.3.7)
77 + activesupport (>= 4.1.0)
78 + haml (4.0.7)
64 tilt
79 tilt
65 - haml-rails (0.4)
80 + haml-rails (0.9.0)
66 - actionpack (>= 3.1, < 4.1)
81 + actionpack (>= 4.0.1)
67 - activesupport (>= 3.1, < 4.1)
82 + activesupport (>= 4.0.1)
68 - haml (>= 3.1, < 4.1)
83 + haml (>= 4.0.6, < 5.0)
69 - railties (>= 3.1, < 4.1)
84 + html2haml (>= 1.0.1)
70 - hike (1.2.3)
85 + railties (>= 4.0.1)
86 + html2haml (2.0.0)
87 + erubis (~> 2.7.0)
88 + haml (~> 4.0.0)
89 + nokogiri (~> 1.6.0)
90 + ruby_parser (~> 3.5)
71 i18n (0.7.0)
91 i18n (0.7.0)
72 in_place_editing (1.2.0)
92 in_place_editing (1.2.0)
73 - journey (1.0.4)
74 jquery-countdown-rails (2.0.2)
93 jquery-countdown-rails (2.0.2)
75 - jquery-rails (3.1.2)
94 + jquery-rails (4.2.1)
76 - railties (>= 3.0, < 5.0)
95 + rails-dom-testing (>= 1, < 3)
96 + railties (>= 4.2.0)
77 thor (>= 0.14, < 2.0)
97 thor (>= 0.14, < 2.0)
78 - jquery-tablesorter (1.13.4)
98 + jquery-tablesorter (1.23.3)
79 - railties (>= 3.1, < 5)
99 + railties (>= 3.2, < 6)
80 jquery-timepicker-addon-rails (1.4.1)
100 jquery-timepicker-addon-rails (1.4.1)
81 railties (>= 3.1)
101 railties (>= 3.1)
82 - jquery-ui-rails (4.0.3)
102 + jquery-ui-rails (6.0.1)
83 - jquery-rails
103 + railties (>= 3.2.16)
84 - railties (>= 3.1.0)
85 - jquery-ui-sass-rails (4.0.3.0)
86 - jquery-rails
87 - jquery-ui-rails (= 4.0.3)
88 - railties (>= 3.1.0)
89 json (1.8.3)
104 json (1.8.3)
90 - mail (2.5.4)
105 + loofah (2.0.3)
91 - mime-types (~> 1.16)
106 + nokogiri (>= 1.5.9)
92 - treetop (~> 1.4.8)
107 + mail (2.6.4)
93 - mime-types (1.25.1)
108 + mime-types (>= 1.16, < 4)
94 - momentjs-rails (2.11.1)
109 + mime-types (3.1)
110 + mime-types-data (~> 3.2015)
111 + mime-types-data (3.2016.0521)
112 + mini_portile2 (2.1.0)
113 + minitest (5.10.1)
114 + momentjs-rails (2.15.1)
95 railties (>= 3.1)
115 railties (>= 3.1)
96 multi_json (1.12.1)
116 multi_json (1.12.1)
97 - mysql2 (0.3.20)
117 + mysql2 (0.4.5)
98 - polyglot (0.3.5)
118 + nokogiri (1.6.8.1)
99 - power_assert (0.2.2)
119 + mini_portile2 (~> 2.1.0)
100 - prototype-rails (3.2.1)
120 + power_assert (0.4.1)
101 - rails (~> 3.2)
121 + rack (1.6.5)
102 - rack (1.4.7)
103 - rack-cache (1.6.1)
104 - rack (>= 0.4)
105 - rack-ssl (1.3.4)
106 - rack
107 rack-test (0.6.3)
122 rack-test (0.6.3)
108 rack (>= 1.0)
123 rack (>= 1.0)
109 - rails (3.2.22.5)
124 + rails (4.2.7.1)
110 - actionmailer (= 3.2.22.5)
125 + actionmailer (= 4.2.7.1)
111 - actionpack (= 3.2.22.5)
126 + actionpack (= 4.2.7.1)
112 - activerecord (= 3.2.22.5)
127 + actionview (= 4.2.7.1)
113 - activeresource (= 3.2.22.5)
128 + activejob (= 4.2.7.1)
114 - activesupport (= 3.2.22.5)
129 + activemodel (= 4.2.7.1)
115 - bundler (~> 1.0)
130 + activerecord (= 4.2.7.1)
116 - railties (= 3.2.22.5)
131 + activesupport (= 4.2.7.1)
117 - rails_bootstrap_sortable (2.0.0)
132 + bundler (>= 1.3.0, < 2.0)
118 - momentjs-rails (~> 2, >= 2.8.3)
133 + railties (= 4.2.7.1)
119 - railties (3.2.22.5)
134 + sprockets-rails
120 - actionpack (= 3.2.22.5)
135 + rails-deprecated_sanitizer (1.0.3)
121 - activesupport (= 3.2.22.5)
136 + activesupport (>= 4.2.0.alpha)
122 - rack-ssl (~> 1.3.2)
137 + rails-dom-testing (1.0.8)
138 + activesupport (>= 4.2.0.beta, < 5.0)
139 + nokogiri (~> 1.6)
140 + rails-deprecated_sanitizer (>= 1.0.1)
141 + rails-html-sanitizer (1.0.3)
142 + loofah (~> 2.0)
143 + rails_bootstrap_sortable (2.0.1)
144 + momentjs-rails (>= 2.8.3)
145 + railties (4.2.7.1)
146 + actionpack (= 4.2.7.1)
147 + activesupport (= 4.2.7.1)
123 rake (>= 0.8.7)
148 rake (>= 0.8.7)
124 - rdoc (~> 3.4)
149 + thor (>= 0.18.1, < 2.0)
125 - thor (>= 0.14.6, < 2.0)
150 + rake (12.0.0)
126 - rake (11.2.2)
151 + rdiscount (2.2.0.1)
127 - rdiscount (2.1.8)
152 + rouge (2.0.7)
128 - rdoc (3.12.2)
153 + ruby_parser (3.8.3)
129 - json (~> 1.4)
154 + sexp_processor (~> 4.1)
130 - rouge (1.8.0)
155 + sass (3.4.23)
131 - rspec-collection_matchers (1.1.2)
156 + sass-rails (5.0.6)
132 - rspec-expectations (>= 2.99.0.beta1)
157 + railties (>= 4.0.0, < 6)
133 - rspec-core (2.99.2)
158 + sass (~> 3.1)
134 - rspec-expectations (2.99.2)
159 + sprockets (>= 2.8, < 4.0)
135 - diff-lcs (>= 1.1.3, < 2.0)
160 + sprockets-rails (>= 2.0, < 4.0)
136 - rspec-mocks (2.99.3)
161 + tilt (>= 1.1, < 3)
137 - rspec-rails (2.99.0)
162 + select2-rails (4.0.3)
138 - actionpack (>= 3.0)
139 - activemodel (>= 3.0)
140 - activesupport (>= 3.0)
141 - railties (>= 3.0)
142 - rspec-collection_matchers
143 - rspec-core (~> 2.99.0)
144 - rspec-expectations (~> 2.99.0)
145 - rspec-mocks (~> 2.99.0)
146 - sass (3.4.11)
147 - sass-rails (3.2.6)
148 - railties (~> 3.2.0)
149 - sass (>= 3.1.10)
150 - tilt (~> 1.3)
151 - select2-rails (4.0.1)
152 thor (~> 0.14)
163 thor (~> 0.14)
153 - sprockets (2.2.3)
164 + sexp_processor (4.7.0)
154 - hike (~> 1.2)
165 + sprockets (3.7.1)
155 - multi_json (~> 1.0)
166 + concurrent-ruby (~> 1.0)
156 - rack (~> 1.0)
167 + rack (> 1, < 3)
157 - tilt (~> 1.1, != 1.3.0)
168 + sprockets-rails (3.2.0)
158 - test-unit (3.0.9)
169 + actionpack (>= 4.0)
170 + activesupport (>= 4.0)
171 + sprockets (>= 3.0.0)
172 + sqlite3 (1.3.12)
173 + test-unit (3.2.3)
159 power_assert
174 power_assert
160 - thor (0.19.1)
175 + thor (0.19.4)
161 - tilt (1.4.1)
176 + thread_safe (0.3.5)
162 - treetop (1.4.15)
177 + tilt (2.0.5)
163 - polyglot
178 + tzinfo (1.2.2)
164 - polyglot (>= 0.3.1)
179 + thread_safe (~> 0.1)
165 - tzinfo (0.3.51)
180 + uglifier (3.0.4)
166 - uglifier (2.7.0)
181 + execjs (>= 0.3.0, < 3)
167 - execjs (>= 0.3.0)
182 + will_paginate (3.0.12)
168 - json (>= 1.8.0)
169 - will_paginate (3.0.7)
170
183
171 PLATFORMS
184 PLATFORMS
172 ruby
185 ruby
173
186
174 DEPENDENCIES
187 DEPENDENCIES
175 ace-rails-ap
188 ace-rails-ap
189 + activerecord-session_store
176 autoprefixer-rails
190 autoprefixer-rails
177 best_in_place (~> 3.0.1)
191 best_in_place (~> 3.0.1)
178 bootstrap-sass (~> 3.2.0)
192 bootstrap-sass (~> 3.2.0)
179 bootstrap-switch-rails
193 bootstrap-switch-rails
180 bootstrap-toggle-rails
194 bootstrap-toggle-rails
181 - coffee-rails (~> 3.2.2)
195 + coffee-rails
182 dynamic_form
196 dynamic_form
183 haml
197 haml
184 haml-rails
198 haml-rails
185 in_place_editing
199 in_place_editing
186 jquery-countdown-rails
200 jquery-countdown-rails
187 jquery-rails
201 jquery-rails
188 jquery-tablesorter
202 jquery-tablesorter
189 jquery-timepicker-addon-rails
203 jquery-timepicker-addon-rails
190 - jquery-ui-sass-rails
204 + jquery-ui-rails
191 mail
205 mail
192 momentjs-rails
206 momentjs-rails
193 mysql2
207 mysql2
194 - prototype-rails
208 + rails (~> 4.2.0)
195 - rails (~> 3.2)
196 rails_bootstrap_sortable
209 rails_bootstrap_sortable
197 rdiscount
210 rdiscount
198 rouge
211 rouge
199 - rspec-rails (~> 2.99.0)
212 + sass-rails
200 - sass-rails (~> 3.2.6)
201 select2-rails
213 select2-rails
214 + sqlite3
202 test-unit
215 test-unit
203 uglifier
216 uglifier
204 verification!
217 verification!
205 will_paginate (~> 3.0.7)
218 will_paginate (~> 3.0.7)
206
219
207 BUNDLED WITH
220 BUNDLED WITH
208 - 1.12.5
221 + 1.13.6
@@ -3,42 +3,39
3 //
3 //
4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 //
6 //
7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 // the compiled file.
8 // the compiled file.
9 //
9 //
10 // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
10 // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11 // GO AFTER THE REQUIRES BELOW.
11 // GO AFTER THE REQUIRES BELOW.
12 //
12 //
13 //= require jquery
13 //= require jquery
14 //= require jquery_ujs
14 //= require jquery_ujs
15 - //= require jquery.ui.all
15 + //= require jquery-ui
16 //= require bootstrap-sprockets
16 //= require bootstrap-sprockets
17 //= require moment
17 //= require moment
18 //= require bootstrap-sortable
18 //= require bootstrap-sortable
19 //= require select2
19 //= require select2
20 //= require ace-rails-ap
20 //= require ace-rails-ap
21 //= require ace/mode-c_cpp
21 //= require ace/mode-c_cpp
22 //= require ace/mode-python
22 //= require ace/mode-python
23 //= require ace/mode-ruby
23 //= require ace/mode-ruby
24 //= require ace/mode-pascal
24 //= require ace/mode-pascal
25 //= require ace/mode-javascript
25 //= require ace/mode-javascript
26 //= require ace/mode-java
26 //= require ace/mode-java
27 //= require ace/theme-merbivore
27 //= require ace/theme-merbivore
28 //= require custom
28 //= require custom
29 //= require jquery.countdown
29 //= require jquery.countdown
30 //-------------- addition from local_jquery -----------
30 //-------------- addition from local_jquery -----------
31 - //= require jquery.ui.datepicker
32 - //= require jquery.ui.slider
33 - //= require jquery-ui-timepicker-addon
34 //= require jquery-tablesorter
31 //= require jquery-tablesorter
35 //= require best_in_place
32 //= require best_in_place
36 //= require best_in_place.jquery-ui
33 //= require best_in_place.jquery-ui
37 //= require brython
34 //= require brython
38
35
39 // since this is after blank line, it is not downloaded
36 // since this is after blank line, it is not downloaded
40 //x= require prototype
37 //x= require prototype
41 //x= require prototype_ujs
38 //x= require prototype_ujs
42 //x= require effects
39 //x= require effects
43 //x= require dragdrop
40 //x= require dragdrop
44 //x= require controls
41 //x= require controls
@@ -1,14 +1,4
1 - //= require jquery
2 - //= require jquery_ujs
3 - //= require jquery.ui.all
4 - //= require jquery.ui.datepicker
5 - //= require jquery.ui.slider
6 - //= require jquery-ui-timepicker-addon
7 - //= require jquery-tablesorter
8 - //= require best_in_place
9 - //= require best_in_place.jquery-ui
10 -
11 $(document).ready(function() {
1 $(document).ready(function() {
12 /* Activating Best In Place */
2 /* Activating Best In Place */
13 jQuery(".best_in_place").best_in_place();
3 jQuery(".best_in_place").best_in_place();
14 });
4 });
@@ -5,29 +5,29
5 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
5 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
6 *
6 *
7 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
7 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
8 * compiled file so the styles you add here take precedence over styles defined in any styles
8 * compiled file so the styles you add here take precedence over styles defined in any styles
9 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
9 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
10 * file per style scope.
10 * file per style scope.
11 *
11 *
12 * // bootstrap says that we should not do this, but @import each file instead
12 * // bootstrap says that we should not do this, but @import each file instead
13 * # *= require_tree .
13 * # *= require_tree .
14 * # *= require_self
14 * # *= require_self
15 */
15 */
16
16
17 - @import "jquery.ui.all";
17 + @import "jquery-ui";
18 - @import "jquery.ui.core";
18 + //@import "jquery.ui.core";
19 - @import "jquery.ui.theme";
19 + //@import "jquery.ui.theme";
20 - @import "jquery.ui.datepicker";
20 + //@import "jquery.ui.datepicker";
21 - @import "jquery.ui.slider";
21 + //@import "jquery.ui.slider";
22 @import "jquery-ui-timepicker-addon";
22 @import "jquery-ui-timepicker-addon";
23 @import "jquery-tablesorter/theme.metro-dark";
23 @import "jquery-tablesorter/theme.metro-dark";
24 @import "jquery.countdown";
24 @import "jquery.countdown";
25 @import "tablesorter-theme.cafe";
25 @import "tablesorter-theme.cafe";
26
26
27 //bootstrap
27 //bootstrap
28 @import "bootstrap-sprockets";
28 @import "bootstrap-sprockets";
29 @import "bootstrap";
29 @import "bootstrap";
30 @import "select2";
30 @import "select2";
31 @import "select2-bootstrap";
31 @import "select2-bootstrap";
32
32
33 //@import bootstrap3-switch
33 //@import bootstrap3-switch
@@ -1,23 +1,22
1 class AnnouncementsController < ApplicationController
1 class AnnouncementsController < ApplicationController
2
2
3 before_filter :admin_authorization
3 before_filter :admin_authorization
4
4
5 in_place_edit_for :announcement, :published
5 in_place_edit_for :announcement, :published
6
6
7 # GET /announcements
7 # GET /announcements
8 # GET /announcements.xml
8 # GET /announcements.xml
9 def index
9 def index
10 - @announcements = Announcement.find(:all,
10 + @announcements = Announcement.order(created_at: :desc)
11 - :order => "created_at DESC")
12
11
13 respond_to do |format|
12 respond_to do |format|
14 format.html # index.html.erb
13 format.html # index.html.erb
15 format.xml { render :xml => @announcements }
14 format.xml { render :xml => @announcements }
16 end
15 end
17 end
16 end
18
17
19 # GET /announcements/1
18 # GET /announcements/1
20 # GET /announcements/1.xml
19 # GET /announcements/1.xml
21 def show
20 def show
22 @announcement = Announcement.find(params[:id])
21 @announcement = Announcement.find(params[:id])
23
22
@@ -57,25 +56,25
57 format.html { render :action => "new" }
56 format.html { render :action => "new" }
58 format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
57 format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
59 end
58 end
60 end
59 end
61 end
60 end
62
61
63 # PUT /announcements/1
62 # PUT /announcements/1
64 # PUT /announcements/1.xml
63 # PUT /announcements/1.xml
65 def update
64 def update
66 @announcement = Announcement.find(params[:id])
65 @announcement = Announcement.find(params[:id])
67
66
68 respond_to do |format|
67 respond_to do |format|
69 - if @announcement.update_attributes(params[:announcement])
68 + if @announcement.update_attributes(announcement_params)
70 flash[:notice] = 'Announcement was successfully updated.'
69 flash[:notice] = 'Announcement was successfully updated.'
71 format.html { redirect_to(@announcement) }
70 format.html { redirect_to(@announcement) }
72 format.js {}
71 format.js {}
73 format.xml { head :ok }
72 format.xml { head :ok }
74 else
73 else
75 format.html { render :action => "edit" }
74 format.html { render :action => "edit" }
76 format.js {}
75 format.js {}
77 format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
76 format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
78 end
77 end
79 end
78 end
80 end
79 end
81
80
@@ -99,13 +98,19
99
98
100 # DELETE /announcements/1
99 # DELETE /announcements/1
101 # DELETE /announcements/1.xml
100 # DELETE /announcements/1.xml
102 def destroy
101 def destroy
103 @announcement = Announcement.find(params[:id])
102 @announcement = Announcement.find(params[:id])
104 @announcement.destroy
103 @announcement.destroy
105
104
106 respond_to do |format|
105 respond_to do |format|
107 format.html { redirect_to(announcements_url) }
106 format.html { redirect_to(announcements_url) }
108 format.xml { head :ok }
107 format.xml { head :ok }
109 end
108 end
110 end
109 end
110 +
111 + private
112 +
113 + def announcement_params
114 + params.require(:announcement).permit(:author, :body, :published, :frontpage, :contest_only,:title, :note)
111 end
115 end
116 + end
@@ -11,25 +11,25
11 flash[:notice] = 'You are not authorized to view the page you requested'
11 flash[:notice] = 'You are not authorized to view the page you requested'
12 redirect_to :controller => 'main', :action => 'login'
12 redirect_to :controller => 'main', :action => 'login'
13 end
13 end
14
14
15 # Returns the current logged-in user (if any).
15 # Returns the current logged-in user (if any).
16 def current_user
16 def current_user
17 return nil unless session[:user_id]
17 return nil unless session[:user_id]
18 @current_user ||= User.find(session[:user_id])
18 @current_user ||= User.find(session[:user_id])
19 end
19 end
20
20
21 def admin_authorization
21 def admin_authorization
22 return false unless authenticate
22 return false unless authenticate
23 - user = User.find(session[:user_id], :include => ['roles'])
23 + user = User.includes(:roles).find(session[:user_id])
24 unless user.admin?
24 unless user.admin?
25 unauthorized_redirect
25 unauthorized_redirect
26 return false
26 return false
27 end
27 end
28 return true
28 return true
29 end
29 end
30
30
31 def authorization_by_roles(allowed_roles)
31 def authorization_by_roles(allowed_roles)
32 return false unless authenticate
32 return false unless authenticate
33 user = User.find(session[:user_id])
33 user = User.find(session[:user_id])
34 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
34 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
35 unauthorized_redirect
35 unauthorized_redirect
@@ -1,30 +1,34
1 class ConfigurationsController < ApplicationController
1 class ConfigurationsController < ApplicationController
2
2
3 before_filter :authenticate
3 before_filter :authenticate
4 before_filter { |controller| controller.authorization_by_roles(['admin'])}
4 before_filter { |controller| controller.authorization_by_roles(['admin'])}
5
5
6
6
7 def index
7 def index
8 - @configurations = GraderConfiguration.find(:all,
8 + @configurations = GraderConfiguration.order(:key)
9 - :order => '`key`')
10 @group = GraderConfiguration.pluck("grader_configurations.key").map{ |x| x[0...(x.index('.'))] }.uniq.sort
9 @group = GraderConfiguration.pluck("grader_configurations.key").map{ |x| x[0...(x.index('.'))] }.uniq.sort
11 end
10 end
12
11
13 def reload
12 def reload
14 GraderConfiguration.reload
13 GraderConfiguration.reload
15 redirect_to :action => 'index'
14 redirect_to :action => 'index'
16 end
15 end
17
16
18 def update
17 def update
19 @config = GraderConfiguration.find(params[:id])
18 @config = GraderConfiguration.find(params[:id])
20 User.clear_last_login if @config.key == GraderConfiguration::MULTIPLE_IP_LOGIN_KEY and @config.value == 'true' and params[:grader_configuration][:value] == 'false'
19 User.clear_last_login if @config.key == GraderConfiguration::MULTIPLE_IP_LOGIN_KEY and @config.value == 'true' and params[:grader_configuration][:value] == 'false'
21 respond_to do |format|
20 respond_to do |format|
22 - if @config.update_attributes(params[:grader_configuration])
21 + if @config.update_attributes(configuration_params)
23 format.json { head :ok }
22 format.json { head :ok }
24 else
23 else
25 format.json { respond_with_bip(@config) }
24 format.json { respond_with_bip(@config) }
26 end
25 end
27 end
26 end
28 end
27 end
29
28
29 + private
30 + def configuration_params
31 + params.require(:grader_configuration).permit(:key,:value_type,:value,:description)
30 end
32 end
33 +
34 + end
@@ -2,27 +2,27
2
2
3 before_filter :admin_authorization
3 before_filter :admin_authorization
4
4
5 def index
5 def index
6 @num_contests = Contest.count()
6 @num_contests = Contest.count()
7 end
7 end
8
8
9 def user_stat
9 def user_stat
10 if not GraderConfiguration.indv_contest_mode?
10 if not GraderConfiguration.indv_contest_mode?
11 redirect_to :action => 'index' and return
11 redirect_to :action => 'index' and return
12 end
12 end
13
13
14 - @users = User.find(:all)
14 + @users = User.all
15 @start_times = {}
15 @start_times = {}
16 - UserContestStat.find(:all).each do |stat|
16 + UserContestStat.all.each do |stat|
17 @start_times[stat.user_id] = stat.started_at
17 @start_times[stat.user_id] = stat.started_at
18 end
18 end
19 end
19 end
20
20
21 def clear_stat
21 def clear_stat
22 user = User.find(params[:id])
22 user = User.find(params[:id])
23 if user.contest_stat!=nil
23 if user.contest_stat!=nil
24 user.contest_stat.destroy
24 user.contest_stat.destroy
25 end
25 end
26 redirect_to :action => 'user_stat'
26 redirect_to :action => 'user_stat'
27 end
27 end
28
28
@@ -57,36 +57,42
57 format.html { render :action => "new" }
57 format.html { render :action => "new" }
58 format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }
58 format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }
59 end
59 end
60 end
60 end
61 end
61 end
62
62
63 # PUT /contests/1
63 # PUT /contests/1
64 # PUT /contests/1.xml
64 # PUT /contests/1.xml
65 def update
65 def update
66 @contest = Contest.find(params[:id])
66 @contest = Contest.find(params[:id])
67
67
68 respond_to do |format|
68 respond_to do |format|
69 - if @contest.update_attributes(params[:contest])
69 + if @contest.update_attributes(contests_params)
70 flash[:notice] = 'Contest was successfully updated.'
70 flash[:notice] = 'Contest was successfully updated.'
71 format.html { redirect_to(@contest) }
71 format.html { redirect_to(@contest) }
72 format.xml { head :ok }
72 format.xml { head :ok }
73 else
73 else
74 format.html { render :action => "edit" }
74 format.html { render :action => "edit" }
75 format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }
75 format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }
76 end
76 end
77 end
77 end
78 end
78 end
79
79
80 # DELETE /contests/1
80 # DELETE /contests/1
81 # DELETE /contests/1.xml
81 # DELETE /contests/1.xml
82 def destroy
82 def destroy
83 @contest = Contest.find(params[:id])
83 @contest = Contest.find(params[:id])
84 @contest.destroy
84 @contest.destroy
85
85
86 respond_to do |format|
86 respond_to do |format|
87 format.html { redirect_to(contests_url) }
87 format.html { redirect_to(contests_url) }
88 format.xml { head :ok }
88 format.xml { head :ok }
89 end
89 end
90 end
90 end
91
91
92 + private
93 +
94 + def contests_params
95 + params.require(:contest).permit(:title,:enabled,:name)
92 end
96 end
97 +
98 + end
@@ -26,47 +26,45
26 :redirect_to => {:action => 'index'}
26 :redirect_to => {:action => 'index'}
27
27
28 def index
28 def index
29 redirect_to :action => 'list'
29 redirect_to :action => 'list'
30 end
30 end
31
31
32 def list
32 def list
33 @grader_processes = GraderProcess.find_running_graders
33 @grader_processes = GraderProcess.find_running_graders
34 @stalled_processes = GraderProcess.find_stalled_process
34 @stalled_processes = GraderProcess.find_stalled_process
35
35
36 @terminated_processes = GraderProcess.find_terminated_graders
36 @terminated_processes = GraderProcess.find_terminated_graders
37
37
38 - @last_task = Task.find(:first,
38 + @last_task = Task.last
39 - :order => 'created_at DESC')
39 + @last_test_request = TestRequest.last
40 - @last_test_request = TestRequest.find(:first,
41 - :order => 'created_at DESC')
42 @submission = Submission.order("id desc").limit(20)
40 @submission = Submission.order("id desc").limit(20)
43 @backlog_submission = Submission.where('graded_at is null')
41 @backlog_submission = Submission.where('graded_at is null')
44 end
42 end
45
43
46 def clear
44 def clear
47 grader_proc = GraderProcess.find(params[:id])
45 grader_proc = GraderProcess.find(params[:id])
48 grader_proc.destroy if grader_proc!=nil
46 grader_proc.destroy if grader_proc!=nil
49 redirect_to :action => 'list'
47 redirect_to :action => 'list'
50 end
48 end
51
49
52 def clear_terminated
50 def clear_terminated
53 GraderProcess.find_terminated_graders.each do |p|
51 GraderProcess.find_terminated_graders.each do |p|
54 p.destroy
52 p.destroy
55 end
53 end
56 redirect_to :action => 'list'
54 redirect_to :action => 'list'
57 end
55 end
58
56
59 def clear_all
57 def clear_all
60 - GraderProcess.find(:all).each do |p|
58 + GraderProcess.all.each do |p|
61 p.destroy
59 p.destroy
62 end
60 end
63 redirect_to :action => 'list'
61 redirect_to :action => 'list'
64 end
62 end
65
63
66 def view
64 def view
67 if params[:type]=='Task'
65 if params[:type]=='Task'
68 redirect_to :action => 'task', :id => params[:id]
66 redirect_to :action => 'task', :id => params[:id]
69 else
67 else
70 redirect_to :action => 'test_request', :id => params[:id]
68 redirect_to :action => 'test_request', :id => params[:id]
71 end
69 end
72 end
70 end
@@ -36,25 +36,25
36 flash.now[:notice] = saved_notice
36 flash.now[:notice] = saved_notice
37
37
38 # EXPERIMENT:
38 # EXPERIMENT:
39 # Hide login if in single user mode and the url does not
39 # Hide login if in single user mode and the url does not
40 # explicitly specify /login
40 # explicitly specify /login
41 #
41 #
42 # logger.info "PATH: #{request.path}"
42 # logger.info "PATH: #{request.path}"
43 # if GraderConfiguration['system.single_user_mode'] and
43 # if GraderConfiguration['system.single_user_mode'] and
44 # request.path!='/main/login'
44 # request.path!='/main/login'
45 # @hidelogin = true
45 # @hidelogin = true
46 # end
46 # end
47
47
48 - @announcements = Announcement.find_for_frontpage
48 + @announcements = Announcement.frontpage
49 render :action => 'login', :layout => 'empty'
49 render :action => 'login', :layout => 'empty'
50 end
50 end
51
51
52 def list
52 def list
53 prepare_list_information
53 prepare_list_information
54 end
54 end
55
55
56 def help
56 def help
57 @user = User.find(session[:user_id])
57 @user = User.find(session[:user_id])
58 end
58 end
59
59
60 def submit
60 def submit
@@ -208,27 +208,27
208 user.update_start_time
208 user.update_start_time
209 redirect_to :action => 'list'
209 redirect_to :action => 'list'
210 else
210 else
211 @contests = user.contests
211 @contests = user.contests
212 @user = user
212 @user = user
213 end
213 end
214 end
214 end
215
215
216 protected
216 protected
217
217
218 def prepare_announcements(recent=nil)
218 def prepare_announcements(recent=nil)
219 if GraderConfiguration.show_tasks_to?(@user)
219 if GraderConfiguration.show_tasks_to?(@user)
220 - @announcements = Announcement.find_published(true)
220 + @announcements = Announcement.published(true)
221 else
221 else
222 - @announcements = Announcement.find_published
222 + @announcements = Announcement.published
223 end
223 end
224 if recent!=nil
224 if recent!=nil
225 recent_id = recent.to_i
225 recent_id = recent.to_i
226 @announcements = @announcements.find_all { |a| a.id > recent_id }
226 @announcements = @announcements.find_all { |a| a.id > recent_id }
227 end
227 end
228 end
228 end
229
229
230 def prepare_list_information
230 def prepare_list_information
231 @user = User.find(session[:user_id])
231 @user = User.find(session[:user_id])
232 if not GraderConfiguration.multicontests?
232 if not GraderConfiguration.multicontests?
233 @problems = @user.available_problems
233 @problems = @user.available_problems
234 else
234 else
@@ -1,22 +1,22
1 class ProblemsController < ApplicationController
1 class ProblemsController < ApplicationController
2
2
3 before_filter :authenticate, :authorization
3 before_filter :authenticate, :authorization
4
4
5 in_place_edit_for :problem, :name
5 in_place_edit_for :problem, :name
6 in_place_edit_for :problem, :full_name
6 in_place_edit_for :problem, :full_name
7 in_place_edit_for :problem, :full_score
7 in_place_edit_for :problem, :full_score
8
8
9 def index
9 def index
10 - @problems = Problem.find(:all, :order => 'date_added DESC')
10 + @problems = Problem.order(date_added: :desc)
11 end
11 end
12
12
13 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
13 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
14 verify :method => :post, :only => [ :create, :quick_create,
14 verify :method => :post, :only => [ :create, :quick_create,
15 :do_manage,
15 :do_manage,
16 :do_import,
16 :do_import,
17 ],
17 ],
18 :redirect_to => { :action => :index }
18 :redirect_to => { :action => :index }
19
19
20 def show
20 def show
21 @problem = Problem.find(params[:id])
21 @problem = Problem.find(params[:id])
22 end
22 end
@@ -126,35 +126,33
126 end
126 end
127 end
127 end
128
128
129 def toggle_test
129 def toggle_test
130 @problem = Problem.find(params[:id])
130 @problem = Problem.find(params[:id])
131 @problem.update_attributes(test_allowed: !(@problem.test_allowed?) )
131 @problem.update_attributes(test_allowed: !(@problem.test_allowed?) )
132 respond_to do |format|
132 respond_to do |format|
133 format.js { }
133 format.js { }
134 end
134 end
135 end
135 end
136
136
137 def turn_all_off
137 def turn_all_off
138 - Problem.find(:all,
138 + Problem.available.all.each do |problem|
139 - :conditions => "available = 1").each do |problem|
140 problem.available = false
139 problem.available = false
141 problem.save
140 problem.save
142 end
141 end
143 redirect_to action: :index
142 redirect_to action: :index
144 end
143 end
145
144
146 def turn_all_on
145 def turn_all_on
147 - Problem.find(:all,
146 + Problem.where.not(available: true).each do |problem|
148 - :conditions => "available = 0").each do |problem|
149 problem.available = true
147 problem.available = true
150 problem.save
148 problem.save
151 end
149 end
152 redirect_to action: :index
150 redirect_to action: :index
153 end
151 end
154
152
155 def stat
153 def stat
156 @problem = Problem.find(params[:id])
154 @problem = Problem.find(params[:id])
157 unless @problem.available or session[:admin]
155 unless @problem.available or session[:admin]
158 redirect_to :controller => 'main', :action => 'list'
156 redirect_to :controller => 'main', :action => 'list'
159 return
157 return
160 end
158 end
@@ -167,25 +165,25
167 @submissions.find_each do |sub|
165 @submissions.find_each do |sub|
168 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
166 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
169 @histogram[:data][d.to_i] += 1 if d < range
167 @histogram[:data][d.to_i] += 1 if d < range
170 user[sub.user_id] = [user[sub.user_id], ((sub.try(:points) || 0) >= @problem.full_score) ? 1 : 0].max
168 user[sub.user_id] = [user[sub.user_id], ((sub.try(:points) || 0) >= @problem.full_score) ? 1 : 0].max
171 end
169 end
172 @histogram[:summary][:max] = [@histogram[:data].max,1].max
170 @histogram[:summary][:max] = [@histogram[:data].max,1].max
173
171
174 @summary = { attempt: user.count, solve: 0 }
172 @summary = { attempt: user.count, solve: 0 }
175 user.each_value { |v| @summary[:solve] += 1 if v == 1 }
173 user.each_value { |v| @summary[:solve] += 1 if v == 1 }
176 end
174 end
177
175
178 def manage
176 def manage
179 - @problems = Problem.find(:all, :order => 'date_added DESC')
177 + @problems = Problem.order(date_added: :desc)
180 end
178 end
181
179
182 def do_manage
180 def do_manage
183 if params.has_key? 'change_date_added'
181 if params.has_key? 'change_date_added'
184 change_date_added
182 change_date_added
185 elsif params.has_key? 'add_to_contest'
183 elsif params.has_key? 'add_to_contest'
186 add_to_contest
184 add_to_contest
187 elsif params.has_key? 'enable_problem'
185 elsif params.has_key? 'enable_problem'
188 set_available(true)
186 set_available(true)
189 elsif params.has_key? 'disable_problem'
187 elsif params.has_key? 'disable_problem'
190 set_available(false)
188 set_available(false)
191 end
189 end
@@ -1,35 +1,31
1 require 'csv'
1 require 'csv'
2
2
3 class ReportController < ApplicationController
3 class ReportController < ApplicationController
4
4
5 before_filter :authenticate
5 before_filter :authenticate
6
6
7 before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize, :show_max_score]
7 before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize, :show_max_score]
8
8
9 before_filter(only: [:problem_hof]) { |c|
9 before_filter(only: [:problem_hof]) { |c|
10 return false unless authenticate
10 return false unless authenticate
11
11
12 - if GraderConfiguration["right.user_view_submission"]
12 + admin_authorization unless GraderConfiguration["right.user_view_submission"]
13 - return true;
14 - end
15 -
16 - admin_authorization
17 }
13 }
18
14
19 def max_score
15 def max_score
20 end
16 end
21
17
22 def current_score
18 def current_score
23 - @problems = Problem.find_available_problems
19 + @problems = Problem.available_problems
24 @users = User.includes(:contests).includes(:contest_stat).where(enabled: true)
20 @users = User.includes(:contests).includes(:contest_stat).where(enabled: true)
25 @scorearray = calculate_max_score(@problems, @users,0,0,true)
21 @scorearray = calculate_max_score(@problems, @users,0,0,true)
26
22
27 #rencer accordingly
23 #rencer accordingly
28 if params[:button] == 'download' then
24 if params[:button] == 'download' then
29 csv = gen_csv_from_scorearray(@scorearray,@problems)
25 csv = gen_csv_from_scorearray(@scorearray,@problems)
30 send_data csv, filename: 'max_score.csv'
26 send_data csv, filename: 'max_score.csv'
31 else
27 else
32 #render template: 'user_admin/user_stat'
28 #render template: 'user_admin/user_stat'
33 render 'current_score'
29 render 'current_score'
34 end
30 end
35 end
31 end
@@ -37,25 +33,25
37 def show_max_score
33 def show_max_score
38 #process parameters
34 #process parameters
39 #problems
35 #problems
40 @problems = []
36 @problems = []
41 params[:problem_id].each do |id|
37 params[:problem_id].each do |id|
42 next unless id.strip != ""
38 next unless id.strip != ""
43 pid = Problem.find_by_id(id.to_i)
39 pid = Problem.find_by_id(id.to_i)
44 @problems << pid if pid
40 @problems << pid if pid
45 end
41 end
46
42
47 #users
43 #users
48 @users = if params[:user] == "all" then
44 @users = if params[:user] == "all" then
49 - User.find(:all, :include => [:contests, :contest_stat])
45 + User.includes(:contests).includes(:contest_stat)
50 else
46 else
51 User.includes(:contests).includes(:contest_stat).where(enabled: true)
47 User.includes(:contests).includes(:contest_stat).where(enabled: true)
52 end
48 end
53
49
54 #set up range from param
50 #set up range from param
55 since_id = params.fetch(:from_id, 0).to_i
51 since_id = params.fetch(:from_id, 0).to_i
56 until_id = params.fetch(:to_id, 0).to_i
52 until_id = params.fetch(:to_id, 0).to_i
57
53
58 #calculate the routine
54 #calculate the routine
59 @scorearray = calculate_max_score(@problems, @users,since_id,until_id)
55 @scorearray = calculate_max_score(@problems, @users,since_id,until_id)
60
56
61 #rencer accordingly
57 #rencer accordingly
@@ -64,27 +60,27
64 send_data csv, filename: 'max_score.csv'
60 send_data csv, filename: 'max_score.csv'
65 else
61 else
66 #render template: 'user_admin/user_stat'
62 #render template: 'user_admin/user_stat'
67 render 'max_score'
63 render 'max_score'
68 end
64 end
69
65
70 end
66 end
71
67
72 def score
68 def score
73 if params[:commit] == 'download csv'
69 if params[:commit] == 'download csv'
74 @problems = Problem.all
70 @problems = Problem.all
75 else
71 else
76 - @problems = Problem.find_available_problems
72 + @problems = Problem.available_problems
77 end
73 end
78 - @users = User.includes(:contests, :contest_stat).where(enabled: true) #find(:all, :include => [:contests, :contest_stat]).where(enabled: true)
74 + @users = User.includes(:contests, :contest_stat).where(enabled: true)
79 @scorearray = Array.new
75 @scorearray = Array.new
80 @users.each do |u|
76 @users.each do |u|
81 ustat = Array.new
77 ustat = Array.new
82 ustat[0] = u
78 ustat[0] = u
83 @problems.each do |p|
79 @problems.each do |p|
84 sub = Submission.find_last_by_user_and_problem(u.id,p.id)
80 sub = Submission.find_last_by_user_and_problem(u.id,p.id)
85 if (sub!=nil) and (sub.points!=nil) and p and p.full_score
81 if (sub!=nil) and (sub.points!=nil) and p and p.full_score
86 ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
82 ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
87 else
83 else
88 ustat << [0,false]
84 ustat << [0,false]
89 end
85 end
90 end
86 end
@@ -1,19 +1,19
1 class SiteController < ApplicationController
1 class SiteController < ApplicationController
2
2
3 before_filter :site_admin_authorization, :except => 'login'
3 before_filter :site_admin_authorization, :except => 'login'
4
4
5 def login
5 def login
6 # Site administrator login
6 # Site administrator login
7 - @countries = Country.find(:all, :include => :sites)
7 + @countries = Country.includes(:sites).all
8 @country_select = @countries.collect { |c| [c.name, c.id] }
8 @country_select = @countries.collect { |c| [c.name, c.id] }
9
9
10 @country_select_with_all = [['Any',0]]
10 @country_select_with_all = [['Any',0]]
11 @countries.each do |country|
11 @countries.each do |country|
12 @country_select_with_all << [country.name, country.id]
12 @country_select_with_all << [country.name, country.id]
13 end
13 end
14
14
15 @site_select = []
15 @site_select = []
16 @countries.each do |country|
16 @countries.each do |country|
17 country.sites.each do |site|
17 country.sites.each do |site|
18 @site_select << ["#{site.name}, #{country.name}", site.id]
18 @site_select << ["#{site.name}, #{country.name}", site.id]
19 end
19 end
@@ -50,13 +50,18
50 redirect_to :controller => 'site', :action => 'login' and return
50 redirect_to :controller => 'site', :action => 'login' and return
51 end
51 end
52 begin
52 begin
53 @site = Site.find(session[:site_id], :include => :country)
53 @site = Site.find(session[:site_id], :include => :country)
54 rescue ActiveRecord::RecordNotFound
54 rescue ActiveRecord::RecordNotFound
55 @site = nil
55 @site = nil
56 end
56 end
57 if @site==nil
57 if @site==nil
58 redirect_to :controller => 'site', :action => 'login' and return
58 redirect_to :controller => 'site', :action => 'login' and return
59 end
59 end
60 end
60 end
61
61
62 + private
63 + def site_params
64 + params.require(:site).permit()
62 end
65 end
66 +
67 + end
@@ -1,20 +1,20
1 class SitesController < ApplicationController
1 class SitesController < ApplicationController
2
2
3 before_filter :admin_authorization
3 before_filter :admin_authorization
4
4
5 # GET /sites
5 # GET /sites
6 # GET /sites.xml
6 # GET /sites.xml
7 def index
7 def index
8 - @sites = Site.find(:all, :order => 'country_id')
8 + @sites = Site.order(:country_id)
9
9
10 respond_to do |format|
10 respond_to do |format|
11 format.html # index.html.erb
11 format.html # index.html.erb
12 format.xml { render :xml => @sites }
12 format.xml { render :xml => @sites }
13 end
13 end
14 end
14 end
15
15
16 # GET /sites/1
16 # GET /sites/1
17 # GET /sites/1.xml
17 # GET /sites/1.xml
18 def show
18 def show
19 @site = Site.find(params[:id])
19 @site = Site.find(params[:id])
20
20
@@ -56,36 +56,42
56 format.xml { render :xml => @site.errors, :status => :unprocessable_entity }
56 format.xml { render :xml => @site.errors, :status => :unprocessable_entity }
57 end
57 end
58 end
58 end
59 end
59 end
60
60
61 # PUT /sites/1
61 # PUT /sites/1
62 # PUT /sites/1.xml
62 # PUT /sites/1.xml
63 def update
63 def update
64 @site = Site.find(params[:id])
64 @site = Site.find(params[:id])
65 @site.clear_start_time_if_not_started
65 @site.clear_start_time_if_not_started
66
66
67 respond_to do |format|
67 respond_to do |format|
68 - if @site.update_attributes(params[:site])
68 + if @site.update_attributes(site_params)
69 flash[:notice] = 'Site was successfully updated.'
69 flash[:notice] = 'Site was successfully updated.'
70 format.html { redirect_to(@site) }
70 format.html { redirect_to(@site) }
71 format.xml { head :ok }
71 format.xml { head :ok }
72 else
72 else
73 format.html { render :action => "edit" }
73 format.html { render :action => "edit" }
74 format.xml { render :xml => @site.errors, :status => :unprocessable_entity }
74 format.xml { render :xml => @site.errors, :status => :unprocessable_entity }
75 end
75 end
76 end
76 end
77 end
77 end
78
78
79 # DELETE /sites/1
79 # DELETE /sites/1
80 # DELETE /sites/1.xml
80 # DELETE /sites/1.xml
81 def destroy
81 def destroy
82 @site = Site.find(params[:id])
82 @site = Site.find(params[:id])
83 @site.destroy
83 @site.destroy
84
84
85 respond_to do |format|
85 respond_to do |format|
86 format.html { redirect_to(sites_url) }
86 format.html { redirect_to(sites_url) }
87 format.xml { head :ok }
87 format.xml { head :ok }
88 end
88 end
89 end
89 end
90
90
91 + private
92 +
93 + def site_params
94 + params.require(:site).permit(:name,:started,:start_time,:country_id,:password)
91 end
95 end
96 +
97 + end
@@ -1,15 +1,15
1 class SubmissionsController < ApplicationController
1 class SubmissionsController < ApplicationController
2 before_filter :authenticate
2 before_filter :authenticate
3 - before_filter :submission_authorization, only: [:show, :direct_edit_submission]
3 + before_filter :submission_authorization, only: [:show, :direct_edit_submission, :download]
4
4
5 # GET /submissions
5 # GET /submissions
6 # GET /submissions.json
6 # GET /submissions.json
7 # Show problem selection and user's submission of that problem
7 # Show problem selection and user's submission of that problem
8 def index
8 def index
9 @user = @current_user
9 @user = @current_user
10 @problems = @user.available_problems
10 @problems = @user.available_problems
11
11
12 if params[:problem_id]==nil
12 if params[:problem_id]==nil
13 @problem = nil
13 @problem = nil
14 @submissions = nil
14 @submissions = nil
15 else
15 else
@@ -24,24 +24,36
24 end
24 end
25
25
26 # GET /submissions/1
26 # GET /submissions/1
27 # GET /submissions/1.json
27 # GET /submissions/1.json
28 def show
28 def show
29 @submission = Submission.find(params[:id])
29 @submission = Submission.find(params[:id])
30
30
31 #log the viewing
31 #log the viewing
32 user = User.find(session[:user_id])
32 user = User.find(session[:user_id])
33 SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin?
33 SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin?
34 end
34 end
35
35
36 + def download
37 + @submission = Submission.find(params[:id])
38 + send_data(@submission.source, {:filename => @submission.download_filename, :type => 'text/plain'})
39 + end
40 +
41 + def compiler_msg
42 + @submission = Submission.find(params[:id])
43 + respond_to do |format|
44 + format.js
45 + end
46 + end
47 +
36 #on-site new submission on specific problem
48 #on-site new submission on specific problem
37 def direct_edit_problem
49 def direct_edit_problem
38 @problem = Problem.find(params[:problem_id])
50 @problem = Problem.find(params[:problem_id])
39 @source = ''
51 @source = ''
40 render 'edit'
52 render 'edit'
41 end
53 end
42
54
43 # GET /submissions/1/edit
55 # GET /submissions/1/edit
44 def edit
56 def edit
45 @submission = Submission.find(params[:id])
57 @submission = Submission.find(params[:id])
46 @source = @submission.source.to_s
58 @source = @submission.source.to_s
47 @problem = @submission.problem
59 @problem = @submission.problem
@@ -51,87 +63,34
51
63
52 def get_latest_submission_status
64 def get_latest_submission_status
53 @problem = Problem.find(params[:pid])
65 @problem = Problem.find(params[:pid])
54 @submission = Submission.find_last_by_user_and_problem(params[:uid],params[:pid])
66 @submission = Submission.find_last_by_user_and_problem(params[:uid],params[:pid])
55 puts User.find(params[:uid]).login
67 puts User.find(params[:uid]).login
56 puts Problem.find(params[:pid]).name
68 puts Problem.find(params[:pid]).name
57 puts 'nil' unless @submission
69 puts 'nil' unless @submission
58 respond_to do |format|
70 respond_to do |format|
59 format.js
71 format.js
60 end
72 end
61 end
73 end
62
74
63 - # # GET /submissions/new
64 - # # GET /submissions/new.json
65 - # def new
66 - # @submission = Submission.new
67 - #
68 - # respond_to do |format|
69 - # format.html # new.html.erb
70 - # format.json { render json: @submission }
71 - # end
72 - # end
73 - #
74 - #
75 - # # POST /submissions
76 - # # POST /submissions.json
77 - # def create
78 - # @submission = Submission.new(params[:submission])
79 - #
80 - # respond_to do |format|
81 - # if @submission.save
82 - # format.html { redirect_to @submission, notice: 'Submission was successfully created.' }
83 - # format.json { render json: @submission, status: :created, location: @submission }
84 - # else
85 - # format.html { render action: "new" }
86 - # format.json { render json: @submission.errors, status: :unprocessable_entity }
87 - # end
88 - # end
89 - # end
90 - #
91 - # # PUT /submissions/1
92 - # # PUT /submissions/1.json
93 - # def update
94 - # @submission = Submission.find(params[:id])
95 - #
96 - # respond_to do |format|
97 - # if @submission.update_attributes(params[:submission])
98 - # format.html { redirect_to @submission, notice: 'Submission was successfully updated.' }
99 - # format.json { head :no_content }
100 - # else
101 - # format.html { render action: "edit" }
102 - # format.json { render json: @submission.errors, status: :unprocessable_entity }
103 - # end
104 - # end
105 - # end
106 - #
107 - # # DELETE /submissions/1
108 - # # DELETE /submissions/1.json
109 - # def destroy
110 - # @submission = Submission.find(params[:id])
111 - # @submission.destroy
112 - #
113 - # respond_to do |format|
114 - # format.html { redirect_to submissions_url }
115 - # format.json { head :no_content }
116 - # end
117 - # end
118
75
119 protected
76 protected
77 +
120 def submission_authorization
78 def submission_authorization
121 #admin always has privileged
79 #admin always has privileged
122 if @current_user.admin?
80 if @current_user.admin?
123 return true
81 return true
124 end
82 end
125
83
126 sub = Submission.find(params[:id])
84 sub = Submission.find(params[:id])
127 if sub.problem.available?
85 if sub.problem.available?
128 puts "sub = #{sub.user.id}, current = #{@current_user.id}"
86 puts "sub = #{sub.user.id}, current = #{@current_user.id}"
129 return true if GraderConfiguration["right.user_view_submission"] or sub.user == @current_user
87 return true if GraderConfiguration["right.user_view_submission"] or sub.user == @current_user
130 end
88 end
131
89
132 #default to NO
90 #default to NO
133 unauthorized_redirect
91 unauthorized_redirect
134 return false
92 return false
135 end
93 end
136
94
95 +
137 end
96 end
@@ -20,25 +20,25
20 if params[:page] == 'all'
20 if params[:page] == 'all'
21 @users = User.all
21 @users = User.all
22 @paginated = false
22 @paginated = false
23 else
23 else
24 @users = User.paginate :page => params[:page]
24 @users = User.paginate :page => params[:page]
25 @paginated = true
25 @paginated = true
26 end
26 end
27 @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at']
27 @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at']
28 @contests = Contest.enabled
28 @contests = Contest.enabled
29 end
29 end
30
30
31 def active
31 def active
32 - sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago])
32 + sessions = ActiveRecord::SessionStore::Session.where("updated_at >= ?", 60.minutes.ago)
33 @users = []
33 @users = []
34 sessions.each do |session|
34 sessions.each do |session|
35 if session.data[:user_id]
35 if session.data[:user_id]
36 @users << User.find(session.data[:user_id])
36 @users << User.find(session.data[:user_id])
37 end
37 end
38 end
38 end
39 end
39 end
40
40
41 def show
41 def show
42 @user = User.find(params[:id])
42 @user = User.find(params[:id])
43 end
43 end
44
44
@@ -109,44 +109,44
109 flash[:notice] = 'User(s) ' + note.join(', ') +
109 flash[:notice] = 'User(s) ' + note.join(', ') +
110 ' were successfully created. ' +
110 ' were successfully created. ' +
111 '( (+) - created with random passwords.)'
111 '( (+) - created with random passwords.)'
112 redirect_to :action => 'index'
112 redirect_to :action => 'index'
113 end
113 end
114
114
115 def edit
115 def edit
116 @user = User.find(params[:id])
116 @user = User.find(params[:id])
117 end
117 end
118
118
119 def update
119 def update
120 @user = User.find(params[:id])
120 @user = User.find(params[:id])
121 - if @user.update_attributes(params[:user])
121 + if @user.update_attributes(user_params)
122 flash[:notice] = 'User was successfully updated.'
122 flash[:notice] = 'User was successfully updated.'
123 redirect_to :action => 'show', :id => @user
123 redirect_to :action => 'show', :id => @user
124 else
124 else
125 render :action => 'edit'
125 render :action => 'edit'
126 end
126 end
127 end
127 end
128
128
129 def destroy
129 def destroy
130 User.find(params[:id]).destroy
130 User.find(params[:id]).destroy
131 redirect_to :action => 'index'
131 redirect_to :action => 'index'
132 end
132 end
133
133
134 def user_stat
134 def user_stat
135 if params[:commit] == 'download csv'
135 if params[:commit] == 'download csv'
136 @problems = Problem.all
136 @problems = Problem.all
137 else
137 else
138 - @problems = Problem.find_available_problems
138 + @problems = Problem.available_problems
139 end
139 end
140 - @users = User.includes(:contests, :contest_stat).where(enabled: true) #find(:all, :include => [:contests, :contest_stat]).where(enabled: true)
140 + @users = User.includes(:contests, :contest_stat).where(enabled: true)
141 @scorearray = Array.new
141 @scorearray = Array.new
142 @users.each do |u|
142 @users.each do |u|
143 ustat = Array.new
143 ustat = Array.new
144 ustat[0] = u
144 ustat[0] = u
145 @problems.each do |p|
145 @problems.each do |p|
146 sub = Submission.find_last_by_user_and_problem(u.id,p.id)
146 sub = Submission.find_last_by_user_and_problem(u.id,p.id)
147 if (sub!=nil) and (sub.points!=nil) and p and p.full_score
147 if (sub!=nil) and (sub.points!=nil) and p and p.full_score
148 ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
148 ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
149 else
149 else
150 ustat << [0,false]
150 ustat << [0,false]
151 end
151 end
152 end
152 end
@@ -155,27 +155,27
155 if params[:commit] == 'download csv' then
155 if params[:commit] == 'download csv' then
156 csv = gen_csv_from_scorearray(@scorearray,@problems)
156 csv = gen_csv_from_scorearray(@scorearray,@problems)
157 send_data csv, filename: 'last_score.csv'
157 send_data csv, filename: 'last_score.csv'
158 else
158 else
159 render template: 'user_admin/user_stat'
159 render template: 'user_admin/user_stat'
160 end
160 end
161 end
161 end
162
162
163 def user_stat_max
163 def user_stat_max
164 if params[:commit] == 'download csv'
164 if params[:commit] == 'download csv'
165 @problems = Problem.all
165 @problems = Problem.all
166 else
166 else
167 - @problems = Problem.find_available_problems
167 + @problems = Problem.available_problems
168 end
168 end
169 - @users = User.find(:all, :include => [:contests, :contest_stat])
169 + @users = User.includes(:contests).includes(:contest_stat).all
170 @scorearray = Array.new
170 @scorearray = Array.new
171 #set up range from param
171 #set up range from param
172 since_id = params.fetch(:since_id, 0).to_i
172 since_id = params.fetch(:since_id, 0).to_i
173 until_id = params.fetch(:until_id, 0).to_i
173 until_id = params.fetch(:until_id, 0).to_i
174 @users.each do |u|
174 @users.each do |u|
175 ustat = Array.new
175 ustat = Array.new
176 ustat[0] = u
176 ustat[0] = u
177 @problems.each do |p|
177 @problems.each do |p|
178 max_points = 0
178 max_points = 0
179 Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub|
179 Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub|
180 max_points = sub.points if sub and sub.points and (sub.points > max_points)
180 max_points = sub.points if sub and sub.points and (sub.points > max_points)
181 end
181 end
@@ -192,25 +192,25
192 end
192 end
193 end
193 end
194
194
195 def import
195 def import
196 if params[:file]==''
196 if params[:file]==''
197 flash[:notice] = 'Error importing no file'
197 flash[:notice] = 'Error importing no file'
198 redirect_to :action => 'index' and return
198 redirect_to :action => 'index' and return
199 end
199 end
200 import_from_file(params[:file])
200 import_from_file(params[:file])
201 end
201 end
202
202
203 def random_all_passwords
203 def random_all_passwords
204 - users = User.find(:all)
204 + users = User.all
205 @prefix = params[:prefix] || ''
205 @prefix = params[:prefix] || ''
206 @non_admin_users = User.find_non_admin_with_prefix(@prefix)
206 @non_admin_users = User.find_non_admin_with_prefix(@prefix)
207 @changed = false
207 @changed = false
208 if request.request_method == 'POST'
208 if request.request_method == 'POST'
209 @non_admin_users.each do |user|
209 @non_admin_users.each do |user|
210 password = random_password
210 password = random_password
211 user.password = password
211 user.password = password
212 user.password_confirmation = password
212 user.password_confirmation = password
213 user.save
213 user.save
214 end
214 end
215 @changed = true
215 @changed = true
216 end
216 end
@@ -315,25 +315,25
315 if params[:reset_timer]
315 if params[:reset_timer]
316 logout_users(users)
316 logout_users(users)
317 end
317 end
318
318
319 flash[:notice] = 'User(s) ' + note.join(', ') +
319 flash[:notice] = 'User(s) ' + note.join(', ') +
320 ' were successfully modified. '
320 ' were successfully modified. '
321 redirect_to :action => 'contest_management'
321 redirect_to :action => 'contest_management'
322 end
322 end
323
323
324 # admin management
324 # admin management
325
325
326 def admin
326 def admin
327 - @admins = User.find(:all).find_all {|user| user.admin? }
327 + @admins = User.all.find_all {|user| user.admin? }
328 end
328 end
329
329
330 def grant_admin
330 def grant_admin
331 login = params[:login]
331 login = params[:login]
332 user = User.find_by_login(login)
332 user = User.find_by_login(login)
333 if user!=nil
333 if user!=nil
334 admin_role = Role.find_by_name('admin')
334 admin_role = Role.find_by_name('admin')
335 user.roles << admin_role
335 user.roles << admin_role
336 else
336 else
337 flash[:notice] = 'Unknown user'
337 flash[:notice] = 'Unknown user'
338 end
338 end
339 flash[:notice] = 'User added as admins'
339 flash[:notice] = 'User added as admins'
@@ -526,13 +526,18
526 else
526 else
527 row << sc[i][0]
527 row << sc[i][0]
528 total += sc[i][0]
528 total += sc[i][0]
529 num_passed += 1 if sc[i][1]
529 num_passed += 1 if sc[i][1]
530 end
530 end
531 end
531 end
532 row << total
532 row << total
533 row << num_passed
533 row << num_passed
534 csv << row
534 csv << row
535 end
535 end
536 end
536 end
537 end
537 end
538 +
539 + private
540 + def user_params
541 + params.require(:user).permit(:login,:full_name,:hashed_password,:salt,:alias,:email,:site_id,:country_id,:activated,:enabled,:remark,:last_ip,:section)
538 end
542 end
543 + end
@@ -1,21 +1,15
1 class Announcement < ActiveRecord::Base
1 class Announcement < ActiveRecord::Base
2
2
3 - def self.find_published(contest_started=false)
3 + def self.published(contest_started=false)
4 if contest_started
4 if contest_started
5 - Announcement.find(:all,
5 + where(published: true).where(frontpage: false).order(created_at: :desc)
6 - :conditions => "(published = 1) AND (frontpage = 0)",
7 - :order => "created_at DESC")
8 else
6 else
9 - Announcement.find(:all,
7 + where(published: true).where(frontpage: false).where(contest_only: false).order(created_at: :desc)
10 - :conditions => "(published = 1) AND (frontpage = 0) AND (contest_only = 0)",
11 - :order => "created_at DESC")
12 end
8 end
13 end
9 end
14
10
15 - def self.find_for_frontpage
11 + def self.frontpage
16 - Announcement.find(:all,
12 + where(published: 1).where(frontpage: 1).order(created_at: :desc)
17 - :conditions => "(published = 1) AND (frontpage = 1)",
18 - :order => "created_at DESC")
19 end
13 end
20
14
21 end
15 end
@@ -1,8 +1,8
1 class Contest < ActiveRecord::Base
1 class Contest < ActiveRecord::Base
2
2
3 has_and_belongs_to_many :users
3 has_and_belongs_to_many :users
4 has_and_belongs_to_many :problems
4 has_and_belongs_to_many :problems
5
5
6 - scope :enabled, :conditions => {:enabled => true}
6 + scope :enabled, -> { where(enabled: true) }
7
7
8 end
8 end
@@ -143,25 +143,25
143 return val
143 return val
144
144
145 when 'integer'
145 when 'integer'
146 return val.to_i
146 return val.to_i
147
147
148 when 'boolean'
148 when 'boolean'
149 return (val=='true')
149 return (val=='true')
150 end
150 end
151 end
151 end
152
152
153 def self.read_config
153 def self.read_config
154 GraderConfiguration.config_cache = {}
154 GraderConfiguration.config_cache = {}
155 - GraderConfiguration.find(:all).each do |conf|
155 + GraderConfiguration.all.each do |conf|
156 key = conf.key
156 key = conf.key
157 val = conf.value
157 val = conf.value
158 GraderConfiguration.config_cache[key] = GraderConfiguration.convert_type(val,conf.value_type)
158 GraderConfiguration.config_cache[key] = GraderConfiguration.convert_type(val,conf.value_type)
159 end
159 end
160 end
160 end
161
161
162 def self.read_one_key(key)
162 def self.read_one_key(key)
163 conf = GraderConfiguration.find_by_key(key)
163 conf = GraderConfiguration.find_by_key(key)
164 if conf
164 if conf
165 return GraderConfiguration.convert_type(conf.value,conf.value_type)
165 return GraderConfiguration.convert_type(conf.value,conf.value_type)
166 else
166 else
167 return nil
167 return nil
@@ -1,55 +1,46
1 class GraderProcess < ActiveRecord::Base
1 class GraderProcess < ActiveRecord::Base
2
2
3 def self.find_by_host_and_pid(host,pid)
3 def self.find_by_host_and_pid(host,pid)
4 - return GraderProcess.find(:first,
4 + return GraderProcess.where(host:host).where(pid: pid).first
5 - :conditions => {
6 - :host => host,
7 - :pid => pid
8 - })
9 end
5 end
10
6
11 def self.register(host,pid,mode)
7 def self.register(host,pid,mode)
12 grader = GraderProcess.find_by_host_and_pid(host,pid)
8 grader = GraderProcess.find_by_host_and_pid(host,pid)
13 if grader
9 if grader
14 grader.mode = mode
10 grader.mode = mode
15 grader.active = nil
11 grader.active = nil
16 grader.task_id = nil
12 grader.task_id = nil
17 grader.task_type = nil
13 grader.task_type = nil
18 grader.terminated = false
14 grader.terminated = false
19 grader.save
15 grader.save
20 else
16 else
21 grader = GraderProcess.create(:host => host,
17 grader = GraderProcess.create(:host => host,
22 :pid => pid,
18 :pid => pid,
23 :mode => mode,
19 :mode => mode,
24 :terminated => false)
20 :terminated => false)
25 end
21 end
26 grader
22 grader
27 end
23 end
28
24
29 def self.find_running_graders
25 def self.find_running_graders
30 - GraderProcess.find(:all,
26 + where(terminated: false)
31 - :conditions => {:terminated => 0})
32 end
27 end
33
28
34 def self.find_terminated_graders
29 def self.find_terminated_graders
35 - GraderProcess.find(:all,
30 + where(terminated: true)
36 - :conditions => "`terminated`")
37 end
31 end
38
32
39 def self.find_stalled_process
33 def self.find_stalled_process
40 - GraderProcess.find(:all,
34 + where(terminated: false).where(active: true).where("updated_at < ?",Time.now.gmtime - GraderProcess.stalled_time)
41 - :conditions => ["(`terminated` = 0) AND active AND " +
42 - "(updated_at < ?)",
43 - Time.now.gmtime - GraderProcess.stalled_time])
44 end
35 end
45
36
46 def report_active(task=nil)
37 def report_active(task=nil)
47 self.active = true
38 self.active = true
48 if task!=nil
39 if task!=nil
49 self.task_id = task.id
40 self.task_id = task.id
50 self.task_type = task.class.to_s
41 self.task_type = task.class.to_s
51 else
42 else
52 self.task_id = nil
43 self.task_id = nil
53 self.task_type = nil
44 self.task_type = nil
54 end
45 end
55 self.save
46 self.save
@@ -1,19 +1,19
1 class Language < ActiveRecord::Base
1 class Language < ActiveRecord::Base
2
2
3 @@languages_by_ext = {}
3 @@languages_by_ext = {}
4
4
5 def self.cache_ext_hash
5 def self.cache_ext_hash
6 @@languages_by_ext = {}
6 @@languages_by_ext = {}
7 - Language.find(:all).each do |language|
7 + Language.all.each do |language|
8 language.common_ext.split(',').each do |ext|
8 language.common_ext.split(',').each do |ext|
9 @@languages_by_ext[ext] = language
9 @@languages_by_ext[ext] = language
10 end
10 end
11 end
11 end
12 end
12 end
13
13
14 def self.find_by_extension(ext)
14 def self.find_by_extension(ext)
15 if @@languages_by_ext.length == 0
15 if @@languages_by_ext.length == 0
16 Language.cache_ext_hash
16 Language.cache_ext_hash
17 end
17 end
18 if @@languages_by_ext.has_key? ext
18 if @@languages_by_ext.has_key? ext
19 return @@languages_by_ext[ext]
19 return @@languages_by_ext[ext]
@@ -1,5 +1,4
1 class Login < ActiveRecord::Base
1 class Login < ActiveRecord::Base
2 belongs_to :user
2 belongs_to :user
3
3
4 - attr_accessible :ip_address, :logged_in_at, :user_id
5 end
4 end
@@ -14,28 +14,26
14 #
14 #
15
15
16 attr_accessor :replied_messages
16 attr_accessor :replied_messages
17
17
18 def self.find_all_sent_by_user(user)
18 def self.find_all_sent_by_user(user)
19 messages = user.messages
19 messages = user.messages
20 replied_messages = user.replied_messages
20 replied_messages = user.replied_messages
21 Message.build_replying_message_hierarchy messages, replied_messages
21 Message.build_replying_message_hierarchy messages, replied_messages
22 return messages
22 return messages
23 end
23 end
24
24
25 def self.find_all_system_unreplied_messages
25 def self.find_all_system_unreplied_messages
26 - self.find(:all,
26 + where('ISNULL(receiver_id) ' +
27 - :conditions => 'ISNULL(receiver_id) ' +
27 + 'AND (ISNULL(replied) OR replied=0)')
28 - 'AND (ISNULL(replied) OR replied=0)',
29 - :order => 'created_at')
30 end
28 end
31
29
32 def self.build_replying_message_hierarchy(*args)
30 def self.build_replying_message_hierarchy(*args)
33 # manually build replies hierarchy (to improve efficiency)
31 # manually build replies hierarchy (to improve efficiency)
34 all_messages = {}
32 all_messages = {}
35
33
36 args.each do |collection|
34 args.each do |collection|
37 collection.each do |m|
35 collection.each do |m|
38 all_messages[m.id] = m
36 all_messages[m.id] = m
39 m.replied_messages = []
37 m.replied_messages = []
40 end
38 end
41 end
39 end
@@ -1,30 +1,31
1 class Problem < ActiveRecord::Base
1 class Problem < ActiveRecord::Base
2
2
3 belongs_to :description
3 belongs_to :description
4 has_and_belongs_to_many :contests, :uniq => true
4 has_and_belongs_to_many :contests, :uniq => true
5 has_many :test_pairs, :dependent => :delete_all
5 has_many :test_pairs, :dependent => :delete_all
6 has_many :testcases, :dependent => :destroy
6 has_many :testcases, :dependent => :destroy
7
7
8 validates_presence_of :name
8 validates_presence_of :name
9 - validates_format_of :name, :with => /^\w+$/
9 + validates_format_of :name, :with => /\A\w+\z/
10 validates_presence_of :full_name
10 validates_presence_of :full_name
11
11
12 - scope :available, :conditions => {:available => true}
12 + scope :available, -> { where(available: true) }
13
13
14 DEFAULT_TIME_LIMIT = 1
14 DEFAULT_TIME_LIMIT = 1
15 DEFAULT_MEMORY_LIMIT = 32
15 DEFAULT_MEMORY_LIMIT = 32
16
16
17 - def self.find_available_problems
17 + def self.available_problems
18 - Problem.available.all(:order => "date_added DESC, name ASC")
18 + available.order(date_added: :desc).order(:name)
19 + #Problem.available.all(:order => "date_added DESC, name ASC")
19 end
20 end
20
21
21 def self.create_from_import_form_params(params, old_problem=nil)
22 def self.create_from_import_form_params(params, old_problem=nil)
22 org_problem = old_problem || Problem.new
23 org_problem = old_problem || Problem.new
23 import_params, problem = Problem.extract_params_and_check(params,
24 import_params, problem = Problem.extract_params_and_check(params,
24 org_problem)
25 org_problem)
25
26
26 if !problem.errors.empty?
27 if !problem.errors.empty?
27 return problem, 'Error importing'
28 return problem, 'Error importing'
28 end
29 end
29
30
30 problem.full_score = 100
31 problem.full_score = 100
@@ -7,74 +7,61
7 before_validation :assign_problem
7 before_validation :assign_problem
8 before_validation :assign_language
8 before_validation :assign_language
9
9
10 validates_presence_of :source
10 validates_presence_of :source
11 validates_length_of :source, :maximum => 100_000, :allow_blank => true, :message => 'too long'
11 validates_length_of :source, :maximum => 100_000, :allow_blank => true, :message => 'too long'
12 validates_length_of :source, :minimum => 1, :allow_blank => true, :message => 'too short'
12 validates_length_of :source, :minimum => 1, :allow_blank => true, :message => 'too short'
13 validate :must_have_valid_problem
13 validate :must_have_valid_problem
14 validate :must_specify_language
14 validate :must_specify_language
15
15
16 before_save :assign_latest_number_if_new_recond
16 before_save :assign_latest_number_if_new_recond
17
17
18 def self.find_last_by_user_and_problem(user_id, problem_id)
18 def self.find_last_by_user_and_problem(user_id, problem_id)
19 - last_sub = find(:first,
19 + where("user_id = ? AND problem_id = ?",user_id,problem_id).last
20 - :conditions => {:user_id => user_id,
21 - :problem_id => problem_id},
22 - :order => 'number DESC')
23 - return last_sub
24 end
20 end
25
21
26 def self.find_all_last_by_problem(problem_id)
22 def self.find_all_last_by_problem(problem_id)
27 # need to put in SQL command, maybe there's a better way
23 # need to put in SQL command, maybe there's a better way
28 Submission.includes(:user).find_by_sql("SELECT * FROM submissions " +
24 Submission.includes(:user).find_by_sql("SELECT * FROM submissions " +
29 "WHERE id = " +
25 "WHERE id = " +
30 "(SELECT MAX(id) FROM submissions AS subs " +
26 "(SELECT MAX(id) FROM submissions AS subs " +
31 "WHERE subs.user_id = submissions.user_id AND " +
27 "WHERE subs.user_id = submissions.user_id AND " +
32 "problem_id = " + problem_id.to_s + " " +
28 "problem_id = " + problem_id.to_s + " " +
33 "GROUP BY user_id) " +
29 "GROUP BY user_id) " +
34 "ORDER BY user_id")
30 "ORDER BY user_id")
35 end
31 end
36
32
37 def self.find_in_range_by_user_and_problem(user_id, problem_id,since_id,until_id)
33 def self.find_in_range_by_user_and_problem(user_id, problem_id,since_id,until_id)
38 records = Submission.where(problem_id: problem_id,user_id: user_id)
34 records = Submission.where(problem_id: problem_id,user_id: user_id)
39 records = records.where('id >= ?',since_id) if since_id > 0
35 records = records.where('id >= ?',since_id) if since_id > 0
40 records = records.where('id <= ?',until_id) if until_id > 0
36 records = records.where('id <= ?',until_id) if until_id > 0
41 records.all
37 records.all
42 end
38 end
43
39
44 def self.find_last_for_all_available_problems(user_id)
40 def self.find_last_for_all_available_problems(user_id)
45 submissions = Array.new
41 submissions = Array.new
46 - problems = Problem.find_available_problems
42 + problems = Problem.available_problems
47 problems.each do |problem|
43 problems.each do |problem|
48 sub = Submission.find_last_by_user_and_problem(user_id, problem.id)
44 sub = Submission.find_last_by_user_and_problem(user_id, problem.id)
49 submissions << sub if sub!=nil
45 submissions << sub if sub!=nil
50 end
46 end
51 submissions
47 submissions
52 end
48 end
53
49
54 def self.find_by_user_problem_number(user_id, problem_id, number)
50 def self.find_by_user_problem_number(user_id, problem_id, number)
55 - Submission.find(:first,
51 + where("user_id = ? AND problem_id = ? AND number = ?",user_id,problem_id,number).first
56 - :conditions => {
57 - :user_id => user_id,
58 - :problem_id => problem_id,
59 - :number => number
60 - })
61 end
52 end
62
53
63 def self.find_all_by_user_problem(user_id, problem_id)
54 def self.find_all_by_user_problem(user_id, problem_id)
64 - Submission.find(:all,
55 + where("user_id = ? AND problem_id = ?",user_id,problem_id)
65 - :conditions => {
66 - :user_id => user_id,
67 - :problem_id => problem_id,
68 - })
69 end
56 end
70
57
71 def download_filename
58 def download_filename
72 if self.problem.output_only
59 if self.problem.output_only
73 return self.source_filename
60 return self.source_filename
74 else
61 else
75 timestamp = self.submitted_at.localtime.strftime("%H%M%S")
62 timestamp = self.submitted_at.localtime.strftime("%H%M%S")
76 return "#{self.problem.name}-#{timestamp}.#{self.language.ext}"
63 return "#{self.problem.name}-#{timestamp}.#{self.language.ext}"
77 end
64 end
78 end
65 end
79
66
80 protected
67 protected
@@ -1,3 +1,3
1 class SubmissionViewLog < ActiveRecord::Base
1 class SubmissionViewLog < ActiveRecord::Base
2 - attr_accessible :submission_id, :user_id
2 + #attr_accessible :submission_id, :user_id
3 end
3 end
@@ -39,28 +39,25
39 "inqueue"
39 "inqueue"
40 when Task::STATUS_GRADING
40 when Task::STATUS_GRADING
41 "grading"
41 "grading"
42 when Task::STATUS_COMPLETE
42 when Task::STATUS_COMPLETE
43 "complete"
43 "complete"
44 end
44 end
45 end
45 end
46
46
47 def self.get_inqueue_and_change_status(status)
47 def self.get_inqueue_and_change_status(status)
48 task = nil
48 task = nil
49 begin
49 begin
50 Task.transaction do
50 Task.transaction do
51 - task = Task.find(:first,
51 + task = Task.where(status: Task::STATUS_INQUEUE).where(lock: true).first
52 - :order => "created_at",
53 - :conditions => {:status=> Task::STATUS_INQUEUE},
54 - :lock => true)
55 if task!=nil
52 if task!=nil
56 task.status = status
53 task.status = status
57 task.save!
54 task.save!
58 end
55 end
59 end
56 end
60
57
61 rescue
58 rescue
62 task = nil
59 task = nil
63
60
64 end
61 end
65 task
62 task
66 end
63 end
@@ -7,49 +7,46
7 # it works as well with problem=nil. In this case, we shall provide
7 # it works as well with problem=nil. In this case, we shall provide
8 # a "default" execution environment for it. This can be done
8 # a "default" execution environment for it. This can be done
9 # seamlessly by using TestRequest#problem_name or
9 # seamlessly by using TestRequest#problem_name or
10 # TestRequest#name_of(problem) when retrieving the name of the
10 # TestRequest#name_of(problem) when retrieving the name of the
11 # problem: #name_of would return problem.name when problem!=nil and
11 # problem: #name_of would return problem.name when problem!=nil and
12 # it would return "default" when problem=nil, #problem_name just
12 # it would return "default" when problem=nil, #problem_name just
13 # call #name_of.
13 # call #name_of.
14 #
14 #
15
15
16 require 'fileutils'
16 require 'fileutils'
17
17
18 class TestRequest < Task
18 class TestRequest < Task
19 -
19 + self.table_name = "test_requests"
20 - set_table_name "test_requests"
21
20
22 belongs_to :user
21 belongs_to :user
23 belongs_to :problem
22 belongs_to :problem
24 belongs_to :submission
23 belongs_to :submission
25
24
26 validates_presence_of :submission
25 validates_presence_of :submission
27 validate :must_have_valid_problem
26 validate :must_have_valid_problem
28
27
29 def problem_name
28 def problem_name
30 TestRequest.name_of(self.problem)
29 TestRequest.name_of(self.problem)
31 end
30 end
32
31
33 def language
32 def language
34 self.submission.language
33 self.submission.language
35 end
34 end
36
35
37 def self.get_inqueue_and_change_status(status)
36 def self.get_inqueue_and_change_status(status)
38 # since there will be only one grader grading TestRequest
37 # since there will be only one grader grading TestRequest
39 # we do not need locking (hopefully)
38 # we do not need locking (hopefully)
40
39
41 - test_request = TestRequest.find(:first,
40 + test_request = TestRequest.where(status: Task::STATUS_INQUEUE).first
42 - :order => "created_at",
43 - :conditions => {:status=> Task::STATUS_INQUEUE})
44 if test_request!=nil
41 if test_request!=nil
45 test_request.status = status
42 test_request.status = status
46 test_request.save!
43 test_request.save!
47 end
44 end
48
45
49 test_request
46 test_request
50 end
47 end
51
48
52 # interfacing with form
49 # interfacing with form
53 def self.new_from_form_params(user,params)
50 def self.new_from_form_params(user,params)
54 test_request = TestRequest.new
51 test_request = TestRequest.new
55 test_request.user = user
52 test_request.user = user
@@ -1,4 +1,4
1 class Testcase < ActiveRecord::Base
1 class Testcase < ActiveRecord::Base
2 belongs_to :problem
2 belongs_to :problem
3 - attr_accessible :group, :input, :num, :score, :sol
3 + #attr_accessible :group, :input, :num, :score, :sol
4 end
4 end
@@ -1,46 +1,44
1 require 'digest/sha1'
1 require 'digest/sha1'
2 require 'net/pop'
2 require 'net/pop'
3 require 'net/https'
3 require 'net/https'
4 require 'net/http'
4 require 'net/http'
5 require 'json'
5 require 'json'
6
6
7 class User < ActiveRecord::Base
7 class User < ActiveRecord::Base
8
8
9 has_and_belongs_to_many :roles
9 has_and_belongs_to_many :roles
10
10
11 - has_many :test_requests, :order => "submitted_at DESC"
11 + has_many :test_requests, -> {order(submitted_at: DESC)}
12
12
13 - has_many :messages,
13 + has_many :messages, -> { order(created_at: DESC) },
14 :class_name => "Message",
14 :class_name => "Message",
15 - :foreign_key => "sender_id",
15 + :foreign_key => "sender_id"
16 - :order => 'created_at DESC'
17
16
18 - has_many :replied_messages,
17 + has_many :replied_messages, -> { order(created_at: DESC) },
19 :class_name => "Message",
18 :class_name => "Message",
20 - :foreign_key => "receiver_id",
19 + :foreign_key => "receiver_id"
21 - :order => 'created_at DESC'
22
20
23 has_one :contest_stat, :class_name => "UserContestStat", :dependent => :destroy
21 has_one :contest_stat, :class_name => "UserContestStat", :dependent => :destroy
24
22
25 belongs_to :site
23 belongs_to :site
26 belongs_to :country
24 belongs_to :country
27
25
28 - has_and_belongs_to_many :contests, :uniq => true, :order => 'name'
26 + has_and_belongs_to_many :contests, -> { order(:name); uniq}
29
27
30 - scope :activated_users, :conditions => {:activated => true}
28 + scope :activated_users, -> {where activated: true}
31
29
32 validates_presence_of :login
30 validates_presence_of :login
33 validates_uniqueness_of :login
31 validates_uniqueness_of :login
34 - validates_format_of :login, :with => /^[\_A-Za-z0-9]+$/
32 + validates_format_of :login, :with => /\A[\_A-Za-z0-9]+\z/
35 validates_length_of :login, :within => 3..30
33 validates_length_of :login, :within => 3..30
36
34
37 validates_presence_of :full_name
35 validates_presence_of :full_name
38 validates_length_of :full_name, :minimum => 1
36 validates_length_of :full_name, :minimum => 1
39
37
40 validates_presence_of :password, :if => :password_required?
38 validates_presence_of :password, :if => :password_required?
41 validates_length_of :password, :within => 4..20, :if => :password_required?
39 validates_length_of :password, :within => 4..20, :if => :password_required?
42 validates_confirmation_of :password, :if => :password_required?
40 validates_confirmation_of :password, :if => :password_required?
43
41
44 validates_format_of :email,
42 validates_format_of :email,
45 :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i,
43 :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i,
46 :if => :email_validation?
44 :if => :email_validation?
@@ -168,32 +166,32
168 def verify_activation_key(key)
166 def verify_activation_key(key)
169 key == activation_key
167 key == activation_key
170 end
168 end
171
169
172 def self.random_password(length=5)
170 def self.random_password(length=5)
173 chars = 'abcdefghjkmnopqrstuvwxyz'
171 chars = 'abcdefghjkmnopqrstuvwxyz'
174 password = ''
172 password = ''
175 length.times { password << chars[rand(chars.length - 1)] }
173 length.times { password << chars[rand(chars.length - 1)] }
176 password
174 password
177 end
175 end
178
176
179 def self.find_non_admin_with_prefix(prefix='')
177 def self.find_non_admin_with_prefix(prefix='')
180 - users = User.find(:all)
178 + users = User.all
181 return users.find_all { |u| !(u.admin?) and u.login.index(prefix)==0 }
179 return users.find_all { |u| !(u.admin?) and u.login.index(prefix)==0 }
182 end
180 end
183
181
184 # Contest information
182 # Contest information
185
183
186 def self.find_users_with_no_contest()
184 def self.find_users_with_no_contest()
187 - users = User.find(:all)
185 + users = User.all
188 return users.find_all { |u| u.contests.length == 0 }
186 return users.find_all { |u| u.contests.length == 0 }
189 end
187 end
190
188
191
189
192 def contest_time_left
190 def contest_time_left
193 if GraderConfiguration.contest_mode?
191 if GraderConfiguration.contest_mode?
194 return nil if site==nil
192 return nil if site==nil
195 return site.time_left
193 return site.time_left
196 elsif GraderConfiguration.indv_contest_mode?
194 elsif GraderConfiguration.indv_contest_mode?
197 time_limit = GraderConfiguration.contest_time_limit
195 time_limit = GraderConfiguration.contest_time_limit
198 if time_limit == nil
196 if time_limit == nil
199 return nil
197 return nil
@@ -274,25 +272,25
274 available_problems.each {|p| pin[p.id] = true}
272 available_problems.each {|p| pin[p.id] = true}
275 end
273 end
276 other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0}
274 other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0}
277 contest_problems << {
275 contest_problems << {
278 :contest => nil,
276 :contest => nil,
279 :problems => other_avaiable_problems
277 :problems => other_avaiable_problems
280 }
278 }
281 return contest_problems
279 return contest_problems
282 end
280 end
283
281
284 def available_problems
282 def available_problems
285 if not GraderConfiguration.multicontests?
283 if not GraderConfiguration.multicontests?
286 - return Problem.find_available_problems
284 + return Problem.available_problems
287 else
285 else
288 contest_problems = []
286 contest_problems = []
289 pin = {}
287 pin = {}
290 contests.enabled.each do |contest|
288 contests.enabled.each do |contest|
291 contest.problems.available.each do |problem|
289 contest.problems.available.each do |problem|
292 if not pin.has_key? problem.id
290 if not pin.has_key? problem.id
293 contest_problems << problem
291 contest_problems << problem
294 end
292 end
295 pin[problem.id] = true
293 pin[problem.id] = true
296 end
294 end
297 end
295 end
298 other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0}
296 other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0}
@@ -1,26 +1,26
1
1
2 - if submission.nil?
2 - if submission.nil?
3 = "-"
3 = "-"
4 - else
4 - else
5 - unless submission.graded_at
5 - unless submission.graded_at
6 = t 'main.submitted_at'
6 = t 'main.submitted_at'
7 = format_short_time(submission.submitted_at.localtime)
7 = format_short_time(submission.submitted_at.localtime)
8 - else
8 - else
9 - = t 'main.graded_at'
9 + %strong= t 'main.graded_at'
10 - = "#{format_short_time(submission.graded_at.localtime)}, "
10 + = "#{format_short_time(submission.graded_at.localtime)} "
11 + %br
11 - if GraderConfiguration['ui.show_score']
12 - if GraderConfiguration['ui.show_score']
12 - = t 'main.score'
13 + %strong=t 'main.score'
13 = "#{(submission.points*100/submission.problem.full_score).to_i} "
14 = "#{(submission.points*100/submission.problem.full_score).to_i} "
14 = " ["
15 = " ["
15 %tt
16 %tt
16 = submission.grader_comment
17 = submission.grader_comment
17 = "]"
18 = "]"
19 + %br
20 + %strong View:
18 - if GraderConfiguration.show_grading_result
21 - if GraderConfiguration.show_grading_result
19 - = " | "
20 = link_to '[detailed result]', :action => 'result', :id => submission.id
22 = link_to '[detailed result]', :action => 'result', :id => submission.id
21 - = " | "
23 + = link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'}
22 - = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true})
24 + = link_to "#{t 'main.src_link'}", download_submission_path(submission.id), class: 'btn btn-xs btn-info'
23 - = " | "
25 + = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info'
24 - = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
26 +
25 - //= " | "
26 - //= link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id)
@@ -11,16 +11,17
11 %br
11 %br
12 - if GraderConfiguration['ui.show_score']
12 - if GraderConfiguration['ui.show_score']
13 %strong=t 'main.score'
13 %strong=t 'main.score'
14 = "#{(submission.points*100/submission.problem.full_score).to_i} "
14 = "#{(submission.points*100/submission.problem.full_score).to_i} "
15 = " ["
15 = " ["
16 %tt
16 %tt
17 = submission.grader_comment
17 = submission.grader_comment
18 = "]"
18 = "]"
19 %br
19 %br
20 %strong View:
20 %strong View:
21 - if GraderConfiguration.show_grading_result
21 - if GraderConfiguration.show_grading_result
22 = link_to '[detailed result]', :action => 'result', :id => submission.id
22 = link_to '[detailed result]', :action => 'result', :id => submission.id
23 - = link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'}
23 + /= link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'}
24 + = link_to "#{t 'main.cmp_msg'}", compiler_msg_submission_path(submission.id), {popup: true,remote: true,class: 'btn btn-xs btn-info'}
24 = link_to "#{t 'main.src_link'}",{:action => 'source', :id => submission.id}, class: 'btn btn-xs btn-info'
25 = link_to "#{t 'main.src_link'}",{:action => 'source', :id => submission.id}, class: 'btn btn-xs btn-info'
25 = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info'
26 = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info'
26
27
@@ -8,25 +8,25
8 / %th Contest(s)
8 / %th Contest(s)
9 %th Remark
9 %th Remark
10 - @problems.each do |p|
10 - @problems.each do |p|
11 %th.text-right= p.name.gsub('_',' ')
11 %th.text-right= p.name.gsub('_',' ')
12 %th.text-right Total
12 %th.text-right Total
13 %th.text-right Passed
13 %th.text-right Passed
14 %tbody
14 %tbody
15 - @scorearray.each do |sc|
15 - @scorearray.each do |sc|
16 %tr
16 %tr
17 - total,num_passed = 0,0
17 - total,num_passed = 0,0
18 - sc.each_index do |i|
18 - sc.each_index do |i|
19 - if i == 0
19 - if i == 0
20 - %td= link_to sc[i].login, controller: 'users', action: 'profile', id: sc[i]
20 + %td= link_to sc[i].login, stat_user_path(sc[i])
21 %td= sc[i].full_name
21 %td= sc[i].full_name
22 / %td= sc[i].activated
22 / %td= sc[i].activated
23 / %td= sc[i].try(:contest_stat).try(:started_at) ? 'yes' : 'no'
23 / %td= sc[i].try(:contest_stat).try(:started_at) ? 'yes' : 'no'
24 / %td= sc[i].contests.collect {|c| c.name}.join(', ')
24 / %td= sc[i].contests.collect {|c| c.name}.join(', ')
25 %td= sc[i].remark
25 %td= sc[i].remark
26 - else
26 - else
27 %td.text-right= sc[i][0]
27 %td.text-right= sc[i][0]
28 - total += sc[i][0]
28 - total += sc[i][0]
29 - num_passed += 1 if sc[i][1]
29 - num_passed += 1 if sc[i][1]
30 %td.text-right= total
30 %td.text-right= total
31 %td.text-right= num_passed
31 %td.text-right= num_passed
32
32
@@ -19,28 +19,29
19 = label_tag "Task:"
19 = label_tag "Task:"
20 = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
20 = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
21
21
22 .form-group
22 .form-group
23 = label_tag 'Language'
23 = label_tag 'Language'
24 = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name', @lang_id || Language.find_by_pretty_name("Python").id || Language.first.id), class: 'form-control select', style: "width: 100px"
24 = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name', @lang_id || Language.find_by_pretty_name("Python").id || Language.first.id), class: 'form-control select', style: "width: 100px"
25 .form-group
25 .form-group
26 = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit',
26 = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit',
27 data: {confirm: "Submitting this source code for task #{@problem.long_name}?"}
27 data: {confirm: "Submitting this source code for task #{@problem.long_name}?"}
28 .panel.panel-info
28 .panel.panel-info
29 .panel-heading
29 .panel-heading
30 Latest Submission Status
30 Latest Submission Status
31 + = link_to "Refresh",get_latest_submission_status_submissions_path(@submission.user,@problem), class: "btn btn-default btn-sm", remote: true
31 .panel-body
32 .panel-body
32 - if @submission
33 - if @submission
33 = render :partial => 'submission_short',
34 = render :partial => 'submission_short',
34 - :locals => {:submission => @submission, :problem_name => @problem.name }
35 + :locals => {submission: @submission, problem_name: @problem.name, problem_id: @problem.id }
35 .row
36 .row
36 .col-md-12
37 .col-md-12
37 %h2 Console
38 %h2 Console
38 %textarea#console{style: 'height: 100%; width: 100%;background-color:#000;color:#fff;font-family: consolas, monaco, "Droid Sans Mono";',rows: 20}
39 %textarea#console{style: 'height: 100%; width: 100%;background-color:#000;color:#fff;font-family: consolas, monaco, "Droid Sans Mono";',rows: 20}
39
40
40 :javascript
41 :javascript
41 $(document).ready(function() {
42 $(document).ready(function() {
42 e = ace.edit("editor")
43 e = ace.edit("editor")
43 e.setValue($("#text_haha").val());
44 e.setValue($("#text_haha").val());
44 e.gotoLine(1);
45 e.gotoLine(1);
45 $("#language_id").trigger('change');
46 $("#language_id").trigger('change');
46 brython();
47 brython();
@@ -76,28 +76,29
76 %strong Runtime (s)
76 %strong Runtime (s)
77 %td #{@submission.max_runtime}
77 %td #{@submission.max_runtime}
78 %tr
78 %tr
79 %td.text-right
79 %td.text-right
80 %strong Memory (kb)
80 %strong Memory (kb)
81 %td #{@submission.peak_memory}
81 %td #{@submission.peak_memory}
82 %tr
82 %tr
83 %td.text-right
83 %td.text-right
84 %strong Compiler result
84 %strong Compiler result
85 %td
85 %td
86 %button.btn.btn-info.btn-xs{type: 'button', data: {toggle: 'modal', target: '#compiler'}}
86 %button.btn.btn-info.btn-xs{type: 'button', data: {toggle: 'modal', target: '#compiler'}}
87 view
87 view
88 + - if session[:admin]
89 + %tr
90 + %td.text-right
91 + %strong IP
92 + %td #{@submission.ip_address}
93 +
88 .modal.fade#compiler{tabindex: -1,role: 'dialog'}
94 .modal.fade#compiler{tabindex: -1,role: 'dialog'}
89 .modal-dialog.modal-lg{role:'document'}
95 .modal-dialog.modal-lg{role:'document'}
90 .modal-content
96 .modal-content
91 .modal-header
97 .modal-header
92 %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}}
98 %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}}
93 %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} &times;
99 %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} &times;
94 %h4 Compiler message
100 %h4 Compiler message
95 .modal-body
101 .modal-body
96 - %pre= @submission.compiler_message
102 + %pre#compiler_msg= @submission.compiler_message
97 .modal-footer
103 .modal-footer
98 %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close
104 %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close
99 - - if session[:admin]
100 - %tr
101 - %td.text-right
102 - %strong IP
103 - %td #{@submission.ip_address}
@@ -1,40 +1,42
1 CafeGrader::Application.configure do
1 CafeGrader::Application.configure do
2 # Settings specified here will take precedence over those in config/application.rb
2 # Settings specified here will take precedence over those in config/application.rb
3
3
4 # In the development environment your application's code is reloaded on
4 # In the development environment your application's code is reloaded on
5 # every request. This slows down response time but is perfect for development
5 # every request. This slows down response time but is perfect for development
6 # since you don't have to restart the web server when you make code changes.
6 # since you don't have to restart the web server when you make code changes.
7 config.cache_classes = false
7 config.cache_classes = false
8
8
9 - # Log error messages when you accidentally call methods on nil.
9 + # Log error messages when you accidentally call methods on nil. //DEPRICATED
10 - config.whiny_nils = true
10 + # config.whiny_nils = true // DEPRICATED
11
11
12 # Show full error reports and disable caching
12 # Show full error reports and disable caching
13 config.consider_all_requests_local = true
13 config.consider_all_requests_local = true
14 config.action_controller.perform_caching = false
14 config.action_controller.perform_caching = false
15
15
16 # Don't care if the mailer can't send
16 # Don't care if the mailer can't send
17 config.action_mailer.raise_delivery_errors = false
17 config.action_mailer.raise_delivery_errors = false
18
18
19 # Print deprecation notices to the Rails logger
19 # Print deprecation notices to the Rails logger
20 config.active_support.deprecation = :log
20 config.active_support.deprecation = :log
21
21
22 # Only use best-standards-support built into browsers
22 # Only use best-standards-support built into browsers
23 config.action_dispatch.best_standards_support = :builtin
23 config.action_dispatch.best_standards_support = :builtin
24
24
25 # Raise exception on mass assignment protection for Active Record models
25 # Raise exception on mass assignment protection for Active Record models
26 - config.active_record.mass_assignment_sanitizer = :strict
26 + # config.active_record.mass_assignment_sanitizer = :strict //DEPRICATED
27
27
28 - # Log the query plan for queries taking more than this (works
28 + # Log the query plan for queries taking more than this (works // DEPRICATED
29 - # with SQLite, MySQL, and PostgreSQL)
29 + # with SQLite, MySQL, and PostgreSQL) // DEPRICATED
30 - config.active_record.auto_explain_threshold_in_seconds = 0.5
30 + # config.active_record.auto_explain_threshold_in_seconds = 0.5 // DEPRICATED
31
31
32 # Do not compress assets
32 # Do not compress assets
33 config.assets.compress = false
33 config.assets.compress = false
34
34
35 # Expands the lines which load the assets
35 # Expands the lines which load the assets
36 config.assets.debug = true
36 config.assets.debug = true
37
37
38 # Prevents assets from rendering twice
38 # Prevents assets from rendering twice
39 - config.serve_static_assets = true
39 + config.serve_static_files = true
40 +
41 + config.eager_load = false
40 end
42 end
@@ -1,24 +1,24
1 CafeGrader::Application.configure do
1 CafeGrader::Application.configure do
2 # Settings specified here will take precedence over those in config/application.rb
2 # Settings specified here will take precedence over those in config/application.rb
3
3
4 # Code is not reloaded between requests
4 # Code is not reloaded between requests
5 config.cache_classes = true
5 config.cache_classes = true
6
6
7 # Full error reports are disabled and caching is turned on
7 # Full error reports are disabled and caching is turned on
8 config.consider_all_requests_local = false
8 config.consider_all_requests_local = false
9 config.action_controller.perform_caching = true
9 config.action_controller.perform_caching = true
10
10
11 # Disable Rails's static asset server (Apache or nginx will already do this)
11 # Disable Rails's static asset server (Apache or nginx will already do this)
12 - config.serve_static_assets = false
12 + config.serve_static_files = false
13
13
14 # Compress JavaScripts and CSS
14 # Compress JavaScripts and CSS
15 config.assets.compress = true
15 config.assets.compress = true
16
16
17 # Don't fallback to assets pipeline if a precompiled asset is missed
17 # Don't fallback to assets pipeline if a precompiled asset is missed
18 config.assets.compile = false
18 config.assets.compile = false
19
19
20 # Generate digests for assets URLs
20 # Generate digests for assets URLs
21 config.assets.digest = true
21 config.assets.digest = true
22
22
23 # Defaults to nil and saved in location specified by config.assets.prefix
23 # Defaults to nil and saved in location specified by config.assets.prefix
24 # config.assets.manifest = YOUR_PATH
24 # config.assets.manifest = YOUR_PATH
@@ -55,13 +55,15
55 # config.threadsafe!
55 # config.threadsafe!
56
56
57 # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
57 # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58 # the I18n.default_locale when a translation can not be found)
58 # the I18n.default_locale when a translation can not be found)
59 config.i18n.fallbacks = true
59 config.i18n.fallbacks = true
60
60
61 # Send deprecation notices to registered listeners
61 # Send deprecation notices to registered listeners
62 config.active_support.deprecation = :notify
62 config.active_support.deprecation = :notify
63
63
64 # Log the query plan for queries taking more than this (works
64 # Log the query plan for queries taking more than this (works
65 # with SQLite, MySQL, and PostgreSQL)
65 # with SQLite, MySQL, and PostgreSQL)
66 # config.active_record.auto_explain_threshold_in_seconds = 0.5
66 # config.active_record.auto_explain_threshold_in_seconds = 0.5
67 +
68 + config.eager_load = true
67 end
69 end
@@ -1,37 +1,43
1 CafeGrader::Application.configure do
1 CafeGrader::Application.configure do
2 # Settings specified here will take precedence over those in config/application.rb
2 # Settings specified here will take precedence over those in config/application.rb
3
3
4 # The test environment is used exclusively to run your application's
4 # The test environment is used exclusively to run your application's
5 # test suite. You never need to work with it otherwise. Remember that
5 # test suite. You never need to work with it otherwise. Remember that
6 # your test database is "scratch space" for the test suite and is wiped
6 # your test database is "scratch space" for the test suite and is wiped
7 # and recreated between test runs. Don't rely on the data there!
7 # and recreated between test runs. Don't rely on the data there!
8 config.cache_classes = true
8 config.cache_classes = true
9
9
10 # Configure static asset server for tests with Cache-Control for performance
10 # Configure static asset server for tests with Cache-Control for performance
11 - config.serve_static_assets = true
11 + config.serve_static_files = true
12 config.static_cache_control = "public, max-age=3600"
12 config.static_cache_control = "public, max-age=3600"
13
13
14 # Log error messages when you accidentally call methods on nil
14 # Log error messages when you accidentally call methods on nil
15 config.whiny_nils = true
15 config.whiny_nils = true
16
16
17 # Show full error reports and disable caching
17 # Show full error reports and disable caching
18 config.consider_all_requests_local = true
18 config.consider_all_requests_local = true
19 config.action_controller.perform_caching = false
19 config.action_controller.perform_caching = false
20
20
21 # Raise exceptions instead of rendering exception templates
21 # Raise exceptions instead of rendering exception templates
22 config.action_dispatch.show_exceptions = false
22 config.action_dispatch.show_exceptions = false
23
23
24 # Disable request forgery protection in test environment
24 # Disable request forgery protection in test environment
25 config.action_controller.allow_forgery_protection = false
25 config.action_controller.allow_forgery_protection = false
26
26
27 # Tell Action Mailer not to deliver emails to the real world.
27 # Tell Action Mailer not to deliver emails to the real world.
28 # The :test delivery method accumulates sent emails in the
28 # The :test delivery method accumulates sent emails in the
29 # ActionMailer::Base.deliveries array.
29 # ActionMailer::Base.deliveries array.
30 config.action_mailer.delivery_method = :test
30 config.action_mailer.delivery_method = :test
31
31
32 # Raise exception on mass assignment protection for Active Record models
32 # Raise exception on mass assignment protection for Active Record models
33 - config.active_record.mass_assignment_sanitizer = :strict
33 + #config.active_record.mass_assignment_sanitizer = :strict // DEPRICATED
34
34
35 # Print deprecation notices to the stderr
35 # Print deprecation notices to the stderr
36 config.active_support.deprecation = :stderr
36 config.active_support.deprecation = :stderr
37 +
38 + config.eager_load = false
39 +
40 + #test order
41 + config.active_support.test_order = :sorted
42 +
37 end
43 end
@@ -1,6 +1,5
1 # Be sure to restart your server when you modify this file.
1 # Be sure to restart your server when you modify this file.
2
2
3 # Add new mime types for use in respond_to blocks:
3 # Add new mime types for use in respond_to blocks:
4 # Mime::Type.register "text/richtext", :rtf
4 # Mime::Type.register "text/richtext", :rtf
5 # Mime::Type.register_alias "text/html", :iphone
5 # Mime::Type.register_alias "text/html", :iphone
6 - Mime::Type.register 'application/pdf', :pdf
@@ -28,46 +28,50
28 end
28 end
29
29
30 resources :grader_configuration, controller: 'configurations'
30 resources :grader_configuration, controller: 'configurations'
31
31
32 resources :users do
32 resources :users do
33 member do
33 member do
34 get 'toggle_activate', 'toggle_enable'
34 get 'toggle_activate', 'toggle_enable'
35 get 'stat'
35 get 'stat'
36 end
36 end
37 end
37 end
38
38
39 resources :submissions do
39 resources :submissions do
40 + member do
41 + get 'download'
42 + get 'compiler_msg'
43 + end
40 collection do
44 collection do
41 get 'prob/:problem_id', to: 'submissions#index', as: 'problem'
45 get 'prob/:problem_id', to: 'submissions#index', as: 'problem'
42 get 'direct_edit_problem/:problem_id', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem'
46 get 'direct_edit_problem/:problem_id', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem'
43 get 'get_latest_submission_status/:uid/:pid', to: 'submissions#get_latest_submission_status', as: 'get_latest_submission_status'
47 get 'get_latest_submission_status/:uid/:pid', to: 'submissions#get_latest_submission_status', as: 'get_latest_submission_status'
44 end
48 end
45 end
49 end
46
50
47 - match 'tasks/view/:file.:ext' => 'tasks#view'
51 + get 'tasks/view/:file.:ext' => 'tasks#view'
48 - match 'tasks/download/:id/:file.:ext' => 'tasks#download'
52 + get 'tasks/download/:id/:file.:ext' => 'tasks#download'
49 - match 'heartbeat/:id/edit' => 'heartbeat#edit'
53 + get 'heartbeat/:id/edit' => 'heartbeat#edit'
50
54
51 #main
55 #main
52 get "main/list"
56 get "main/list"
53 get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
57 get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
54
58
55 #report
59 #report
56 get 'report/current_score', to: 'report#current_score', as: 'report_current_score'
60 get 'report/current_score', to: 'report#current_score', as: 'report_current_score'
57 get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof'
61 get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof'
58 get "report/login"
62 get "report/login"
59 get 'report/max_score', to: 'report#max_score', as: 'report_max_score'
63 get 'report/max_score', to: 'report#max_score', as: 'report_max_score'
60 post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score'
64 post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score'
61
65
62 #grader
66 #grader
63 get 'graders/list', to: 'graders#list', as: 'grader_list'
67 get 'graders/list', to: 'graders#list', as: 'grader_list'
64
68
65
69
66 - match 'heartbeat/:id/edit' => 'heartbeat#edit'
70 + get 'heartbeat/:id/edit' => 'heartbeat#edit'
67
71
68 # See how all your routes lay out with "rake routes"
72 # See how all your routes lay out with "rake routes"
69
73
70 # This is a legacy wild controller route that's not recommended for RESTful applications.
74 # This is a legacy wild controller route that's not recommended for RESTful applications.
71 # Note: This route will make all actions in every controller accessible via GET requests.
75 # Note: This route will make all actions in every controller accessible via GET requests.
72 - match ':controller(/:action(/:id))(.:format)'
76 + match ':controller(/:action(/:id))(.:format)', via: [:get, :post]
73 end
77 end
@@ -1,280 +1,280
1 # encoding: UTF-8
1 # encoding: UTF-8
2 # This file is auto-generated from the current state of the database. Instead
2 # This file is auto-generated from the current state of the database. Instead
3 # of editing this file, please use the migrations feature of Active Record to
3 # of editing this file, please use the migrations feature of Active Record to
4 # incrementally modify your database, and then regenerate this schema definition.
4 # incrementally modify your database, and then regenerate this schema definition.
5 #
5 #
6 # Note that this schema.rb definition is the authoritative source for your
6 # Note that this schema.rb definition is the authoritative source for your
7 # database schema. If you need to create the application database on another
7 # database schema. If you need to create the application database on another
8 # system, you should be using db:schema:load, not running all the migrations
8 # system, you should be using db:schema:load, not running all the migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
11 #
11 #
12 - # It's strongly recommended to check this file into your version control system.
12 + # It's strongly recommended that you check this file into your version control system.
13
13
14 - ActiveRecord::Schema.define(:version => 20161031063337) do
14 + ActiveRecord::Schema.define(version: 20161031063337) do
15
15
16 - create_table "announcements", :force => true do |t|
16 + create_table "announcements", force: :cascade do |t|
17 t.string "author"
17 t.string "author"
18 t.text "body"
18 t.text "body"
19 t.boolean "published"
19 t.boolean "published"
20 - t.datetime "created_at", :null => false
20 + t.datetime "created_at", null: false
21 - t.datetime "updated_at", :null => false
21 + t.datetime "updated_at", null: false
22 - t.boolean "frontpage", :default => false
22 + t.boolean "frontpage", default: false
23 - t.boolean "contest_only", :default => false
23 + t.boolean "contest_only", default: false
24 t.string "title"
24 t.string "title"
25 t.string "notes"
25 t.string "notes"
26 end
26 end
27
27
28 - create_table "contests", :force => true do |t|
28 + create_table "contests", force: :cascade do |t|
29 t.string "title"
29 t.string "title"
30 t.boolean "enabled"
30 t.boolean "enabled"
31 - t.datetime "created_at", :null => false
31 + t.datetime "created_at", null: false
32 - t.datetime "updated_at", :null => false
32 + t.datetime "updated_at", null: false
33 t.string "name"
33 t.string "name"
34 end
34 end
35
35
36 - create_table "contests_problems", :id => false, :force => true do |t|
36 + create_table "contests_problems", id: false, force: :cascade do |t|
37 t.integer "contest_id"
37 t.integer "contest_id"
38 t.integer "problem_id"
38 t.integer "problem_id"
39 end
39 end
40
40
41 - create_table "contests_users", :id => false, :force => true do |t|
41 + create_table "contests_users", id: false, force: :cascade do |t|
42 t.integer "contest_id"
42 t.integer "contest_id"
43 t.integer "user_id"
43 t.integer "user_id"
44 end
44 end
45
45
46 - create_table "countries", :force => true do |t|
46 + create_table "countries", force: :cascade do |t|
47 t.string "name"
47 t.string "name"
48 - t.datetime "created_at", :null => false
48 + t.datetime "created_at", null: false
49 - t.datetime "updated_at", :null => false
49 + t.datetime "updated_at", null: false
50 end
50 end
51
51
52 - create_table "descriptions", :force => true do |t|
52 + create_table "descriptions", force: :cascade do |t|
53 t.text "body"
53 t.text "body"
54 t.boolean "markdowned"
54 t.boolean "markdowned"
55 - t.datetime "created_at", :null => false
55 + t.datetime "created_at", null: false
56 - t.datetime "updated_at", :null => false
56 + t.datetime "updated_at", null: false
57 end
57 end
58
58
59 - create_table "grader_configurations", :force => true do |t|
59 + create_table "grader_configurations", force: :cascade do |t|
60 t.string "key"
60 t.string "key"
61 t.string "value_type"
61 t.string "value_type"
62 t.string "value"
62 t.string "value"
63 - t.datetime "created_at", :null => false
63 + t.datetime "created_at", null: false
64 - t.datetime "updated_at", :null => false
64 + t.datetime "updated_at", null: false
65 t.text "description"
65 t.text "description"
66 end
66 end
67
67
68 - create_table "grader_processes", :force => true do |t|
68 + create_table "grader_processes", force: :cascade do |t|
69 t.string "host"
69 t.string "host"
70 t.integer "pid"
70 t.integer "pid"
71 t.string "mode"
71 t.string "mode"
72 t.boolean "active"
72 t.boolean "active"
73 - t.datetime "created_at", :null => false
73 + t.datetime "created_at", null: false
74 - t.datetime "updated_at", :null => false
74 + t.datetime "updated_at", null: false
75 t.integer "task_id"
75 t.integer "task_id"
76 t.string "task_type"
76 t.string "task_type"
77 t.boolean "terminated"
77 t.boolean "terminated"
78 end
78 end
79
79
80 - add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid"
80 + add_index "grader_processes", ["host", "pid"], name: "index_grader_processes_on_ip_and_pid"
81
81
82 - create_table "heart_beats", :force => true do |t|
82 + create_table "heart_beats", force: :cascade do |t|
83 t.integer "user_id"
83 t.integer "user_id"
84 t.string "ip_address"
84 t.string "ip_address"
85 - t.datetime "created_at", :null => false
85 + t.datetime "created_at", null: false
86 - t.datetime "updated_at", :null => false
86 + t.datetime "updated_at", null: false
87 t.string "status"
87 t.string "status"
88 end
88 end
89
89
90 - add_index "heart_beats", ["updated_at"], :name => "index_heart_beats_on_updated_at"
90 + add_index "heart_beats", ["updated_at"], name: "index_heart_beats_on_updated_at"
91
91
92 - create_table "languages", :force => true do |t|
92 + create_table "languages", force: :cascade do |t|
93 - t.string "name", :limit => 10
93 + t.string "name", limit: 10
94 t.string "pretty_name"
94 t.string "pretty_name"
95 - t.string "ext", :limit => 10
95 + t.string "ext", limit: 10
96 t.string "common_ext"
96 t.string "common_ext"
97 end
97 end
98
98
99 - create_table "logins", :force => true do |t|
99 + create_table "logins", force: :cascade do |t|
100 t.integer "user_id"
100 t.integer "user_id"
101 t.string "ip_address"
101 t.string "ip_address"
102 - t.datetime "created_at", :null => false
102 + t.datetime "created_at", null: false
103 - t.datetime "updated_at", :null => false
103 + t.datetime "updated_at", null: false
104 end
104 end
105
105
106 - create_table "messages", :force => true do |t|
106 + create_table "messages", force: :cascade do |t|
107 t.integer "sender_id"
107 t.integer "sender_id"
108 t.integer "receiver_id"
108 t.integer "receiver_id"
109 t.integer "replying_message_id"
109 t.integer "replying_message_id"
110 t.text "body"
110 t.text "body"
111 t.boolean "replied"
111 t.boolean "replied"
112 - t.datetime "created_at", :null => false
112 + t.datetime "created_at", null: false
113 - t.datetime "updated_at", :null => false
113 + t.datetime "updated_at", null: false
114 end
114 end
115
115
116 - create_table "problems", :force => true do |t|
116 + create_table "problems", force: :cascade do |t|
117 - t.string "name", :limit => 30
117 + t.string "name", limit: 30
118 t.string "full_name"
118 t.string "full_name"
119 t.integer "full_score"
119 t.integer "full_score"
120 t.date "date_added"
120 t.date "date_added"
121 t.boolean "available"
121 t.boolean "available"
122 t.string "url"
122 t.string "url"
123 t.integer "description_id"
123 t.integer "description_id"
124 t.boolean "test_allowed"
124 t.boolean "test_allowed"
125 t.boolean "output_only"
125 t.boolean "output_only"
126 t.string "description_filename"
126 t.string "description_filename"
127 end
127 end
128
128
129 - create_table "rights", :force => true do |t|
129 + create_table "rights", force: :cascade do |t|
130 t.string "name"
130 t.string "name"
131 t.string "controller"
131 t.string "controller"
132 t.string "action"
132 t.string "action"
133 end
133 end
134
134
135 - create_table "rights_roles", :id => false, :force => true do |t|
135 + create_table "rights_roles", id: false, force: :cascade do |t|
136 t.integer "right_id"
136 t.integer "right_id"
137 t.integer "role_id"
137 t.integer "role_id"
138 end
138 end
139
139
140 - add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id"
140 + add_index "rights_roles", ["role_id"], name: "index_rights_roles_on_role_id"
141
141
142 - create_table "roles", :force => true do |t|
142 + create_table "roles", force: :cascade do |t|
143 t.string "name"
143 t.string "name"
144 end
144 end
145
145
146 - create_table "roles_users", :id => false, :force => true do |t|
146 + create_table "roles_users", id: false, force: :cascade do |t|
147 t.integer "role_id"
147 t.integer "role_id"
148 t.integer "user_id"
148 t.integer "user_id"
149 end
149 end
150
150
151 - add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
151 + add_index "roles_users", ["user_id"], name: "index_roles_users_on_user_id"
152
152
153 - create_table "sessions", :force => true do |t|
153 + create_table "sessions", force: :cascade do |t|
154 t.string "session_id"
154 t.string "session_id"
155 t.text "data"
155 t.text "data"
156 t.datetime "updated_at"
156 t.datetime "updated_at"
157 end
157 end
158
158
159 - add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
159 + add_index "sessions", ["session_id"], name: "index_sessions_on_session_id"
160 - add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
160 + add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at"
161
161
162 - create_table "sites", :force => true do |t|
162 + create_table "sites", force: :cascade do |t|
163 t.string "name"
163 t.string "name"
164 t.boolean "started"
164 t.boolean "started"
165 t.datetime "start_time"
165 t.datetime "start_time"
166 - t.datetime "created_at", :null => false
166 + t.datetime "created_at", null: false
167 - t.datetime "updated_at", :null => false
167 + t.datetime "updated_at", null: false
168 t.integer "country_id"
168 t.integer "country_id"
169 t.string "password"
169 t.string "password"
170 end
170 end
171
171
172 - create_table "submission_view_logs", :force => true do |t|
172 + create_table "submission_view_logs", force: :cascade do |t|
173 t.integer "user_id"
173 t.integer "user_id"
174 t.integer "submission_id"
174 t.integer "submission_id"
175 - t.datetime "created_at", :null => false
175 + t.datetime "created_at", null: false
176 - t.datetime "updated_at", :null => false
176 + t.datetime "updated_at", null: false
177 end
177 end
178
178
179 - create_table "submissions", :force => true do |t|
179 + create_table "submissions", force: :cascade do |t|
180 t.integer "user_id"
180 t.integer "user_id"
181 t.integer "problem_id"
181 t.integer "problem_id"
182 t.integer "language_id"
182 t.integer "language_id"
183 t.text "source"
183 t.text "source"
184 t.binary "binary"
184 t.binary "binary"
185 t.datetime "submitted_at"
185 t.datetime "submitted_at"
186 t.datetime "compiled_at"
186 t.datetime "compiled_at"
187 t.text "compiler_message"
187 t.text "compiler_message"
188 t.datetime "graded_at"
188 t.datetime "graded_at"
189 t.integer "points"
189 t.integer "points"
190 t.text "grader_comment"
190 t.text "grader_comment"
191 t.integer "number"
191 t.integer "number"
192 t.string "source_filename"
192 t.string "source_filename"
193 t.float "max_runtime"
193 t.float "max_runtime"
194 t.integer "peak_memory"
194 t.integer "peak_memory"
195 t.integer "effective_code_length"
195 t.integer "effective_code_length"
196 t.string "ip_address"
196 t.string "ip_address"
197 end
197 end
198
198
199 - add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
199 + add_index "submissions", ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true
200 - add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
200 + add_index "submissions", ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id"
201
201
202 - create_table "tasks", :force => true do |t|
202 + create_table "tasks", force: :cascade do |t|
203 t.integer "submission_id"
203 t.integer "submission_id"
204 t.datetime "created_at"
204 t.datetime "created_at"
205 t.integer "status"
205 t.integer "status"
206 t.datetime "updated_at"
206 t.datetime "updated_at"
207 end
207 end
208
208
209 - create_table "test_pairs", :force => true do |t|
209 + create_table "test_pairs", force: :cascade do |t|
210 t.integer "problem_id"
210 t.integer "problem_id"
211 - t.text "input", :limit => 16777215
211 + t.text "input", limit: 16777215
212 - t.text "solution", :limit => 16777215
212 + t.text "solution", limit: 16777215
213 - t.datetime "created_at", :null => false
213 + t.datetime "created_at", null: false
214 - t.datetime "updated_at", :null => false
214 + t.datetime "updated_at", null: false
215 end
215 end
216
216
217 - create_table "test_requests", :force => true do |t|
217 + create_table "test_requests", force: :cascade do |t|
218 t.integer "user_id"
218 t.integer "user_id"
219 t.integer "problem_id"
219 t.integer "problem_id"
220 t.integer "submission_id"
220 t.integer "submission_id"
221 t.string "input_file_name"
221 t.string "input_file_name"
222 t.string "output_file_name"
222 t.string "output_file_name"
223 t.string "running_stat"
223 t.string "running_stat"
224 t.integer "status"
224 t.integer "status"
225 - t.datetime "updated_at", :null => false
225 + t.datetime "updated_at", null: false
226 t.datetime "submitted_at"
226 t.datetime "submitted_at"
227 t.datetime "compiled_at"
227 t.datetime "compiled_at"
228 t.text "compiler_message"
228 t.text "compiler_message"
229 t.datetime "graded_at"
229 t.datetime "graded_at"
230 t.string "grader_comment"
230 t.string "grader_comment"
231 - t.datetime "created_at", :null => false
231 + t.datetime "created_at", null: false
232 t.float "running_time"
232 t.float "running_time"
233 t.string "exit_status"
233 t.string "exit_status"
234 t.integer "memory_usage"
234 t.integer "memory_usage"
235 end
235 end
236
236
237 - add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
237 + add_index "test_requests", ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id"
238
238
239 - create_table "testcases", :force => true do |t|
239 + create_table "testcases", force: :cascade do |t|
240 t.integer "problem_id"
240 t.integer "problem_id"
241 t.integer "num"
241 t.integer "num"
242 t.integer "group"
242 t.integer "group"
243 t.integer "score"
243 t.integer "score"
244 t.text "input"
244 t.text "input"
245 t.text "sol"
245 t.text "sol"
246 - t.datetime "created_at", :null => false
246 + t.datetime "created_at", null: false
247 - t.datetime "updated_at", :null => false
247 + t.datetime "updated_at", null: false
248 end
248 end
249
249
250 - add_index "testcases", ["problem_id"], :name => "index_testcases_on_problem_id"
250 + add_index "testcases", ["problem_id"], name: "index_testcases_on_problem_id"
251
251
252 - create_table "user_contest_stats", :force => true do |t|
252 + create_table "user_contest_stats", force: :cascade do |t|
253 t.integer "user_id"
253 t.integer "user_id"
254 t.datetime "started_at"
254 t.datetime "started_at"
255 - t.datetime "created_at", :null => false
255 + t.datetime "created_at", null: false
256 - t.datetime "updated_at", :null => false
256 + t.datetime "updated_at", null: false
257 t.boolean "forced_logout"
257 t.boolean "forced_logout"
258 end
258 end
259
259
260 - create_table "users", :force => true do |t|
260 + create_table "users", force: :cascade do |t|
261 - t.string "login", :limit => 50
261 + t.string "login", limit: 50
262 t.string "full_name"
262 t.string "full_name"
263 t.string "hashed_password"
263 t.string "hashed_password"
264 - t.string "salt", :limit => 5
264 + t.string "salt", limit: 5
265 t.string "alias"
265 t.string "alias"
266 t.string "email"
266 t.string "email"
267 t.integer "site_id"
267 t.integer "site_id"
268 t.integer "country_id"
268 t.integer "country_id"
269 - t.boolean "activated", :default => false
269 + t.boolean "activated", default: false
270 t.datetime "created_at"
270 t.datetime "created_at"
271 t.datetime "updated_at"
271 t.datetime "updated_at"
272 - t.boolean "enabled", :default => true
272 + t.boolean "enabled", default: true
273 t.string "remark"
273 t.string "remark"
274 t.string "last_ip"
274 t.string "last_ip"
275 t.string "section"
275 t.string "section"
276 end
276 end
277
277
278 - add_index "users", ["login"], :name => "index_users_on_login", :unique => true
278 + add_index "users", ["login"], name: "index_users_on_login", unique: true
279
279
280 end
280 end
@@ -44,45 +44,60
44 :value_type => 'string',
44 :value_type => 'string',
45 :default_value => 'Grader',
45 :default_value => 'Grader',
46 :description => 'This name will be shown on the user header bar.'
46 :description => 'This name will be shown on the user header bar.'
47 },
47 },
48
48
49 {
49 {
50 :key => 'contest.multisites',
50 :key => 'contest.multisites',
51 :value_type => 'boolean',
51 :value_type => 'boolean',
52 :default_value => 'false',
52 :default_value => 'false',
53 :description => 'If the server is in contest mode and this option is true, on the log in of the admin a menu for site selections is shown.'
53 :description => 'If the server is in contest mode and this option is true, on the log in of the admin a menu for site selections is shown.'
54 },
54 },
55
55
56 + #---------------------------- right --------------------------------
56 {
57 {
57 :key => 'right.user_hall_of_fame',
58 :key => 'right.user_hall_of_fame',
58 :value_type => 'boolean',
59 :value_type => 'boolean',
59 :default_value => 'false',
60 :default_value => 'false',
60 :description => 'If true, any user can access hall of fame page.'
61 :description => 'If true, any user can access hall of fame page.'
61 },
62 },
62
63
63 {
64 {
64 :key => 'right.multiple_ip_login',
65 :key => 'right.multiple_ip_login',
65 :value_type => 'boolean',
66 :value_type => 'boolean',
66 :default_value => 'true',
67 :default_value => 'true',
67 :description => 'When change from true to false, a user can login from the first IP they logged into afterward.'
68 :description => 'When change from true to false, a user can login from the first IP they logged into afterward.'
68 },
69 },
69
70
70 {
71 {
71 :key => 'right.user_view_submission',
72 :key => 'right.user_view_submission',
72 :value_type => 'boolean',
73 :value_type => 'boolean',
73 :default_value => 'false',
74 :default_value => 'false',
74 :description => 'If true, any user can view submissions of every one.'
75 :description => 'If true, any user can view submissions of every one.'
75 },
76 },
76
77
78 + {
79 + :key => 'right.bypass_agreement',
80 + :value_type => 'boolean',
81 + :default_value => 'true',
82 + :description => 'When false, a user must accept usage agreement before login'
83 + },
84 +
85 + {
86 + :key => 'right.heartbeat_response',
87 + :value_type => 'string',
88 + :default_value => 'OK',
89 + :description => 'Heart beat response text'
90 + },
91 +
77 # If Configuration['system.online_registration'] is true, the
92 # If Configuration['system.online_registration'] is true, the
78 # system allows online registration, and will use these
93 # system allows online registration, and will use these
79 # information for sending confirmation emails.
94 # information for sending confirmation emails.
80 {
95 {
81 :key => 'system.online_registration.smtp',
96 :key => 'system.online_registration.smtp',
82 :value_type => 'string',
97 :value_type => 'string',
83 :default_value => 'smtp.somehost.com'
98 :default_value => 'smtp.somehost.com'
84 },
99 },
85
100
86 {
101 {
87 :key => 'system.online_registration.from',
102 :key => 'system.online_registration.from',
88 :value_type => 'string',
103 :value_type => 'string',
@@ -1,17 +1,17
1 ENV["RAILS_ENV"] = "test"
1 ENV["RAILS_ENV"] = "test"
2 require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
2 require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
3
3
4 def clear_all_tasks
4 def clear_all_tasks
5 - Task.find(:all).each do |task|
5 + Task.all.each do |task|
6 task.destroy
6 task.destroy
7 end
7 end
8 end
8 end
9
9
10
10
11 clear_all_tasks
11 clear_all_tasks
12
12
13 (1..1000).each do |i|
13 (1..1000).each do |i|
14 Task.create(:id => i,
14 Task.create(:id => i,
15 :submission_id => i,
15 :submission_id => i,
16 :status => Task::STATUS_INQUEUE)
16 :status => Task::STATUS_INQUEUE)
17 end
17 end
@@ -1,14 +1,13
1 ENV["RAILS_ENV"] = "test"
1 ENV["RAILS_ENV"] = "test"
2 require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
2 require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
3
3
4 def clear_all_tasks
4 def clear_all_tasks
5 - Task.find(:all).each do |task|
5 + Task.all.each do |task|
6 task.destroy
6 task.destroy
7 end
7 end
8 end
8 end
9
9
10 - puts Task.find(:all,
10 + puts Task.where(status: Task::STATUS_COMPLETE).length
11 - :conditions => {:status => Task::STATUS_COMPLETE}).length
12
11
13 clear_all_tasks
12 clear_all_tasks
14
13
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
You need to be logged in to leave comments. Login now