Description:
more login test add grader configuration to fixture add minitest reporter
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r627:f6a768e3c391 - - 10 files changed: 400 inserted, 155 deleted

@@ -0,0 +1,41
1 + # Original from http://snippets.dzone.com/posts/show/4468 by MichaelBoutros
2 + #
3 + # Optimized version which uses to_yaml for content creation and checks
4 + # that models are ActiveRecord::Base models before trying to fetch
5 + # them from database.
6 + namespace :db do
7 + namespace :fixtures do
8 + desc 'Dumps all models into fixtures.'
9 + task :dump => :environment do
10 + puts "rails root = #{Rails.root}"
11 + models = Dir.glob(Rails.root.to_s + '/app/models/**.rb').map do |s|
12 + Pathname.new(s).basename.to_s.gsub(/\.rb$/,'').camelize
13 + end
14 +
15 + puts "Found models: " + models.join(', ')
16 +
17 + models.each do |m|
18 + model = m.constantize
19 + next unless model.ancestors.include?(ActiveRecord::Base)
20 +
21 + puts "Dumping model: " + m
22 + entries = model.all.order(id: :asc)
23 +
24 + increment = 1
25 +
26 + model_file = Rails.root.to_s + '/test/fixtures2/' + m.underscore.pluralize + '.yml'
27 + File.open(model_file, 'w') do |f|
28 + entries.each do |a|
29 + attrs = a.attributes
30 + attrs.delete_if{|k,v| v.blank?}
31 +
32 + output = {m + '_' + increment.to_s => attrs}
33 + f << output.to_yaml.gsub(/^--- \n/,'') + "\n"
34 +
35 + increment += 1
36 + end
37 + end
38 + end
39 + end
40 + end
41 + end
@@ -0,0 +1,144
1 + GraderConfiguration_1:
2 + key: system.single_user_mode
3 + value_type: boolean
4 + value: 'false'
5 + description: Only admins can log in to the system when running under single user mode.
6 +
7 + GraderConfiguration_2:
8 + key: ui.front.title
9 + value_type: string
10 + value: Grader
11 +
12 + GraderConfiguration_3:
13 + key: ui.front.welcome_message
14 + value_type: string
15 + value: Welcome!
16 +
17 + GraderConfiguration_4:
18 + key: ui.show_score
19 + value_type: boolean
20 + value: 'true'
21 +
22 + GraderConfiguration_5:
23 + key: contest.time_limit
24 + value_type: string
25 + value: unlimited
26 + description: Time limit in format hh:mm, or "unlimited" for contests with no time
27 + limits. This config is CACHED. Restart the server before the change can take
28 + effect.
29 +
30 + GraderConfiguration_6:
31 + key: system.mode
32 + value_type: string
33 + value: standard
34 + description: Current modes are "standard", "contest", "indv-contest", and "analysis".
35 +
36 +
37 + GraderConfiguration_7:
38 + key: contest.name
39 + value_type: string
40 + value: Grader
41 + description: This name will be shown on the user header bar.
42 +
43 +
44 + GraderConfiguration_8:
45 + key: contest.multisites
46 + value_type: boolean
47 + value: 'false'
48 + description: If the server is in contest mode and this option is true, on the log
49 + in of the admin a menu for site selections is shown.
50 +
51 +
52 + GraderConfiguration_9:
53 + key: right.user_hall_of_fame
54 + value_type: boolean
55 + value: 'false'
56 + description: If true, any user can access hall of fame page.
57 +
58 +
59 + GraderConfiguration_10:
60 + key: right.multiple_ip_login
61 + value_type: boolean
62 + value: 'true'
63 + description: When change from true to false, a user can login from the first IP
64 + they logged into afterward.
65 +
66 +
67 + GraderConfiguration_11:
68 + key: right.user_view_submission
69 + value_type: boolean
70 + value: 'false'
71 + description: If true, any user can view submissions of every one.
72 +
73 +
74 + GraderConfiguration_12:
75 + key: right.bypass_agreement
76 + value_type: boolean
77 + value: 'true'
78 + description: When false, a user must accept usage agreement before login
79 +
80 +
81 + GraderConfiguration_13:
82 + key: right.heartbeat_response
83 + value_type: string
84 + value: OK
85 + description: Heart beat response text
86 +
87 +
88 + GraderConfiguration_14:
89 + key: right.view_testcase
90 + value_type: boolean
91 + value: 'false'
92 + description: When true, any user can view/download test data
93 +
94 +
95 + GraderConfiguration_15:
96 + key: system.online_registration.smtp
97 + value_type: string
98 + value: smtp.somehost.com
99 +
100 +
101 + GraderConfiguration_16:
102 + key: system.online_registration.from
103 + value_type: string
104 + value: your.email@address
105 +
106 +
107 + GraderConfiguration_17:
108 + key: system.admin_email
109 + value_type: string
110 + value: admin@admin.email
111 +
112 +
113 + GraderConfiguration_18:
114 + key: system.user_setting_enabled
115 + value_type: boolean
116 + value: 'true'
117 + description: If this option is true, users can change their settings
118 +
119 +
120 + GraderConfiguration_19:
121 + key: contest.test_request.early_timeout
122 + value_type: boolean
123 + value: 'false'
124 +
125 +
126 + GraderConfiguration_20:
127 + key: system.multicontests
128 + value_type: boolean
129 + value: 'false'
130 +
131 +
132 + GraderConfiguration_21:
133 + key: contest.confirm_indv_contest_start
134 + value_type: boolean
135 + value: 'false'
136 +
137 +
138 + GraderConfiguration_22:
139 + key: contest.default_contest_name
140 + value_type: string
141 + value: none
142 + description: New user will be assigned to this contest automatically, if it exists. Set
143 + to 'none' if there is no default contest.
144 +
@@ -1,78 +1,88
1 source 'https://rubygems.org'
1 source 'https://rubygems.org'
2
2
3 + #rails
3 gem 'rails', '~>4.2.0'
4 gem 'rails', '~>4.2.0'
4 gem 'activerecord-session_store'
5 gem 'activerecord-session_store'
5
6
6 - gem 'select2-rails'
7
7
8 # Bundle edge Rails instead:
8 # Bundle edge Rails instead:
9 # gem 'rails', :git => 'git://github.com/rails/rails.git'
9 # gem 'rails', :git => 'git://github.com/rails/rails.git'
10
10
11 + #---------------- database ---------------------
12 + #the database
11 gem 'mysql2'
13 gem 'mysql2'
14 + #for testing
12 gem 'sqlite3'
15 gem 'sqlite3'
16 + #for dumping database into yaml
17 + gem 'yaml_db'
13
18
14 # Gems used only for assets and not required
19 # Gems used only for assets and not required
15 # in production environments by default.
20 # in production environments by default.
16 gem 'sass-rails'
21 gem 'sass-rails'
17 gem 'coffee-rails'
22 gem 'coffee-rails'
18
23
19 # See https://github.com/sstephenson/execjs#readme for more supported runtimes
24 # See https://github.com/sstephenson/execjs#readme for more supported runtimes
20 # gem 'therubyracer', :platforms => :ruby
25 # gem 'therubyracer', :platforms => :ruby
21
26
22 gem 'uglifier'
27 gem 'uglifier'
23
28
24 -
29 + gem 'haml'
30 + gem 'haml-rails'
25 # gem 'prototype-rails'
31 # gem 'prototype-rails'
26
32
27 # To use ActiveModel has_secure_password
33 # To use ActiveModel has_secure_password
28 # gem 'bcrypt-ruby', '~> 3.0.0'
34 # gem 'bcrypt-ruby', '~> 3.0.0'
29
35
30 # To use Jbuilder templates for JSON
36 # To use Jbuilder templates for JSON
31 # gem 'jbuilder'
37 # gem 'jbuilder'
32
38
33 # Use unicorn as the app server
39 # Use unicorn as the app server
34 # gem 'unicorn'
40 # gem 'unicorn'
35
41
36 # Deploy with Capistrano
42 # Deploy with Capistrano
37 # gem 'capistrano'
43 # gem 'capistrano'
38
44
39 # To use debugger
45 # To use debugger
40 # gem 'debugger'
46 # gem 'debugger'
41 #
47 #
42
48
43 #in-place editor
49 #in-place editor
44 gem 'best_in_place', '~> 3.0.1'
50 gem 'best_in_place', '~> 3.0.1'
45
51
46 # jquery addition
52 # jquery addition
47 gem 'jquery-rails'
53 gem 'jquery-rails'
48 gem 'jquery-ui-rails'
54 gem 'jquery-ui-rails'
49 gem 'jquery-timepicker-addon-rails'
55 gem 'jquery-timepicker-addon-rails'
50 gem 'jquery-tablesorter'
56 gem 'jquery-tablesorter'
51 gem 'jquery-countdown-rails'
57 gem 'jquery-countdown-rails'
52
58
53 #syntax highlighter
59 #syntax highlighter
54 gem 'rouge'
60 gem 'rouge'
55
61
56 #add bootstrap
62 #add bootstrap
57 gem 'bootstrap-sass', '~> 3.2.0'
63 gem 'bootstrap-sass', '~> 3.2.0'
58 gem 'bootstrap-switch-rails'
64 gem 'bootstrap-switch-rails'
59 gem 'bootstrap-toggle-rails'
65 gem 'bootstrap-toggle-rails'
60 gem 'autoprefixer-rails'
66 gem 'autoprefixer-rails'
61
67
62 #bootstrap sortable
68 #bootstrap sortable
63 gem 'momentjs-rails'
69 gem 'momentjs-rails'
64 gem 'rails_bootstrap_sortable'
70 gem 'rails_bootstrap_sortable'
65
71
72 + #----------- user interface -----------------
73 + #select 2
74 + gem 'select2-rails'
66 #ace editor
75 #ace editor
67 gem 'ace-rails-ap'
76 gem 'ace-rails-ap'
77 + #paginator
78 + gem 'will_paginate', '~> 3.0.7'
68
79
69 - gem 'haml'
70 - gem 'haml-rails'
71 gem 'mail'
80 gem 'mail'
72 gem 'rdiscount'
81 gem 'rdiscount'
73 - #gem 'test-unit'
74 - gem 'will_paginate', '~> 3.0.7'
75 gem 'dynamic_form'
82 gem 'dynamic_form'
76 gem 'in_place_editing'
83 gem 'in_place_editing'
77 gem 'verification', :git => 'https://github.com/sikachu/verification.git'
84 gem 'verification', :git => 'https://github.com/sikachu/verification.git'
78
85
86 +
87 + #---------------- testiing -----------------------
88 + gem 'minitest-reporters'
@@ -1,217 +1,229
1 GIT
1 GIT
2 remote: https://github.com/sikachu/verification.git
2 remote: https://github.com/sikachu/verification.git
3 revision: ff31697b940d7b0e2ec65f08764215c96104e76d
3 revision: ff31697b940d7b0e2ec65f08764215c96104e76d
4 specs:
4 specs:
5 verification (1.0.3)
5 verification (1.0.3)
6 actionpack (>= 3.0.0, < 5.1)
6 actionpack (>= 3.0.0, < 5.1)
7 activesupport (>= 3.0.0, < 5.1)
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.1.1)
12 ace-rails-ap (4.1.1)
13 actionmailer (4.2.7.1)
13 actionmailer (4.2.7.1)
14 actionpack (= 4.2.7.1)
14 actionpack (= 4.2.7.1)
15 actionview (= 4.2.7.1)
15 actionview (= 4.2.7.1)
16 activejob (= 4.2.7.1)
16 activejob (= 4.2.7.1)
17 mail (~> 2.5, >= 2.5.4)
17 mail (~> 2.5, >= 2.5.4)
18 rails-dom-testing (~> 1.0, >= 1.0.5)
18 rails-dom-testing (~> 1.0, >= 1.0.5)
19 actionpack (4.2.7.1)
19 actionpack (4.2.7.1)
20 actionview (= 4.2.7.1)
20 actionview (= 4.2.7.1)
21 activesupport (= 4.2.7.1)
21 activesupport (= 4.2.7.1)
22 rack (~> 1.6)
22 rack (~> 1.6)
23 rack-test (~> 0.6.2)
23 rack-test (~> 0.6.2)
24 rails-dom-testing (~> 1.0, >= 1.0.5)
24 rails-dom-testing (~> 1.0, >= 1.0.5)
25 rails-html-sanitizer (~> 1.0, >= 1.0.2)
25 rails-html-sanitizer (~> 1.0, >= 1.0.2)
26 actionview (4.2.7.1)
26 actionview (4.2.7.1)
27 activesupport (= 4.2.7.1)
27 activesupport (= 4.2.7.1)
28 builder (~> 3.1)
28 builder (~> 3.1)
29 erubis (~> 2.7.0)
29 erubis (~> 2.7.0)
30 rails-dom-testing (~> 1.0, >= 1.0.5)
30 rails-dom-testing (~> 1.0, >= 1.0.5)
31 rails-html-sanitizer (~> 1.0, >= 1.0.2)
31 rails-html-sanitizer (~> 1.0, >= 1.0.2)
32 activejob (4.2.7.1)
32 activejob (4.2.7.1)
33 activesupport (= 4.2.7.1)
33 activesupport (= 4.2.7.1)
34 globalid (>= 0.3.0)
34 globalid (>= 0.3.0)
35 activemodel (4.2.7.1)
35 activemodel (4.2.7.1)
36 activesupport (= 4.2.7.1)
36 activesupport (= 4.2.7.1)
37 builder (~> 3.1)
37 builder (~> 3.1)
38 activerecord (4.2.7.1)
38 activerecord (4.2.7.1)
39 activemodel (= 4.2.7.1)
39 activemodel (= 4.2.7.1)
40 activesupport (= 4.2.7.1)
40 activesupport (= 4.2.7.1)
41 arel (~> 6.0)
41 arel (~> 6.0)
42 activerecord-session_store (1.0.0)
42 activerecord-session_store (1.0.0)
43 actionpack (>= 4.0, < 5.1)
43 actionpack (>= 4.0, < 5.1)
44 activerecord (>= 4.0, < 5.1)
44 activerecord (>= 4.0, < 5.1)
45 multi_json (~> 1.11, >= 1.11.2)
45 multi_json (~> 1.11, >= 1.11.2)
46 rack (>= 1.5.2, < 3)
46 rack (>= 1.5.2, < 3)
47 railties (>= 4.0, < 5.1)
47 railties (>= 4.0, < 5.1)
48 activesupport (4.2.7.1)
48 activesupport (4.2.7.1)
49 i18n (~> 0.7)
49 i18n (~> 0.7)
50 json (~> 1.7, >= 1.7.7)
50 json (~> 1.7, >= 1.7.7)
51 minitest (~> 5.1)
51 minitest (~> 5.1)
52 thread_safe (~> 0.3, >= 0.3.4)
52 thread_safe (~> 0.3, >= 0.3.4)
53 tzinfo (~> 1.1)
53 tzinfo (~> 1.1)
54 + ansi (1.5.0)
54 arel (6.0.4)
55 arel (6.0.4)
55 autoprefixer-rails (6.6.0)
56 autoprefixer-rails (6.6.0)
56 execjs
57 execjs
57 best_in_place (3.0.3)
58 best_in_place (3.0.3)
58 actionpack (>= 3.2)
59 actionpack (>= 3.2)
59 railties (>= 3.2)
60 railties (>= 3.2)
60 bootstrap-sass (3.2.0.2)
61 bootstrap-sass (3.2.0.2)
61 sass (~> 3.2)
62 sass (~> 3.2)
62 bootstrap-switch-rails (3.3.3)
63 bootstrap-switch-rails (3.3.3)
63 bootstrap-toggle-rails (2.2.1.0)
64 bootstrap-toggle-rails (2.2.1.0)
64 builder (3.2.2)
65 builder (3.2.2)
65 coffee-rails (4.2.1)
66 coffee-rails (4.2.1)
66 coffee-script (>= 2.2.0)
67 coffee-script (>= 2.2.0)
67 railties (>= 4.0.0, < 5.2.x)
68 railties (>= 4.0.0, < 5.2.x)
68 coffee-script (2.4.1)
69 coffee-script (2.4.1)
69 coffee-script-source
70 coffee-script-source
70 execjs
71 execjs
71 coffee-script-source (1.12.2)
72 coffee-script-source (1.12.2)
72 concurrent-ruby (1.0.4)
73 concurrent-ruby (1.0.4)
73 dynamic_form (1.1.4)
74 dynamic_form (1.1.4)
74 erubis (2.7.0)
75 erubis (2.7.0)
75 execjs (2.7.0)
76 execjs (2.7.0)
76 globalid (0.3.7)
77 globalid (0.3.7)
77 activesupport (>= 4.1.0)
78 activesupport (>= 4.1.0)
78 haml (4.0.7)
79 haml (4.0.7)
79 tilt
80 tilt
80 haml-rails (0.9.0)
81 haml-rails (0.9.0)
81 actionpack (>= 4.0.1)
82 actionpack (>= 4.0.1)
82 activesupport (>= 4.0.1)
83 activesupport (>= 4.0.1)
83 haml (>= 4.0.6, < 5.0)
84 haml (>= 4.0.6, < 5.0)
84 html2haml (>= 1.0.1)
85 html2haml (>= 1.0.1)
85 railties (>= 4.0.1)
86 railties (>= 4.0.1)
86 html2haml (2.0.0)
87 html2haml (2.0.0)
87 erubis (~> 2.7.0)
88 erubis (~> 2.7.0)
88 haml (~> 4.0.0)
89 haml (~> 4.0.0)
89 nokogiri (~> 1.6.0)
90 nokogiri (~> 1.6.0)
90 ruby_parser (~> 3.5)
91 ruby_parser (~> 3.5)
91 i18n (0.7.0)
92 i18n (0.7.0)
92 in_place_editing (1.2.0)
93 in_place_editing (1.2.0)
93 jquery-countdown-rails (2.0.2)
94 jquery-countdown-rails (2.0.2)
94 jquery-rails (4.2.1)
95 jquery-rails (4.2.1)
95 rails-dom-testing (>= 1, < 3)
96 rails-dom-testing (>= 1, < 3)
96 railties (>= 4.2.0)
97 railties (>= 4.2.0)
97 thor (>= 0.14, < 2.0)
98 thor (>= 0.14, < 2.0)
98 jquery-tablesorter (1.23.3)
99 jquery-tablesorter (1.23.3)
99 railties (>= 3.2, < 6)
100 railties (>= 3.2, < 6)
100 jquery-timepicker-addon-rails (1.4.1)
101 jquery-timepicker-addon-rails (1.4.1)
101 railties (>= 3.1)
102 railties (>= 3.1)
102 jquery-ui-rails (6.0.1)
103 jquery-ui-rails (6.0.1)
103 railties (>= 3.2.16)
104 railties (>= 3.2.16)
104 json (1.8.3)
105 json (1.8.3)
105 loofah (2.0.3)
106 loofah (2.0.3)
106 nokogiri (>= 1.5.9)
107 nokogiri (>= 1.5.9)
107 mail (2.6.4)
108 mail (2.6.4)
108 mime-types (>= 1.16, < 4)
109 mime-types (>= 1.16, < 4)
109 mime-types (3.1)
110 mime-types (3.1)
110 mime-types-data (~> 3.2015)
111 mime-types-data (~> 3.2015)
111 mime-types-data (3.2016.0521)
112 mime-types-data (3.2016.0521)
112 mini_portile2 (2.1.0)
113 mini_portile2 (2.1.0)
113 minitest (5.10.1)
114 minitest (5.10.1)
115 + minitest-reporters (1.1.13)
116 + ansi
117 + builder
118 + minitest (>= 5.0)
119 + ruby-progressbar
114 momentjs-rails (2.15.1)
120 momentjs-rails (2.15.1)
115 railties (>= 3.1)
121 railties (>= 3.1)
116 multi_json (1.12.1)
122 multi_json (1.12.1)
117 mysql2 (0.4.5)
123 mysql2 (0.4.5)
118 nokogiri (1.6.8.1)
124 nokogiri (1.6.8.1)
119 mini_portile2 (~> 2.1.0)
125 mini_portile2 (~> 2.1.0)
120 rack (1.6.5)
126 rack (1.6.5)
121 rack-test (0.6.3)
127 rack-test (0.6.3)
122 rack (>= 1.0)
128 rack (>= 1.0)
123 rails (4.2.7.1)
129 rails (4.2.7.1)
124 actionmailer (= 4.2.7.1)
130 actionmailer (= 4.2.7.1)
125 actionpack (= 4.2.7.1)
131 actionpack (= 4.2.7.1)
126 actionview (= 4.2.7.1)
132 actionview (= 4.2.7.1)
127 activejob (= 4.2.7.1)
133 activejob (= 4.2.7.1)
128 activemodel (= 4.2.7.1)
134 activemodel (= 4.2.7.1)
129 activerecord (= 4.2.7.1)
135 activerecord (= 4.2.7.1)
130 activesupport (= 4.2.7.1)
136 activesupport (= 4.2.7.1)
131 bundler (>= 1.3.0, < 2.0)
137 bundler (>= 1.3.0, < 2.0)
132 railties (= 4.2.7.1)
138 railties (= 4.2.7.1)
133 sprockets-rails
139 sprockets-rails
134 rails-deprecated_sanitizer (1.0.3)
140 rails-deprecated_sanitizer (1.0.3)
135 activesupport (>= 4.2.0.alpha)
141 activesupport (>= 4.2.0.alpha)
136 rails-dom-testing (1.0.8)
142 rails-dom-testing (1.0.8)
137 activesupport (>= 4.2.0.beta, < 5.0)
143 activesupport (>= 4.2.0.beta, < 5.0)
138 nokogiri (~> 1.6)
144 nokogiri (~> 1.6)
139 rails-deprecated_sanitizer (>= 1.0.1)
145 rails-deprecated_sanitizer (>= 1.0.1)
140 rails-html-sanitizer (1.0.3)
146 rails-html-sanitizer (1.0.3)
141 loofah (~> 2.0)
147 loofah (~> 2.0)
142 rails_bootstrap_sortable (2.0.1)
148 rails_bootstrap_sortable (2.0.1)
143 momentjs-rails (>= 2.8.3)
149 momentjs-rails (>= 2.8.3)
144 railties (4.2.7.1)
150 railties (4.2.7.1)
145 actionpack (= 4.2.7.1)
151 actionpack (= 4.2.7.1)
146 activesupport (= 4.2.7.1)
152 activesupport (= 4.2.7.1)
147 rake (>= 0.8.7)
153 rake (>= 0.8.7)
148 thor (>= 0.18.1, < 2.0)
154 thor (>= 0.18.1, < 2.0)
149 rake (12.0.0)
155 rake (12.0.0)
150 rdiscount (2.2.0.1)
156 rdiscount (2.2.0.1)
151 rouge (2.0.7)
157 rouge (2.0.7)
158 + ruby-progressbar (1.8.1)
152 ruby_parser (3.8.3)
159 ruby_parser (3.8.3)
153 sexp_processor (~> 4.1)
160 sexp_processor (~> 4.1)
154 sass (3.4.23)
161 sass (3.4.23)
155 sass-rails (5.0.6)
162 sass-rails (5.0.6)
156 railties (>= 4.0.0, < 6)
163 railties (>= 4.0.0, < 6)
157 sass (~> 3.1)
164 sass (~> 3.1)
158 sprockets (>= 2.8, < 4.0)
165 sprockets (>= 2.8, < 4.0)
159 sprockets-rails (>= 2.0, < 4.0)
166 sprockets-rails (>= 2.0, < 4.0)
160 tilt (>= 1.1, < 3)
167 tilt (>= 1.1, < 3)
161 select2-rails (4.0.3)
168 select2-rails (4.0.3)
162 thor (~> 0.14)
169 thor (~> 0.14)
163 sexp_processor (4.7.0)
170 sexp_processor (4.7.0)
164 sprockets (3.7.1)
171 sprockets (3.7.1)
165 concurrent-ruby (~> 1.0)
172 concurrent-ruby (~> 1.0)
166 rack (> 1, < 3)
173 rack (> 1, < 3)
167 sprockets-rails (3.2.0)
174 sprockets-rails (3.2.0)
168 actionpack (>= 4.0)
175 actionpack (>= 4.0)
169 activesupport (>= 4.0)
176 activesupport (>= 4.0)
170 sprockets (>= 3.0.0)
177 sprockets (>= 3.0.0)
171 sqlite3 (1.3.12)
178 sqlite3 (1.3.12)
172 thor (0.19.4)
179 thor (0.19.4)
173 thread_safe (0.3.5)
180 thread_safe (0.3.5)
174 tilt (2.0.5)
181 tilt (2.0.5)
175 tzinfo (1.2.2)
182 tzinfo (1.2.2)
176 thread_safe (~> 0.1)
183 thread_safe (~> 0.1)
177 uglifier (3.0.4)
184 uglifier (3.0.4)
178 execjs (>= 0.3.0, < 3)
185 execjs (>= 0.3.0, < 3)
179 will_paginate (3.0.12)
186 will_paginate (3.0.12)
187 + yaml_db (0.4.2)
188 + rails (>= 3.0, < 5.1)
189 + rake (>= 0.8.7)
180
190
181 PLATFORMS
191 PLATFORMS
182 ruby
192 ruby
183
193
184 DEPENDENCIES
194 DEPENDENCIES
185 ace-rails-ap
195 ace-rails-ap
186 activerecord-session_store
196 activerecord-session_store
187 autoprefixer-rails
197 autoprefixer-rails
188 best_in_place (~> 3.0.1)
198 best_in_place (~> 3.0.1)
189 bootstrap-sass (~> 3.2.0)
199 bootstrap-sass (~> 3.2.0)
190 bootstrap-switch-rails
200 bootstrap-switch-rails
191 bootstrap-toggle-rails
201 bootstrap-toggle-rails
192 coffee-rails
202 coffee-rails
193 dynamic_form
203 dynamic_form
194 haml
204 haml
195 haml-rails
205 haml-rails
196 in_place_editing
206 in_place_editing
197 jquery-countdown-rails
207 jquery-countdown-rails
198 jquery-rails
208 jquery-rails
199 jquery-tablesorter
209 jquery-tablesorter
200 jquery-timepicker-addon-rails
210 jquery-timepicker-addon-rails
201 jquery-ui-rails
211 jquery-ui-rails
202 mail
212 mail
213 + minitest-reporters
203 momentjs-rails
214 momentjs-rails
204 mysql2
215 mysql2
205 rails (~> 4.2.0)
216 rails (~> 4.2.0)
206 rails_bootstrap_sortable
217 rails_bootstrap_sortable
207 rdiscount
218 rdiscount
208 rouge
219 rouge
209 sass-rails
220 sass-rails
210 select2-rails
221 select2-rails
211 sqlite3
222 sqlite3
212 uglifier
223 uglifier
213 verification!
224 verification!
214 will_paginate (~> 3.0.7)
225 will_paginate (~> 3.0.7)
226 + yaml_db
215
227
216 BUNDLED WITH
228 BUNDLED WITH
217 1.13.6
229 1.13.6
@@ -1,137 +1,137
1 class ApplicationController < ActionController::Base
1 class ApplicationController < ActionController::Base
2 protect_from_forgery
2 protect_from_forgery
3
3
4 - before_filter :current_user
4 + before_filter :current_user
5
5
6 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
6 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
7 MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login'
7 MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login'
8
8
9 #report and redirect for unauthorized activities
9 #report and redirect for unauthorized activities
10 def unauthorized_redirect
10 def unauthorized_redirect
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.includes(:roles).find(session[:user_id])
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
36 return false
36 return false
37 end
37 end
38 end
38 end
39
39
40 def testcase_authorization
40 def testcase_authorization
41 #admin always has privileged
41 #admin always has privileged
42 if @current_user.admin?
42 if @current_user.admin?
43 return true
43 return true
44 end
44 end
45
45
46 unauthorized_redirect if GraderConfiguration["right.view_testcase"]
46 unauthorized_redirect if GraderConfiguration["right.view_testcase"]
47 end
47 end
48
48
49 protected
49 protected
50
50
51 def authenticate
51 def authenticate
52 unless session[:user_id]
52 unless session[:user_id]
53 flash[:notice] = 'You need to login'
53 flash[:notice] = 'You need to login'
54 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
54 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
55 flash[:notice] = 'You need to login but you cannot log in at this time'
55 flash[:notice] = 'You need to login but you cannot log in at this time'
56 end
56 end
57 redirect_to :controller => 'main', :action => 'login'
57 redirect_to :controller => 'main', :action => 'login'
58 return false
58 return false
59 end
59 end
60
60
61 # check if run in single user mode
61 # check if run in single user mode
62 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
62 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
63 user = User.find_by_id(session[:user_id])
63 user = User.find_by_id(session[:user_id])
64 if user==nil or (not user.admin?)
64 if user==nil or (not user.admin?)
65 flash[:notice] = 'You cannot log in at this time'
65 flash[:notice] = 'You cannot log in at this time'
66 redirect_to :controller => 'main', :action => 'login'
66 redirect_to :controller => 'main', :action => 'login'
67 return false
67 return false
68 end
68 end
69 unless user.enabled?
69 unless user.enabled?
70 flash[:notice] = 'Your account is disabled'
70 flash[:notice] = 'Your account is disabled'
71 redirect_to :controller => 'main', :action => 'login'
71 redirect_to :controller => 'main', :action => 'login'
72 return false
72 return false
73 end
73 end
74 return true
74 return true
75 end
75 end
76
76
77 if GraderConfiguration.multicontests?
77 if GraderConfiguration.multicontests?
78 user = User.find(session[:user_id])
78 user = User.find(session[:user_id])
79 return true if user.admin?
79 return true if user.admin?
80 begin
80 begin
81 if user.contest_stat(true).forced_logout
81 if user.contest_stat(true).forced_logout
82 flash[:notice] = 'You have been automatically logged out.'
82 flash[:notice] = 'You have been automatically logged out.'
83 redirect_to :controller => 'main', :action => 'index'
83 redirect_to :controller => 'main', :action => 'index'
84 end
84 end
85 rescue
85 rescue
86 end
86 end
87 end
87 end
88 return true
88 return true
89 end
89 end
90
90
91 def authenticate_by_ip_address
91 def authenticate_by_ip_address
92 #this assume that we have already authenticate normally
92 #this assume that we have already authenticate normally
93 unless GraderConfiguration[MULTIPLE_IP_LOGIN_CONF_KEY]
93 unless GraderConfiguration[MULTIPLE_IP_LOGIN_CONF_KEY]
94 user = User.find(session[:user_id])
94 user = User.find(session[:user_id])
95 if (not user.admin? and user.last_ip and user.last_ip != request.remote_ip)
95 if (not user.admin? and user.last_ip and user.last_ip != request.remote_ip)
96 flash[:notice] = "You cannot use the system from #{request.remote_ip}. Your last ip is #{user.last_ip}"
96 flash[:notice] = "You cannot use the system from #{request.remote_ip}. Your last ip is #{user.last_ip}"
97 redirect_to :controller => 'main', :action => 'login'
97 redirect_to :controller => 'main', :action => 'login'
98 puts "CHEAT: user #{user.login} tried to login from '#{request.remote_ip}' while last ip is '#{user.last_ip}' at #{Time.zone.now}"
98 puts "CHEAT: user #{user.login} tried to login from '#{request.remote_ip}' while last ip is '#{user.last_ip}' at #{Time.zone.now}"
99 return false
99 return false
100 end
100 end
101 unless user.last_ip
101 unless user.last_ip
102 user.last_ip = request.remote_ip
102 user.last_ip = request.remote_ip
103 user.save
103 user.save
104 end
104 end
105 end
105 end
106 return true
106 return true
107 end
107 end
108
108
109 def authorization
109 def authorization
110 return false unless authenticate
110 return false unless authenticate
111 user = User.find(session[:user_id])
111 user = User.find(session[:user_id])
112 unless user.roles.detect { |role|
112 unless user.roles.detect { |role|
113 role.rights.detect{ |right|
113 role.rights.detect{ |right|
114 right.controller == self.class.controller_name and
114 right.controller == self.class.controller_name and
115 (right.action == 'all' or right.action == action_name)
115 (right.action == 'all' or right.action == action_name)
116 }
116 }
117 }
117 }
118 flash[:notice] = 'You are not authorized to view the page you requested'
118 flash[:notice] = 'You are not authorized to view the page you requested'
119 #request.env['HTTP_REFERER'] ? (redirect_to :back) : (redirect_to :controller => 'login')
119 #request.env['HTTP_REFERER'] ? (redirect_to :back) : (redirect_to :controller => 'login')
120 redirect_to :controller => 'main', :action => 'login'
120 redirect_to :controller => 'main', :action => 'login'
121 return false
121 return false
122 end
122 end
123 end
123 end
124
124
125 def verify_time_limit
125 def verify_time_limit
126 return true if session[:user_id]==nil
126 return true if session[:user_id]==nil
127 user = User.find(session[:user_id], :include => :site)
127 user = User.find(session[:user_id], :include => :site)
128 return true if user==nil or user.site == nil
128 return true if user==nil or user.site == nil
129 if user.contest_finished?
129 if user.contest_finished?
130 flash[:notice] = 'Error: the contest you are participating is over.'
130 flash[:notice] = 'Error: the contest you are participating is over.'
131 redirect_to :back
131 redirect_to :back
132 return false
132 return false
133 end
133 end
134 return true
134 return true
135 end
135 end
136
136
137 end
137 end
@@ -1,183 +1,183
1 require 'yaml'
1 require 'yaml'
2
2
3 #
3 #
4 # This class also contains various login of the system.
4 # This class also contains various login of the system.
5 #
5 #
6 class GraderConfiguration < ActiveRecord::Base
6 class GraderConfiguration < ActiveRecord::Base
7
7
8 SYSTEM_MODE_CONF_KEY = 'system.mode'
8 SYSTEM_MODE_CONF_KEY = 'system.mode'
9 TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout'
9 TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout'
10 MULTICONTESTS_KEY = 'system.multicontests'
10 MULTICONTESTS_KEY = 'system.multicontests'
11 CONTEST_TIME_LIMIT_KEY = 'contest.time_limit'
11 CONTEST_TIME_LIMIT_KEY = 'contest.time_limit'
12 MULTIPLE_IP_LOGIN_KEY = 'right.multiple_ip_login'
12 MULTIPLE_IP_LOGIN_KEY = 'right.multiple_ip_login'
13 VIEW_TESTCASE = 'right.view_testcase'
13 VIEW_TESTCASE = 'right.view_testcase'
14 - SINGLE_USER_KEY = 'system.single_user'
14 + SINGLE_USER_KEY = 'system.single_user_mode'
15
15
16 cattr_accessor :config_cache
16 cattr_accessor :config_cache
17 cattr_accessor :task_grading_info_cache
17 cattr_accessor :task_grading_info_cache
18 cattr_accessor :contest_time_str
18 cattr_accessor :contest_time_str
19 cattr_accessor :contest_time
19 cattr_accessor :contest_time
20
20
21 GraderConfiguration.config_cache = nil
21 GraderConfiguration.config_cache = nil
22 GraderConfiguration.task_grading_info_cache = nil
22 GraderConfiguration.task_grading_info_cache = nil
23
23
24 def self.config_cached?
24 def self.config_cached?
25 (defined? CONFIGURATION_CACHE_ENABLED) and (CONFIGURATION_CACHE_ENABLED)
25 (defined? CONFIGURATION_CACHE_ENABLED) and (CONFIGURATION_CACHE_ENABLED)
26 end
26 end
27
27
28 def self.get(key)
28 def self.get(key)
29 if GraderConfiguration.config_cached?
29 if GraderConfiguration.config_cached?
30 if GraderConfiguration.config_cache == nil
30 if GraderConfiguration.config_cache == nil
31 self.read_config
31 self.read_config
32 end
32 end
33 return GraderConfiguration.config_cache[key]
33 return GraderConfiguration.config_cache[key]
34 else
34 else
35 return GraderConfiguration.read_one_key(key)
35 return GraderConfiguration.read_one_key(key)
36 end
36 end
37 end
37 end
38
38
39 def self.[](key)
39 def self.[](key)
40 self.get(key)
40 self.get(key)
41 end
41 end
42
42
43 def self.reload
43 def self.reload
44 self.read_config
44 self.read_config
45 end
45 end
46
46
47 def self.clear
47 def self.clear
48 GraderConfiguration.config_cache = nil
48 GraderConfiguration.config_cache = nil
49 end
49 end
50
50
51 #
51 #
52 # View decision
52 # View decision
53 #
53 #
54 def self.show_submitbox_to?(user)
54 def self.show_submitbox_to?(user)
55 mode = get(SYSTEM_MODE_CONF_KEY)
55 mode = get(SYSTEM_MODE_CONF_KEY)
56 return false if mode=='analysis'
56 return false if mode=='analysis'
57 if (mode=='contest')
57 if (mode=='contest')
58 return false if (user.site!=nil) and
58 return false if (user.site!=nil) and
59 ((user.site.started!=true) or (user.site.finished?))
59 ((user.site.started!=true) or (user.site.finished?))
60 end
60 end
61 return true
61 return true
62 end
62 end
63
63
64 def self.show_tasks_to?(user)
64 def self.show_tasks_to?(user)
65 if time_limit_mode?
65 if time_limit_mode?
66 return false if not user.contest_started?
66 return false if not user.contest_started?
67 end
67 end
68 return true
68 return true
69 end
69 end
70
70
71 def self.show_grading_result
71 def self.show_grading_result
72 return (get(SYSTEM_MODE_CONF_KEY)=='analysis')
72 return (get(SYSTEM_MODE_CONF_KEY)=='analysis')
73 end
73 end
74
74
75 def self.show_testcase
75 def self.show_testcase
76 return get(VIEW_TESTCASE)
76 return get(VIEW_TESTCASE)
77 end
77 end
78
78
79 def self.allow_test_request(user)
79 def self.allow_test_request(user)
80 mode = get(SYSTEM_MODE_CONF_KEY)
80 mode = get(SYSTEM_MODE_CONF_KEY)
81 early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY)
81 early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY)
82 if (mode=='contest')
82 if (mode=='contest')
83 return false if ((user.site!=nil) and
83 return false if ((user.site!=nil) and
84 ((user.site.started!=true) or
84 ((user.site.started!=true) or
85 (early_timeout and (user.site.time_left < 30.minutes))))
85 (early_timeout and (user.site.time_left < 30.minutes))))
86 end
86 end
87 return false if mode=='analysis'
87 return false if mode=='analysis'
88 return true
88 return true
89 end
89 end
90
90
91 def self.task_grading_info
91 def self.task_grading_info
92 if GraderConfiguration.task_grading_info_cache==nil
92 if GraderConfiguration.task_grading_info_cache==nil
93 read_grading_info
93 read_grading_info
94 end
94 end
95 return GraderConfiguration.task_grading_info_cache
95 return GraderConfiguration.task_grading_info_cache
96 end
96 end
97
97
98 def self.standard_mode?
98 def self.standard_mode?
99 return get(SYSTEM_MODE_CONF_KEY) == 'standard'
99 return get(SYSTEM_MODE_CONF_KEY) == 'standard'
100 end
100 end
101
101
102 def self.contest_mode?
102 def self.contest_mode?
103 return get(SYSTEM_MODE_CONF_KEY) == 'contest'
103 return get(SYSTEM_MODE_CONF_KEY) == 'contest'
104 end
104 end
105
105
106 def self.indv_contest_mode?
106 def self.indv_contest_mode?
107 return get(SYSTEM_MODE_CONF_KEY) == 'indv-contest'
107 return get(SYSTEM_MODE_CONF_KEY) == 'indv-contest'
108 end
108 end
109
109
110 def self.multicontests?
110 def self.multicontests?
111 return get(MULTICONTESTS_KEY) == true
111 return get(MULTICONTESTS_KEY) == true
112 end
112 end
113
113
114 def self.time_limit_mode?
114 def self.time_limit_mode?
115 mode = get(SYSTEM_MODE_CONF_KEY)
115 mode = get(SYSTEM_MODE_CONF_KEY)
116 return ((mode == 'contest') or (mode == 'indv-contest'))
116 return ((mode == 'contest') or (mode == 'indv-contest'))
117 end
117 end
118
118
119 def self.analysis_mode?
119 def self.analysis_mode?
120 return get(SYSTEM_MODE_CONF_KEY) == 'analysis'
120 return get(SYSTEM_MODE_CONF_KEY) == 'analysis'
121 end
121 end
122
122
123 def self.contest_time_limit
123 def self.contest_time_limit
124 contest_time_str = GraderConfiguration[CONTEST_TIME_LIMIT_KEY]
124 contest_time_str = GraderConfiguration[CONTEST_TIME_LIMIT_KEY]
125
125
126 if not defined? GraderConfiguration.contest_time_str
126 if not defined? GraderConfiguration.contest_time_str
127 GraderConfiguration.contest_time_str = nil
127 GraderConfiguration.contest_time_str = nil
128 end
128 end
129
129
130 if GraderConfiguration.contest_time_str != contest_time_str
130 if GraderConfiguration.contest_time_str != contest_time_str
131 GraderConfiguration.contest_time_str = contest_time_str
131 GraderConfiguration.contest_time_str = contest_time_str
132 if tmatch = /(\d+):(\d+)/.match(contest_time_str)
132 if tmatch = /(\d+):(\d+)/.match(contest_time_str)
133 h = tmatch[1].to_i
133 h = tmatch[1].to_i
134 m = tmatch[2].to_i
134 m = tmatch[2].to_i
135
135
136 GraderConfiguration.contest_time = h.hour + m.minute
136 GraderConfiguration.contest_time = h.hour + m.minute
137 else
137 else
138 GraderConfiguration.contest_time = nil
138 GraderConfiguration.contest_time = nil
139 end
139 end
140 end
140 end
141 return GraderConfiguration.contest_time
141 return GraderConfiguration.contest_time
142 end
142 end
143
143
144 protected
144 protected
145
145
146 def self.convert_type(val,type)
146 def self.convert_type(val,type)
147 case type
147 case type
148 when 'string'
148 when 'string'
149 return val
149 return val
150
150
151 when 'integer'
151 when 'integer'
152 return val.to_i
152 return val.to_i
153
153
154 when 'boolean'
154 when 'boolean'
155 return (val=='true')
155 return (val=='true')
156 end
156 end
157 end
157 end
158
158
159 def self.read_config
159 def self.read_config
160 GraderConfiguration.config_cache = {}
160 GraderConfiguration.config_cache = {}
161 GraderConfiguration.all.each do |conf|
161 GraderConfiguration.all.each do |conf|
162 key = conf.key
162 key = conf.key
163 val = conf.value
163 val = conf.value
164 GraderConfiguration.config_cache[key] = GraderConfiguration.convert_type(val,conf.value_type)
164 GraderConfiguration.config_cache[key] = GraderConfiguration.convert_type(val,conf.value_type)
165 end
165 end
166 end
166 end
167
167
168 def self.read_one_key(key)
168 def self.read_one_key(key)
169 conf = GraderConfiguration.find_by_key(key)
169 conf = GraderConfiguration.find_by_key(key)
170 if conf
170 if conf
171 return GraderConfiguration.convert_type(conf.value,conf.value_type)
171 return GraderConfiguration.convert_type(conf.value,conf.value_type)
172 else
172 else
173 return nil
173 return nil
174 end
174 end
175 end
175 end
176
176
177 def self.read_grading_info
177 def self.read_grading_info
178 f = File.open(TASK_GRADING_INFO_FILENAME)
178 f = File.open(TASK_GRADING_INFO_FILENAME)
179 GraderConfiguration.task_grading_info_cache = YAML.load(f)
179 GraderConfiguration.task_grading_info_cache = YAML.load(f)
180 f.close
180 f.close
181 end
181 end
182
182
183 end
183 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 that you 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: :cascade do |t|
16 create_table "announcements", force: :cascade do |t|
17 - t.string "author"
17 + t.string "author", limit: 255
18 - t.text "body"
18 + t.text "body", limit: 65535
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", limit: 255
25 - t.string "notes"
25 + t.string "notes", limit: 255
26 end
26 end
27
27
28 create_table "contests", force: :cascade do |t|
28 create_table "contests", force: :cascade do |t|
29 - t.string "title"
29 + t.string "title", limit: 255
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", limit: 255
34 end
34 end
35
35
36 create_table "contests_problems", id: false, force: :cascade do |t|
36 create_table "contests_problems", id: false, force: :cascade do |t|
37 - t.integer "contest_id"
37 + t.integer "contest_id", limit: 4
38 - t.integer "problem_id"
38 + t.integer "problem_id", limit: 4
39 end
39 end
40
40
41 create_table "contests_users", id: false, force: :cascade do |t|
41 create_table "contests_users", id: false, force: :cascade do |t|
42 - t.integer "contest_id"
42 + t.integer "contest_id", limit: 4
43 - t.integer "user_id"
43 + t.integer "user_id", limit: 4
44 end
44 end
45
45
46 create_table "countries", force: :cascade do |t|
46 create_table "countries", force: :cascade do |t|
47 - t.string "name"
47 + t.string "name", limit: 255
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: :cascade do |t|
52 create_table "descriptions", force: :cascade do |t|
53 - t.text "body"
53 + t.text "body", limit: 65535
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: :cascade do |t|
59 create_table "grader_configurations", force: :cascade do |t|
60 - t.string "key"
60 + t.string "key", limit: 255
61 - t.string "value_type"
61 + t.string "value_type", limit: 255
62 - t.string "value"
62 + t.string "value", limit: 255
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", limit: 65535
66 end
66 end
67
67
68 create_table "grader_processes", force: :cascade do |t|
68 create_table "grader_processes", force: :cascade do |t|
69 - t.string "host"
69 + t.string "host", limit: 255
70 - t.integer "pid"
70 + t.integer "pid", limit: 4
71 - t.string "mode"
71 + t.string "mode", limit: 255
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", limit: 4
76 - t.string "task_type"
76 + t.string "task_type", limit: 255
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", using: :btree
81
81
82 create_table "heart_beats", force: :cascade do |t|
82 create_table "heart_beats", force: :cascade do |t|
83 - t.integer "user_id"
83 + t.integer "user_id", limit: 4
84 - t.string "ip_address"
84 + t.string "ip_address", limit: 255
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", limit: 255
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", using: :btree
91
91
92 create_table "languages", force: :cascade 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", limit: 255
95 t.string "ext", limit: 10
95 t.string "ext", limit: 10
96 - t.string "common_ext"
96 + t.string "common_ext", limit: 255
97 end
97 end
98
98
99 create_table "logins", force: :cascade do |t|
99 create_table "logins", force: :cascade do |t|
100 - t.integer "user_id"
100 + t.integer "user_id", limit: 4
101 - t.string "ip_address"
101 + t.string "ip_address", limit: 255
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: :cascade do |t|
106 create_table "messages", force: :cascade do |t|
107 - t.integer "sender_id"
107 + t.integer "sender_id", limit: 4
108 - t.integer "receiver_id"
108 + t.integer "receiver_id", limit: 4
109 - t.integer "replying_message_id"
109 + t.integer "replying_message_id", limit: 4
110 - t.text "body"
110 + t.text "body", limit: 65535
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: :cascade 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", limit: 255
119 - t.integer "full_score"
119 + t.integer "full_score", limit: 4
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", limit: 255
123 - t.integer "description_id"
123 + t.integer "description_id", limit: 4
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", limit: 255
127 end
127 end
128
128
129 create_table "rights", force: :cascade do |t|
129 create_table "rights", force: :cascade do |t|
130 - t.string "name"
130 + t.string "name", limit: 255
131 - t.string "controller"
131 + t.string "controller", limit: 255
132 - t.string "action"
132 + t.string "action", limit: 255
133 end
133 end
134
134
135 create_table "rights_roles", id: false, force: :cascade do |t|
135 create_table "rights_roles", id: false, force: :cascade do |t|
136 - t.integer "right_id"
136 + t.integer "right_id", limit: 4
137 - t.integer "role_id"
137 + t.integer "role_id", limit: 4
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", using: :btree
141
141
142 create_table "roles", force: :cascade do |t|
142 create_table "roles", force: :cascade do |t|
143 - t.string "name"
143 + t.string "name", limit: 255
144 end
144 end
145
145
146 create_table "roles_users", id: false, force: :cascade do |t|
146 create_table "roles_users", id: false, force: :cascade do |t|
147 - t.integer "role_id"
147 + t.integer "role_id", limit: 4
148 - t.integer "user_id"
148 + t.integer "user_id", limit: 4
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", using: :btree
152
152
153 create_table "sessions", force: :cascade do |t|
153 create_table "sessions", force: :cascade do |t|
154 - t.string "session_id"
154 + t.string "session_id", limit: 255
155 - t.text "data"
155 + t.text "data", limit: 65535
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", using: :btree
160 - add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at"
160 + add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree
161
161
162 create_table "sites", force: :cascade do |t|
162 create_table "sites", force: :cascade do |t|
163 - t.string "name"
163 + t.string "name", limit: 255
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", limit: 4
169 - t.string "password"
169 + t.string "password", limit: 255
170 end
170 end
171
171
172 create_table "submission_view_logs", force: :cascade do |t|
172 create_table "submission_view_logs", force: :cascade do |t|
173 - t.integer "user_id"
173 + t.integer "user_id", limit: 4
174 - t.integer "submission_id"
174 + t.integer "submission_id", limit: 4
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: :cascade do |t|
179 create_table "submissions", force: :cascade do |t|
180 - t.integer "user_id"
180 + t.integer "user_id", limit: 4
181 - t.integer "problem_id"
181 + t.integer "problem_id", limit: 4
182 - t.integer "language_id"
182 + t.integer "language_id", limit: 4
183 - t.text "source"
183 + t.text "source", limit: 65535
184 - t.binary "binary"
184 + t.binary "binary", limit: 65535
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", limit: 65535
188 t.datetime "graded_at"
188 t.datetime "graded_at"
189 - t.integer "points"
189 + t.integer "points", limit: 4
190 - t.text "grader_comment"
190 + t.text "grader_comment", limit: 65535
191 - t.integer "number"
191 + t.integer "number", limit: 4
192 - t.string "source_filename"
192 + t.string "source_filename", limit: 255
193 - t.float "max_runtime"
193 + t.float "max_runtime", limit: 24
194 - t.integer "peak_memory"
194 + t.integer "peak_memory", limit: 4
195 - t.integer "effective_code_length"
195 + t.integer "effective_code_length", limit: 4
196 - t.string "ip_address"
196 + t.string "ip_address", limit: 255
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, using: :btree
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", using: :btree
201
201
202 create_table "tasks", force: :cascade do |t|
202 create_table "tasks", force: :cascade do |t|
203 - t.integer "submission_id"
203 + t.integer "submission_id", limit: 4
204 t.datetime "created_at"
204 t.datetime "created_at"
205 - t.integer "status"
205 + t.integer "status", limit: 4
206 t.datetime "updated_at"
206 t.datetime "updated_at"
207 end
207 end
208
208
209 create_table "test_pairs", force: :cascade do |t|
209 create_table "test_pairs", force: :cascade do |t|
210 - t.integer "problem_id"
210 + t.integer "problem_id", limit: 4
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: :cascade do |t|
217 create_table "test_requests", force: :cascade do |t|
218 - t.integer "user_id"
218 + t.integer "user_id", limit: 4
219 - t.integer "problem_id"
219 + t.integer "problem_id", limit: 4
220 - t.integer "submission_id"
220 + t.integer "submission_id", limit: 4
221 - t.string "input_file_name"
221 + t.string "input_file_name", limit: 255
222 - t.string "output_file_name"
222 + t.string "output_file_name", limit: 255
223 - t.string "running_stat"
223 + t.string "running_stat", limit: 255
224 - t.integer "status"
224 + t.integer "status", limit: 4
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", limit: 65535
229 t.datetime "graded_at"
229 t.datetime "graded_at"
230 - t.string "grader_comment"
230 + t.string "grader_comment", limit: 255
231 - t.datetime "created_at", null: false
231 + t.datetime "created_at", null: false
232 - t.float "running_time"
232 + t.float "running_time", limit: 24
233 - t.string "exit_status"
233 + t.string "exit_status", limit: 255
234 - t.integer "memory_usage"
234 + t.integer "memory_usage", limit: 4
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", using: :btree
238
238
239 create_table "testcases", force: :cascade do |t|
239 create_table "testcases", force: :cascade do |t|
240 - t.integer "problem_id"
240 + t.integer "problem_id", limit: 4
241 - t.integer "num"
241 + t.integer "num", limit: 4
242 - t.integer "group"
242 + t.integer "group", limit: 4
243 - t.integer "score"
243 + t.integer "score", limit: 4
244 - t.text "input"
244 + t.text "input", limit: 65535
245 - t.text "sol"
245 + t.text "sol", limit: 65535
246 - t.datetime "created_at", null: false
246 + t.datetime "created_at"
247 - t.datetime "updated_at", null: false
247 + t.datetime "updated_at"
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", using: :btree
251
251
252 create_table "user_contest_stats", force: :cascade do |t|
252 create_table "user_contest_stats", force: :cascade do |t|
253 - t.integer "user_id"
253 + t.integer "user_id", limit: 4
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: :cascade 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", limit: 255
263 - t.string "hashed_password"
263 + t.string "hashed_password", limit: 255
264 t.string "salt", limit: 5
264 t.string "salt", limit: 5
265 - t.string "alias"
265 + t.string "alias", limit: 255
266 - t.string "email"
266 + t.string "email", limit: 255
267 - t.integer "site_id"
267 + t.integer "site_id", limit: 4
268 - t.integer "country_id"
268 + t.integer "country_id", limit: 4
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", limit: 255
274 - t.string "last_ip"
274 + t.string "last_ip", limit: 255
275 - t.string "section"
275 + t.string "section", limit: 255
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, using: :btree
279
279
280 end
280 end
@@ -1,5 +1,36
1 - # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
1 + Language_1:
2 - one:
2 + name: c
3 - id: 1
3 + pretty_name: C
4 - two:
4 + ext: c
5 - id: 2
5 + common_ext: c
6 +
7 + Language_2:
8 + name: cpp
9 + pretty_name: C++
10 + ext: cpp
11 + common_ext: cpp,cc
12 +
13 + Language_3:
14 + name: pas
15 + pretty_name: Pascal
16 + ext: pas
17 + common_ext: pas
18 +
19 + Language_4:
20 + name: ruby
21 + pretty_name: Ruby
22 + ext: rb
23 + common_ext: rb
24 +
25 + Language_5:
26 + name: python
27 + pretty_name: Python
28 + ext: py
29 + common_ext: py
30 +
31 + Language_6:
32 + name: java
33 + pretty_name: Java
34 + ext: java
35 + common_ext: java
36 +
@@ -1,37 +1,40
1 require 'test_helper'
1 require 'test_helper'
2
2
3 class LoginTest < ActionDispatch::IntegrationTest
3 class LoginTest < ActionDispatch::IntegrationTest
4 # test "the truth" do
4 # test "the truth" do
5 # assert true
5 # assert true
6 # end
6 # end
7
7
8 test "login with invalid information" do
8 test "login with invalid information" do
9 get root_path
9 get root_path
10 assert_response :success
10 assert_response :success
11 post login_login_path, login: "root", password: "hahaha"
11 post login_login_path, login: "root", password: "hahaha"
12 assert_redirected_to root_path
12 assert_redirected_to root_path
13 end
13 end
14
14
15 test "normal user login" do
15 test "normal user login" do
16 get root_path
16 get root_path
17 assert_response :success
17 assert_response :success
18 post login_login_path, {login: "john", password: "hello" }
18 post login_login_path, {login: "john", password: "hello" }
19 assert_redirected_to main_list_path
19 assert_redirected_to main_list_path
20 end
20 end
21
21
22 test "normal user login in single_user mode" do
22 test "normal user login in single_user mode" do
23 - GraderConfiguration[GraderConfiguration::SINGLE_USER_KEY] = 'true'
23 + GraderConfiguration.find_by(key: GraderConfiguration::SINGLE_USER_KEY).update_attributes(value: 'true')
24 + GraderConfiguration.reload
24 get root_path
25 get root_path
25 assert_response :success
26 assert_response :success
26 post login_login_path, {login: "john", password: "hello" }
27 post login_login_path, {login: "john", password: "hello" }
28 + follow_redirect!
27 assert_redirected_to root_path
29 assert_redirected_to root_path
28 end
30 end
29
31
30 test "root login in in single_user mode" do
32 test "root login in in single_user mode" do
31 - GraderConfiguration[GraderConfiguration::SINGLE_USER_KEY] = 'true'
33 + GraderConfiguration.find_by(key: GraderConfiguration::SINGLE_USER_KEY).update_attributes(value: 'true')
34 + GraderConfiguration.reload
32 get root_path
35 get root_path
33 assert_response :success
36 assert_response :success
34 post login_login_path, {login: "admin", password: "admin" }
37 post login_login_path, {login: "admin", password: "admin" }
35 assert_redirected_to main_list_path
38 assert_redirected_to main_list_path
36 end
39 end
37 end
40 end
@@ -1,16 +1,20
1 ENV["RAILS_ENV"] = "test"
1 ENV["RAILS_ENV"] = "test"
2 require File.expand_path('../../config/environment', __FILE__)
2 require File.expand_path('../../config/environment', __FILE__)
3 require 'rails/test_help'
3 require 'rails/test_help'
4
4
5 + #reporter
6 + require "minitest/reporters"
7 + Minitest::Reporters.use!
8 +
5 class ActiveSupport::TestCase
9 class ActiveSupport::TestCase
6 # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
10 # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7 #
11 #
8 # Note: You'll currently still have to declare fixtures explicitly in integration tests
12 # Note: You'll currently still have to declare fixtures explicitly in integration tests
9 # -- they do not yet inherit this setting
13 # -- they do not yet inherit this setting
10 fixtures :all
14 fixtures :all
11
15
12 # Add more helper methods to be used by all tests here...
16 # Add more helper methods to be used by all tests here...
13
17
14 self.use_transactional_fixtures = true
18 self.use_transactional_fixtures = true
15 self.use_instantiated_fixtures = false
19 self.use_instantiated_fixtures = false
16 end
20 end
You need to be logged in to leave comments. Login now