Description:
merge
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r628:3df78cd5515f - - 25 files changed: 560 inserted, 168 deleted
@@ -0,0 +1,24 | |||
|
1 | + class TestcasesController < ApplicationController | |
|
2 | + before_action :set_testcase, only: [:download_input,:download_sol] | |
|
3 | + before_action :testcase_authorization | |
|
4 | + | |
|
5 | + def download_input | |
|
6 | + send_data @testcase.input, type: 'text/plain', filename: "#{@testcase.problem.name}.#{@testcase.num}.in" | |
|
7 | + end | |
|
8 | + | |
|
9 | + def download_sol | |
|
10 | + send_data @testcase.sol, type: 'text/plain', filename: "#{@testcase.problem.name}.#{@testcase.num}.sol" | |
|
11 | + end | |
|
12 | + | |
|
13 | + | |
|
14 | + private | |
|
15 | + # Use callbacks to share common setup or constraints between actions. | |
|
16 | + def set_testcase | |
|
17 | + @testcase = Testcase.find(params[:id]) | |
|
18 | + end | |
|
19 | + | |
|
20 | + # Only allow a trusted parameter "white list" through. | |
|
21 | + def testcase_params | |
|
22 | + params[:testcase] | |
|
23 | + end | |
|
24 | + end |
@@ -0,0 +1,25 | |||
|
1 | + %h1 Test cases | |
|
2 | + %h2= @problem.long_name | |
|
3 | + | |
|
4 | + /navbar | |
|
5 | + %ul.nav.nav-pills{role: :tablist} | |
|
6 | + - @problem.testcases.each.with_index do |tc,id| | |
|
7 | + %li{role: :presentation, class: ('active' if id == 0)} | |
|
8 | + %a{href:"#tc#{tc.id}", role: 'tab', data: {toggle: 'tab'}}= tc.num | |
|
9 | + | |
|
10 | + /actual data | |
|
11 | + .tab-content | |
|
12 | + - @problem.testcases.each.with_index do |tc,id| | |
|
13 | + .tab-pane{id: "tc#{tc.id}",class: ('active' if id == 0)} | |
|
14 | + .row | |
|
15 | + .col-md-6 | |
|
16 | + %h3 Input | |
|
17 | + = link_to "Download",download_input_problem_testcase_path(@problem,tc),class: 'btn btn-info btn-sm' | |
|
18 | + .col-md-6 | |
|
19 | + %h3 Output | |
|
20 | + = link_to "Download",download_sol_problem_testcase_path(@problem,tc),class: 'btn btn-info btn-sm' | |
|
21 | + .row | |
|
22 | + .col-md-6 | |
|
23 | + %textarea{ rows: 25,readonly: true,style: "width:100%;resize=none;overflow-y: scroll;"}= tc.input | |
|
24 | + .col-md-6 | |
|
25 | + %textarea{ rows: 25,readonly: true,style: "width:100%;resize=none;overflow-y: scroll;"}= tc.sol |
@@ -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,7 | |||
|
1 | + require 'test_helper' | |
|
2 | + | |
|
3 | + class TestcasesControllerTest < ActionController::TestCase | |
|
4 | + setup do | |
|
5 | + @testcase = testcases(:one) | |
|
6 | + end | |
|
7 | + 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,30 +1,36 | |||
|
1 | 1 | source 'https://rubygems.org' |
|
2 | 2 | |
|
3 | + #rails | |
|
3 | 4 | gem 'rails', '~>4.2.0' |
|
4 | 5 | gem 'activerecord-session_store' |
|
5 | 6 | |
|
6 | - gem 'select2-rails' | |
|
7 | 7 | |
|
8 | 8 | # Bundle edge Rails instead: |
|
9 | 9 | # gem 'rails', :git => 'git://github.com/rails/rails.git' |
|
10 | 10 | |
|
11 | + #---------------- database --------------------- | |
|
12 | + #the database | |
|
11 | 13 | gem 'mysql2' |
|
14 | + #for testing | |
|
12 | 15 | gem 'sqlite3' |
|
16 | + #for dumping database into yaml | |
|
17 | + gem 'yaml_db' | |
|
13 | 18 | |
|
14 | 19 | # Gems used only for assets and not required |
|
15 | 20 | # in production environments by default. |
|
16 | 21 | gem 'sass-rails' |
|
17 | 22 | gem 'coffee-rails' |
|
18 | 23 | |
|
19 | 24 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes |
|
20 | 25 | # gem 'therubyracer', :platforms => :ruby |
|
21 | 26 | |
|
22 | 27 | gem 'uglifier' |
|
23 | 28 | |
|
24 | - | |
|
29 | + gem 'haml' | |
|
30 | + gem 'haml-rails' | |
|
25 | 31 | # gem 'prototype-rails' |
|
26 | 32 | |
|
27 | 33 | # To use ActiveModel has_secure_password |
|
28 | 34 | # gem 'bcrypt-ruby', '~> 3.0.0' |
|
29 | 35 | |
|
30 | 36 | # To use Jbuilder templates for JSON |
@@ -60,19 +66,23 | |||
|
60 | 66 | gem 'autoprefixer-rails' |
|
61 | 67 | |
|
62 | 68 | #bootstrap sortable |
|
63 | 69 | gem 'momentjs-rails' |
|
64 | 70 | gem 'rails_bootstrap_sortable' |
|
65 | 71 | |
|
72 | + #----------- user interface ----------------- | |
|
73 | + #select 2 | |
|
74 | + gem 'select2-rails' | |
|
66 | 75 | #ace editor |
|
67 | 76 | gem 'ace-rails-ap' |
|
77 | + #paginator | |
|
78 | + gem 'will_paginate', '~> 3.0.7' | |
|
68 | 79 | |
|
69 | - gem 'haml' | |
|
70 | - gem 'haml-rails' | |
|
71 | 80 | gem 'mail' |
|
72 | 81 | gem 'rdiscount' |
|
73 | - gem 'test-unit' | |
|
74 | - gem 'will_paginate', '~> 3.0.7' | |
|
75 | 82 | gem 'dynamic_form' |
|
76 | 83 | gem 'in_place_editing' |
|
77 | 84 | gem 'verification', :git => 'https://github.com/sikachu/verification.git' |
|
78 | 85 | |
|
86 | + | |
|
87 | + #---------------- testiing ----------------------- | |
|
88 | + gem 'minitest-reporters' |
@@ -48,12 +48,13 | |||
|
48 | 48 | activesupport (4.2.7.1) |
|
49 | 49 | i18n (~> 0.7) |
|
50 | 50 | json (~> 1.7, >= 1.7.7) |
|
51 | 51 | minitest (~> 5.1) |
|
52 | 52 | thread_safe (~> 0.3, >= 0.3.4) |
|
53 | 53 | tzinfo (~> 1.1) |
|
54 | + ansi (1.5.0) | |
|
54 | 55 | arel (6.0.4) |
|
55 | 56 | autoprefixer-rails (6.6.0) |
|
56 | 57 | execjs |
|
57 | 58 | best_in_place (3.0.3) |
|
58 | 59 | actionpack (>= 3.2) |
|
59 | 60 | railties (>= 3.2) |
@@ -108,19 +109,23 | |||
|
108 | 109 | mime-types (>= 1.16, < 4) |
|
109 | 110 | mime-types (3.1) |
|
110 | 111 | mime-types-data (~> 3.2015) |
|
111 | 112 | mime-types-data (3.2016.0521) |
|
112 | 113 | mini_portile2 (2.1.0) |
|
113 | 114 | minitest (5.10.1) |
|
115 | + minitest-reporters (1.1.13) | |
|
116 | + ansi | |
|
117 | + builder | |
|
118 | + minitest (>= 5.0) | |
|
119 | + ruby-progressbar | |
|
114 | 120 | momentjs-rails (2.15.1) |
|
115 | 121 | railties (>= 3.1) |
|
116 | 122 | multi_json (1.12.1) |
|
117 | 123 | mysql2 (0.4.5) |
|
118 | 124 | nokogiri (1.6.8.1) |
|
119 | 125 | mini_portile2 (~> 2.1.0) |
|
120 | - power_assert (0.4.1) | |
|
121 | 126 | rack (1.6.5) |
|
122 | 127 | rack-test (0.6.3) |
|
123 | 128 | rack (>= 1.0) |
|
124 | 129 | rails (4.2.7.1) |
|
125 | 130 | actionmailer (= 4.2.7.1) |
|
126 | 131 | actionpack (= 4.2.7.1) |
@@ -147,12 +152,13 | |||
|
147 | 152 | activesupport (= 4.2.7.1) |
|
148 | 153 | rake (>= 0.8.7) |
|
149 | 154 | thor (>= 0.18.1, < 2.0) |
|
150 | 155 | rake (12.0.0) |
|
151 | 156 | rdiscount (2.2.0.1) |
|
152 | 157 | rouge (2.0.7) |
|
158 | + ruby-progressbar (1.8.1) | |
|
153 | 159 | ruby_parser (3.8.3) |
|
154 | 160 | sexp_processor (~> 4.1) |
|
155 | 161 | sass (3.4.23) |
|
156 | 162 | sass-rails (5.0.6) |
|
157 | 163 | railties (>= 4.0.0, < 6) |
|
158 | 164 | sass (~> 3.1) |
@@ -167,22 +173,23 | |||
|
167 | 173 | rack (> 1, < 3) |
|
168 | 174 | sprockets-rails (3.2.0) |
|
169 | 175 | actionpack (>= 4.0) |
|
170 | 176 | activesupport (>= 4.0) |
|
171 | 177 | sprockets (>= 3.0.0) |
|
172 | 178 | sqlite3 (1.3.12) |
|
173 | - test-unit (3.2.3) | |
|
174 | - power_assert | |
|
175 | 179 | thor (0.19.4) |
|
176 | 180 | thread_safe (0.3.5) |
|
177 | 181 | tilt (2.0.5) |
|
178 | 182 | tzinfo (1.2.2) |
|
179 | 183 | thread_safe (~> 0.1) |
|
180 | 184 | uglifier (3.0.4) |
|
181 | 185 | execjs (>= 0.3.0, < 3) |
|
182 | 186 | will_paginate (3.0.12) |
|
187 | + yaml_db (0.4.2) | |
|
188 | + rails (>= 3.0, < 5.1) | |
|
189 | + rake (>= 0.8.7) | |
|
183 | 190 | |
|
184 | 191 | PLATFORMS |
|
185 | 192 | ruby |
|
186 | 193 | |
|
187 | 194 | DEPENDENCIES |
|
188 | 195 | ace-rails-ap |
@@ -200,22 +207,23 | |||
|
200 | 207 | jquery-countdown-rails |
|
201 | 208 | jquery-rails |
|
202 | 209 | jquery-tablesorter |
|
203 | 210 | jquery-timepicker-addon-rails |
|
204 | 211 | jquery-ui-rails |
|
205 | 212 | |
|
213 | + minitest-reporters | |
|
206 | 214 | momentjs-rails |
|
207 | 215 | mysql2 |
|
208 | 216 | rails (~> 4.2.0) |
|
209 | 217 | rails_bootstrap_sortable |
|
210 | 218 | rdiscount |
|
211 | 219 | rouge |
|
212 | 220 | sass-rails |
|
213 | 221 | select2-rails |
|
214 | 222 | sqlite3 |
|
215 | - test-unit | |
|
216 | 223 | uglifier |
|
217 | 224 | verification! |
|
218 | 225 | will_paginate (~> 3.0.7) |
|
226 | + yaml_db | |
|
219 | 227 | |
|
220 | 228 | BUNDLED WITH |
|
221 | 229 | 1.13.6 |
@@ -1,10 +1,10 | |||
|
1 | 1 | class ApplicationController < ActionController::Base |
|
2 | 2 | protect_from_forgery |
|
3 | 3 | |
|
4 |
- before_filter :current_user |
|
|
4 | + before_filter :current_user | |
|
5 | 5 | |
|
6 | 6 | SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode' |
|
7 | 7 | MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login' |
|
8 | 8 | |
|
9 | 9 | #report and redirect for unauthorized activities |
|
10 | 10 | def unauthorized_redirect |
@@ -34,12 +34,21 | |||
|
34 | 34 | unless user.roles.detect { |role| allowed_roles.member?(role.name) } |
|
35 | 35 | unauthorized_redirect |
|
36 | 36 | return false |
|
37 | 37 | end |
|
38 | 38 | end |
|
39 | 39 | |
|
40 | + def testcase_authorization | |
|
41 | + #admin always has privileged | |
|
42 | + if @current_user.admin? | |
|
43 | + return true | |
|
44 | + end | |
|
45 | + | |
|
46 | + unauthorized_redirect if GraderConfiguration["right.view_testcase"] | |
|
47 | + end | |
|
48 | + | |
|
40 | 49 | protected |
|
41 | 50 | |
|
42 | 51 | def authenticate |
|
43 | 52 | unless session[:user_id] |
|
44 | 53 | flash[:notice] = 'You need to login' |
|
45 | 54 | if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] |
@@ -1,9 +1,10 | |||
|
1 | 1 | class ProblemsController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
3 | + before_action :authenticate, :authorization | |
|
4 | + before_action :testcase_authorization, only: [:show_testcase] | |
|
4 | 5 | |
|
5 | 6 | in_place_edit_for :problem, :name |
|
6 | 7 | in_place_edit_for :problem, :full_name |
|
7 | 8 | in_place_edit_for :problem, :full_score |
|
8 | 9 | |
|
9 | 10 | def index |
@@ -218,12 +219,16 | |||
|
218 | 219 | if problem!=nil and contest!=nil |
|
219 | 220 | problem.contests.delete(contest) |
|
220 | 221 | end |
|
221 | 222 | redirect_to :action => 'manage' |
|
222 | 223 | end |
|
223 | 224 | |
|
225 | + def show_testcase | |
|
226 | + @problem = Problem.includes(:testcases).find(params[:id]) | |
|
227 | + end | |
|
228 | + | |
|
224 | 229 | ################################## |
|
225 | 230 | protected |
|
226 | 231 | |
|
227 | 232 | def allow_test_pair_import? |
|
228 | 233 | if defined? ALLOW_TEST_PAIR_IMPORT |
|
229 | 234 | return ALLOW_TEST_PAIR_IMPORT |
@@ -7,12 +7,14 | |||
|
7 | 7 | |
|
8 | 8 | SYSTEM_MODE_CONF_KEY = 'system.mode' |
|
9 | 9 | TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout' |
|
10 | 10 | MULTICONTESTS_KEY = 'system.multicontests' |
|
11 | 11 | CONTEST_TIME_LIMIT_KEY = 'contest.time_limit' |
|
12 | 12 | MULTIPLE_IP_LOGIN_KEY = 'right.multiple_ip_login' |
|
13 | + VIEW_TESTCASE = 'right.view_testcase' | |
|
14 | + SINGLE_USER_KEY = 'system.single_user_mode' | |
|
13 | 15 | |
|
14 | 16 | cattr_accessor :config_cache |
|
15 | 17 | cattr_accessor :task_grading_info_cache |
|
16 | 18 | cattr_accessor :contest_time_str |
|
17 | 19 | cattr_accessor :contest_time |
|
18 | 20 | |
@@ -67,12 +69,16 | |||
|
67 | 69 | end |
|
68 | 70 | |
|
69 | 71 | def self.show_grading_result |
|
70 | 72 | return (get(SYSTEM_MODE_CONF_KEY)=='analysis') |
|
71 | 73 | end |
|
72 | 74 | |
|
75 | + def self.show_testcase | |
|
76 | + return get(VIEW_TESTCASE) | |
|
77 | + end | |
|
78 | + | |
|
73 | 79 | def self.allow_test_request(user) |
|
74 | 80 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
75 | 81 | early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY) |
|
76 | 82 | if (mode=='contest') |
|
77 | 83 | return false if ((user.site!=nil) and |
|
78 | 84 | ((user.site.started!=true) or |
@@ -9,13 +9,13 | |||
|
9 | 9 | - if flash[:notice] |
|
10 | 10 | %hr/ |
|
11 | 11 | %b= flash[:notice] |
|
12 | 12 | %hr/ |
|
13 | 13 | |
|
14 | 14 | %div{ :style => "border: solid 1px gray; padding: 4px; background: #eeeeff;"} |
|
15 | - = form_tag :controller => 'login', :action => 'login' do | |
|
15 | + = form_tag login_login_path do | |
|
16 | 16 | %table |
|
17 | 17 | %tr |
|
18 | 18 | %td{:align => "right"} |
|
19 | 19 | ="#{t 'login_label'}:" |
|
20 | 20 | %td= text_field_tag 'login' |
|
21 | 21 | %tr |
@@ -21,7 +21,9 | |||
|
21 | 21 | - if GraderConfiguration.show_grading_result |
|
22 | 22 | = link_to '[detailed result]', :action => 'result', :id => submission.id |
|
23 | 23 | /= link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'} |
|
24 | 24 | = link_to "#{t 'main.cmp_msg'}", compiler_msg_submission_path(submission.id), {popup: true,remote: true,class: 'btn btn-xs btn-info'} |
|
25 | 25 | = link_to "#{t 'main.src_link'}",{:action => 'source', :id => submission.id}, class: 'btn btn-xs btn-info' |
|
26 | 26 | = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info' |
|
27 | + - if GraderConfiguration.show_testcase | |
|
28 | + = link_to "testcases", show_testcase_problem_path(problem_id), class: 'btn btn-xs btn-info' | |
|
27 | 29 |
@@ -47,6 +47,17 | |||
|
47 | 47 | = render :partial => 'announcement', :collection => @announcements |
|
48 | 48 | |
|
49 | 49 | %script{:type => 'text/javascript'} |
|
50 | 50 | = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';" |
|
51 | 51 | Announcement.registerRefreshEventTimer(); |
|
52 | 52 | |
|
53 | + .modal.fade#compiler{tabindex: -1,role: 'dialog'} | |
|
54 | + .modal-dialog.modal-lg{role:'document'} | |
|
55 | + .modal-content | |
|
56 | + .modal-header | |
|
57 | + %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}} | |
|
58 | + %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} × | |
|
59 | + %h4 Compiler message | |
|
60 | + .modal-body | |
|
61 | + %pre#compiler_msg | |
|
62 | + .modal-footer | |
|
63 | + %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close |
@@ -1,3 +1,4 | |||
|
1 | - :javascript | |
|
2 |
- $("#compiler_msg").html("#{j @submission |
|
|
3 | - | |
|
1 | + :plain | |
|
2 | + $("#compiler_msg").html("#{j @submission.compiler_message}"); | |
|
3 | + $("#compiler").modal(); | |
|
4 | + |
@@ -1,2 +1,2 | |||
|
1 | - :javascript | |
|
1 | + :plain | |
|
2 | 2 | $("#latest_status").html("#{j render({partial: 'submission_short', locals: {submission: @submission, problem_name: @problem.name}})}") |
@@ -1,11 +1,14 | |||
|
1 | 1 | CafeGrader::Application.routes.draw do |
|
2 | 2 | get "sources/direct_edit" |
|
3 | 3 | |
|
4 | 4 | root :to => 'main#login' |
|
5 | 5 | |
|
6 | + #logins | |
|
7 | + get 'login/login', to: 'login#login' | |
|
8 | + | |
|
6 | 9 | resources :contests |
|
7 | 10 | |
|
8 | 11 | resources :sites |
|
9 | 12 | |
|
10 | 13 | resources :announcements do |
|
11 | 14 | member do |
@@ -15,19 +18,27 | |||
|
15 | 18 | |
|
16 | 19 | resources :problems do |
|
17 | 20 | member do |
|
18 | 21 | get 'toggle' |
|
19 | 22 | get 'toggle_test' |
|
20 | 23 | get 'stat' |
|
24 | + get 'show_testcase' | |
|
21 | 25 | end |
|
22 | 26 | collection do |
|
23 | 27 | get 'turn_all_off' |
|
24 | 28 | get 'turn_all_on' |
|
25 | 29 | get 'import' |
|
26 | 30 | get 'manage' |
|
27 | 31 | end |
|
32 | + | |
|
33 | + resources :testcases, only: [] do | |
|
34 | + member do | |
|
35 | + get 'download_input' | |
|
36 | + get 'download_sol' | |
|
37 | + end | |
|
38 | + end | |
|
28 | 39 | end |
|
29 | 40 | |
|
30 | 41 | resources :grader_configuration, controller: 'configurations' |
|
31 | 42 | |
|
32 | 43 | resources :users do |
|
33 | 44 | member do |
@@ -11,270 +11,270 | |||
|
11 | 11 | # |
|
12 | 12 | # It's strongly recommended that you check this file into your version control system. |
|
13 | 13 | |
|
14 | 14 | ActiveRecord::Schema.define(version: 20161031063337) do |
|
15 | 15 | |
|
16 | 16 | create_table "announcements", force: :cascade do |t| |
|
17 | - t.string "author" | |
|
18 | - t.text "body" | |
|
17 | + t.string "author", limit: 255 | |
|
18 | + t.text "body", limit: 65535 | |
|
19 | 19 | t.boolean "published" |
|
20 | - t.datetime "created_at", null: false | |
|
21 | - t.datetime "updated_at", null: false | |
|
22 | - t.boolean "frontpage", default: false | |
|
23 | - t.boolean "contest_only", default: false | |
|
24 | - t.string "title" | |
|
25 | - t.string "notes" | |
|
20 | + t.datetime "created_at", null: false | |
|
21 | + t.datetime "updated_at", null: false | |
|
22 | + t.boolean "frontpage", default: false | |
|
23 | + t.boolean "contest_only", default: false | |
|
24 | + t.string "title", limit: 255 | |
|
25 | + t.string "notes", limit: 255 | |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | create_table "contests", force: :cascade do |t| |
|
29 | - t.string "title" | |
|
29 | + t.string "title", limit: 255 | |
|
30 | 30 | t.boolean "enabled" |
|
31 | - t.datetime "created_at", null: false | |
|
32 | - t.datetime "updated_at", null: false | |
|
33 | - t.string "name" | |
|
31 | + t.datetime "created_at", null: false | |
|
32 | + t.datetime "updated_at", null: false | |
|
33 | + t.string "name", limit: 255 | |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | create_table "contests_problems", id: false, force: :cascade do |t| |
|
37 | - t.integer "contest_id" | |
|
38 | - t.integer "problem_id" | |
|
37 | + t.integer "contest_id", limit: 4 | |
|
38 | + t.integer "problem_id", limit: 4 | |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | create_table "contests_users", id: false, force: :cascade do |t| |
|
42 | - t.integer "contest_id" | |
|
43 | - t.integer "user_id" | |
|
42 | + t.integer "contest_id", limit: 4 | |
|
43 | + t.integer "user_id", limit: 4 | |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | create_table "countries", force: :cascade do |t| |
|
47 | - t.string "name" | |
|
48 | - t.datetime "created_at", null: false | |
|
49 | - t.datetime "updated_at", null: false | |
|
47 | + t.string "name", limit: 255 | |
|
48 | + t.datetime "created_at", null: false | |
|
49 | + t.datetime "updated_at", null: false | |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | create_table "descriptions", force: :cascade do |t| |
|
53 | - t.text "body" | |
|
53 | + t.text "body", limit: 65535 | |
|
54 | 54 | t.boolean "markdowned" |
|
55 | - t.datetime "created_at", null: false | |
|
56 | - t.datetime "updated_at", null: false | |
|
55 | + t.datetime "created_at", null: false | |
|
56 | + t.datetime "updated_at", null: false | |
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | create_table "grader_configurations", force: :cascade do |t| |
|
60 | - t.string "key" | |
|
61 | - t.string "value_type" | |
|
62 | - t.string "value" | |
|
63 | - t.datetime "created_at", null: false | |
|
64 | - t.datetime "updated_at", null: false | |
|
65 | - t.text "description" | |
|
60 | + t.string "key", limit: 255 | |
|
61 | + t.string "value_type", limit: 255 | |
|
62 | + t.string "value", limit: 255 | |
|
63 | + t.datetime "created_at", null: false | |
|
64 | + t.datetime "updated_at", null: false | |
|
65 | + t.text "description", limit: 65535 | |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | create_table "grader_processes", force: :cascade do |t| |
|
69 | - t.string "host" | |
|
70 | - t.integer "pid" | |
|
71 | - t.string "mode" | |
|
69 | + t.string "host", limit: 255 | |
|
70 | + t.integer "pid", limit: 4 | |
|
71 | + t.string "mode", limit: 255 | |
|
72 | 72 | t.boolean "active" |
|
73 | - t.datetime "created_at", null: false | |
|
74 | - t.datetime "updated_at", null: false | |
|
75 | - t.integer "task_id" | |
|
76 | - t.string "task_type" | |
|
73 | + t.datetime "created_at", null: false | |
|
74 | + t.datetime "updated_at", null: false | |
|
75 | + t.integer "task_id", limit: 4 | |
|
76 | + t.string "task_type", limit: 255 | |
|
77 | 77 | t.boolean "terminated" |
|
78 | 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 | 82 | create_table "heart_beats", force: :cascade do |t| |
|
83 | - t.integer "user_id" | |
|
84 | - t.string "ip_address" | |
|
85 | - t.datetime "created_at", null: false | |
|
86 | - t.datetime "updated_at", null: false | |
|
87 | - t.string "status" | |
|
83 | + t.integer "user_id", limit: 4 | |
|
84 | + t.string "ip_address", limit: 255 | |
|
85 | + t.datetime "created_at", null: false | |
|
86 | + t.datetime "updated_at", null: false | |
|
87 | + t.string "status", limit: 255 | |
|
88 | 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 | 92 | create_table "languages", force: :cascade do |t| |
|
93 | 93 | t.string "name", limit: 10 |
|
94 | - t.string "pretty_name" | |
|
94 | + t.string "pretty_name", limit: 255 | |
|
95 | 95 | t.string "ext", limit: 10 |
|
96 | - t.string "common_ext" | |
|
96 | + t.string "common_ext", limit: 255 | |
|
97 | 97 | end |
|
98 | 98 | |
|
99 | 99 | create_table "logins", force: :cascade do |t| |
|
100 | - t.integer "user_id" | |
|
101 | - t.string "ip_address" | |
|
102 | - t.datetime "created_at", null: false | |
|
103 | - t.datetime "updated_at", null: false | |
|
100 | + t.integer "user_id", limit: 4 | |
|
101 | + t.string "ip_address", limit: 255 | |
|
102 | + t.datetime "created_at", null: false | |
|
103 | + t.datetime "updated_at", null: false | |
|
104 | 104 | end |
|
105 | 105 | |
|
106 | 106 | create_table "messages", force: :cascade do |t| |
|
107 | - t.integer "sender_id" | |
|
108 | - t.integer "receiver_id" | |
|
109 | - t.integer "replying_message_id" | |
|
110 | - t.text "body" | |
|
107 | + t.integer "sender_id", limit: 4 | |
|
108 | + t.integer "receiver_id", limit: 4 | |
|
109 | + t.integer "replying_message_id", limit: 4 | |
|
110 | + t.text "body", limit: 65535 | |
|
111 | 111 | t.boolean "replied" |
|
112 | - t.datetime "created_at", null: false | |
|
113 | - t.datetime "updated_at", null: false | |
|
112 | + t.datetime "created_at", null: false | |
|
113 | + t.datetime "updated_at", null: false | |
|
114 | 114 | end |
|
115 | 115 | |
|
116 | 116 | create_table "problems", force: :cascade do |t| |
|
117 | 117 | t.string "name", limit: 30 |
|
118 | - t.string "full_name" | |
|
119 | - t.integer "full_score" | |
|
118 | + t.string "full_name", limit: 255 | |
|
119 | + t.integer "full_score", limit: 4 | |
|
120 | 120 | t.date "date_added" |
|
121 | 121 | t.boolean "available" |
|
122 | - t.string "url" | |
|
123 | - t.integer "description_id" | |
|
122 | + t.string "url", limit: 255 | |
|
123 | + t.integer "description_id", limit: 4 | |
|
124 | 124 | t.boolean "test_allowed" |
|
125 | 125 | t.boolean "output_only" |
|
126 | - t.string "description_filename" | |
|
126 | + t.string "description_filename", limit: 255 | |
|
127 | 127 | end |
|
128 | 128 | |
|
129 | 129 | create_table "rights", force: :cascade do |t| |
|
130 | - t.string "name" | |
|
131 | - t.string "controller" | |
|
132 | - t.string "action" | |
|
130 | + t.string "name", limit: 255 | |
|
131 | + t.string "controller", limit: 255 | |
|
132 | + t.string "action", limit: 255 | |
|
133 | 133 | end |
|
134 | 134 | |
|
135 | 135 | create_table "rights_roles", id: false, force: :cascade do |t| |
|
136 | - t.integer "right_id" | |
|
137 | - t.integer "role_id" | |
|
136 | + t.integer "right_id", limit: 4 | |
|
137 | + t.integer "role_id", limit: 4 | |
|
138 | 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 | 142 | create_table "roles", force: :cascade do |t| |
|
143 | - t.string "name" | |
|
143 | + t.string "name", limit: 255 | |
|
144 | 144 | end |
|
145 | 145 | |
|
146 | 146 | create_table "roles_users", id: false, force: :cascade do |t| |
|
147 | - t.integer "role_id" | |
|
148 | - t.integer "user_id" | |
|
147 | + t.integer "role_id", limit: 4 | |
|
148 | + t.integer "user_id", limit: 4 | |
|
149 | 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 | 153 | create_table "sessions", force: :cascade do |t| |
|
154 | - t.string "session_id" | |
|
155 | - t.text "data" | |
|
154 | + t.string "session_id", limit: 255 | |
|
155 | + t.text "data", limit: 65535 | |
|
156 | 156 | t.datetime "updated_at" |
|
157 | 157 | end |
|
158 | 158 | |
|
159 | - add_index "sessions", ["session_id"], name: "index_sessions_on_session_id" | |
|
160 | - add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at" | |
|
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", using: :btree | |
|
161 | 161 | |
|
162 | 162 | create_table "sites", force: :cascade do |t| |
|
163 | - t.string "name" | |
|
163 | + t.string "name", limit: 255 | |
|
164 | 164 | t.boolean "started" |
|
165 | 165 | t.datetime "start_time" |
|
166 | - t.datetime "created_at", null: false | |
|
167 | - t.datetime "updated_at", null: false | |
|
168 | - t.integer "country_id" | |
|
169 | - t.string "password" | |
|
166 | + t.datetime "created_at", null: false | |
|
167 | + t.datetime "updated_at", null: false | |
|
168 | + t.integer "country_id", limit: 4 | |
|
169 | + t.string "password", limit: 255 | |
|
170 | 170 | end |
|
171 | 171 | |
|
172 | 172 | create_table "submission_view_logs", force: :cascade do |t| |
|
173 | - t.integer "user_id" | |
|
174 | - t.integer "submission_id" | |
|
175 | - t.datetime "created_at", null: false | |
|
176 | - t.datetime "updated_at", null: false | |
|
173 | + t.integer "user_id", limit: 4 | |
|
174 | + t.integer "submission_id", limit: 4 | |
|
175 | + t.datetime "created_at", null: false | |
|
176 | + t.datetime "updated_at", null: false | |
|
177 | 177 | end |
|
178 | 178 | |
|
179 | 179 | create_table "submissions", force: :cascade do |t| |
|
180 | - t.integer "user_id" | |
|
181 | - t.integer "problem_id" | |
|
182 | - t.integer "language_id" | |
|
183 | - t.text "source" | |
|
184 | - t.binary "binary" | |
|
180 | + t.integer "user_id", limit: 4 | |
|
181 | + t.integer "problem_id", limit: 4 | |
|
182 | + t.integer "language_id", limit: 4 | |
|
183 | + t.text "source", limit: 65535 | |
|
184 | + t.binary "binary", limit: 65535 | |
|
185 | 185 | t.datetime "submitted_at" |
|
186 | 186 | t.datetime "compiled_at" |
|
187 | - t.text "compiler_message" | |
|
187 | + t.text "compiler_message", limit: 65535 | |
|
188 | 188 | t.datetime "graded_at" |
|
189 | - t.integer "points" | |
|
190 | - t.text "grader_comment" | |
|
191 | - t.integer "number" | |
|
192 | - t.string "source_filename" | |
|
193 | - t.float "max_runtime" | |
|
194 | - t.integer "peak_memory" | |
|
195 | - t.integer "effective_code_length" | |
|
196 | - t.string "ip_address" | |
|
189 | + t.integer "points", limit: 4 | |
|
190 | + t.text "grader_comment", limit: 65535 | |
|
191 | + t.integer "number", limit: 4 | |
|
192 | + t.string "source_filename", limit: 255 | |
|
193 | + t.float "max_runtime", limit: 24 | |
|
194 | + t.integer "peak_memory", limit: 4 | |
|
195 | + t.integer "effective_code_length", limit: 4 | |
|
196 | + t.string "ip_address", limit: 255 | |
|
197 | 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 | |
|
200 | - add_index "submissions", ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id" | |
|
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", using: :btree | |
|
201 | 201 | |
|
202 | 202 | create_table "tasks", force: :cascade do |t| |
|
203 | - t.integer "submission_id" | |
|
203 | + t.integer "submission_id", limit: 4 | |
|
204 | 204 | t.datetime "created_at" |
|
205 | - t.integer "status" | |
|
205 | + t.integer "status", limit: 4 | |
|
206 | 206 | t.datetime "updated_at" |
|
207 | 207 | end |
|
208 | 208 | |
|
209 | 209 | create_table "test_pairs", force: :cascade do |t| |
|
210 | - t.integer "problem_id" | |
|
210 | + t.integer "problem_id", limit: 4 | |
|
211 | 211 | t.text "input", limit: 16777215 |
|
212 | 212 | t.text "solution", limit: 16777215 |
|
213 | 213 | t.datetime "created_at", null: false |
|
214 | 214 | t.datetime "updated_at", null: false |
|
215 | 215 | end |
|
216 | 216 | |
|
217 | 217 | create_table "test_requests", force: :cascade do |t| |
|
218 | - t.integer "user_id" | |
|
219 | - t.integer "problem_id" | |
|
220 | - t.integer "submission_id" | |
|
221 | - t.string "input_file_name" | |
|
222 | - t.string "output_file_name" | |
|
223 | - t.string "running_stat" | |
|
224 | - t.integer "status" | |
|
225 | - t.datetime "updated_at", null: false | |
|
218 | + t.integer "user_id", limit: 4 | |
|
219 | + t.integer "problem_id", limit: 4 | |
|
220 | + t.integer "submission_id", limit: 4 | |
|
221 | + t.string "input_file_name", limit: 255 | |
|
222 | + t.string "output_file_name", limit: 255 | |
|
223 | + t.string "running_stat", limit: 255 | |
|
224 | + t.integer "status", limit: 4 | |
|
225 | + t.datetime "updated_at", null: false | |
|
226 | 226 | t.datetime "submitted_at" |
|
227 | 227 | t.datetime "compiled_at" |
|
228 | - t.text "compiler_message" | |
|
228 | + t.text "compiler_message", limit: 65535 | |
|
229 | 229 | t.datetime "graded_at" |
|
230 | - t.string "grader_comment" | |
|
231 | - t.datetime "created_at", null: false | |
|
232 | - t.float "running_time" | |
|
233 | - t.string "exit_status" | |
|
234 | - t.integer "memory_usage" | |
|
230 | + t.string "grader_comment", limit: 255 | |
|
231 | + t.datetime "created_at", null: false | |
|
232 | + t.float "running_time", limit: 24 | |
|
233 | + t.string "exit_status", limit: 255 | |
|
234 | + t.integer "memory_usage", limit: 4 | |
|
235 | 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 | 239 | create_table "testcases", force: :cascade do |t| |
|
240 | - t.integer "problem_id" | |
|
241 | - t.integer "num" | |
|
242 | - t.integer "group" | |
|
243 | - t.integer "score" | |
|
244 | - t.text "input" | |
|
245 | - t.text "sol" | |
|
246 |
- t.datetime "created_at" |
|
|
247 |
- t.datetime "updated_at" |
|
|
240 | + t.integer "problem_id", limit: 4 | |
|
241 | + t.integer "num", limit: 4 | |
|
242 | + t.integer "group", limit: 4 | |
|
243 | + t.integer "score", limit: 4 | |
|
244 | + t.text "input", limit: 65535 | |
|
245 | + t.text "sol", limit: 65535 | |
|
246 | + t.datetime "created_at" | |
|
247 | + t.datetime "updated_at" | |
|
248 | 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 | 252 | create_table "user_contest_stats", force: :cascade do |t| |
|
253 | - t.integer "user_id" | |
|
253 | + t.integer "user_id", limit: 4 | |
|
254 | 254 | t.datetime "started_at" |
|
255 | - t.datetime "created_at", null: false | |
|
256 | - t.datetime "updated_at", null: false | |
|
255 | + t.datetime "created_at", null: false | |
|
256 | + t.datetime "updated_at", null: false | |
|
257 | 257 | t.boolean "forced_logout" |
|
258 | 258 | end |
|
259 | 259 | |
|
260 | 260 | create_table "users", force: :cascade do |t| |
|
261 | 261 | t.string "login", limit: 50 |
|
262 | - t.string "full_name" | |
|
263 | - t.string "hashed_password" | |
|
262 | + t.string "full_name", limit: 255 | |
|
263 | + t.string "hashed_password", limit: 255 | |
|
264 | 264 | t.string "salt", limit: 5 |
|
265 | - t.string "alias" | |
|
266 | - t.string "email" | |
|
267 | - t.integer "site_id" | |
|
268 | - t.integer "country_id" | |
|
269 | - t.boolean "activated", default: false | |
|
265 | + t.string "alias", limit: 255 | |
|
266 | + t.string "email", limit: 255 | |
|
267 | + t.integer "site_id", limit: 4 | |
|
268 | + t.integer "country_id", limit: 4 | |
|
269 | + t.boolean "activated", default: false | |
|
270 | 270 | t.datetime "created_at" |
|
271 | 271 | t.datetime "updated_at" |
|
272 | - t.boolean "enabled", default: true | |
|
273 | - t.string "remark" | |
|
274 | - t.string "last_ip" | |
|
275 | - t.string "section" | |
|
272 | + t.boolean "enabled", default: true | |
|
273 | + t.string "remark", limit: 255 | |
|
274 | + t.string "last_ip", limit: 255 | |
|
275 | + t.string "section", limit: 255 | |
|
276 | 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 | 280 | end |
@@ -86,12 +86,18 | |||
|
86 | 86 | :key => 'right.heartbeat_response', |
|
87 | 87 | :value_type => 'string', |
|
88 | 88 | :default_value => 'OK', |
|
89 | 89 | :description => 'Heart beat response text' |
|
90 | 90 | }, |
|
91 | 91 | |
|
92 | + { | |
|
93 | + :key => 'right.view_testcase', | |
|
94 | + :value_type => 'boolean', | |
|
95 | + :default_value => 'false', | |
|
96 | + :description => 'When true, any user can view/download test data' | |
|
97 | + }, | |
|
92 | 98 | # If Configuration['system.online_registration'] is true, the |
|
93 | 99 | # system allows online registration, and will use these |
|
94 | 100 | # information for sending confirmation emails. |
|
95 | 101 | { |
|
96 | 102 | :key => 'system.online_registration.smtp', |
|
97 | 103 | :value_type => 'string', |
@@ -46,13 +46,28 | |||
|
46 | 46 | cmd = "#{script_name} #{problem_name} #{problem_dir} #{checker_name}" + |
|
47 | 47 | " -t #{time_limit} -m #{memory_limit}" |
|
48 | 48 | |
|
49 | 49 | output = `#{cmd}` |
|
50 | 50 | |
|
51 | 51 | Dir.chdir(cur_dir) |
|
52 | - | |
|
52 | + | |
|
53 | 53 | return "import CMD: #{cmd}\n" + output |
|
54 | 54 | end |
|
55 | 55 | return '' |
|
56 | 56 | end |
|
57 | 57 | |
|
58 | + def self.call_import_testcase(problem_name) | |
|
59 | + if GraderScript.grader_control_enabled? | |
|
60 | + cur_dir = `pwd`.chomp | |
|
61 | + Dir.chdir(GRADER_ROOT_DIR) | |
|
62 | + | |
|
63 | + script_name = File.join(GRADER_ROOT_DIR, "scripts/load_testcase") | |
|
64 | + cmd = "#{script_name} #{problem_name}" | |
|
65 | + | |
|
66 | + output = `#{cmd}` | |
|
67 | + | |
|
68 | + Dir.chdir(cur_dir) | |
|
69 | + return "Testcase import result:\n" + output | |
|
70 | + end | |
|
71 | + end | |
|
72 | + | |
|
58 | 73 | end |
@@ -35,12 +35,15 | |||
|
35 | 35 | end |
|
36 | 36 | |
|
37 | 37 | @log_msg << import_problem_description(dirname) |
|
38 | 38 | @log_msg << import_problem_pdf(dirname) |
|
39 | 39 | @log_msg << import_full_score(dirname) |
|
40 | 40 | |
|
41 | + #import test data | |
|
42 | + @log_msg << GraderScript.call_import_testcase(@problem.name) | |
|
43 | + | |
|
41 | 44 | return true |
|
42 | 45 | end |
|
43 | 46 | |
|
44 | 47 | protected |
|
45 | 48 | |
|
46 | 49 | def self.long_ext(filename) |
@@ -1,5 +1,36 | |||
|
1 | - # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | |
|
2 | - one: | |
|
3 | - id: 1 | |
|
4 | - two: | |
|
5 | - id: 2 | |
|
1 | + Language_1: | |
|
2 | + name: c | |
|
3 | + pretty_name: C | |
|
4 | + ext: c | |
|
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 | + |
@@ -10,16 +10,16 | |||
|
10 | 10 | login: john |
|
11 | 11 | full_name: john |
|
12 | 12 | hashed_password: <%= User.encrypt("hello",salt) %> |
|
13 | 13 | salt: <%= salt %> |
|
14 | 14 | activated: true |
|
15 | 15 | |
|
16 | - mary: | |
|
17 |
- login: |
|
|
18 |
- full_name: |
|
|
19 |
- hashed_password: <%= User.encrypt(" |
|
|
16 | + admin: | |
|
17 | + login: admin | |
|
18 | + full_name: admin | |
|
19 | + hashed_password: <%= User.encrypt("admin",salt) %> | |
|
20 | 20 | salt: <%= salt %> |
|
21 | 21 | roles: admin |
|
22 | 22 | activated: true |
|
23 | 23 | |
|
24 | 24 | james: |
|
25 | 25 | login: james |
@@ -2,12 +2,39 | |||
|
2 | 2 | |
|
3 | 3 | class LoginTest < ActionDispatch::IntegrationTest |
|
4 | 4 | # test "the truth" do |
|
5 | 5 | # assert true |
|
6 | 6 | # end |
|
7 | 7 | |
|
8 | - test "login with valid information" do | |
|
8 | + test "login with invalid information" do | |
|
9 | + get root_path | |
|
10 | + assert_response :success | |
|
11 | + post login_login_path, login: "root", password: "hahaha" | |
|
12 | + assert_redirected_to root_path | |
|
13 | + end | |
|
14 | + | |
|
15 | + test "normal user login" do | |
|
9 | 16 | get root_path |
|
10 | 17 | assert_response :success |
|
18 | + post login_login_path, {login: "john", password: "hello" } | |
|
19 | + assert_redirected_to main_list_path | |
|
20 | + end | |
|
11 | 21 | |
|
22 | + test "normal user login in single_user mode" do | |
|
23 | + GraderConfiguration.find_by(key: GraderConfiguration::SINGLE_USER_KEY).update_attributes(value: 'true') | |
|
24 | + GraderConfiguration.reload | |
|
25 | + get root_path | |
|
26 | + assert_response :success | |
|
27 | + post login_login_path, {login: "john", password: "hello" } | |
|
28 | + follow_redirect! | |
|
29 | + assert_redirected_to root_path | |
|
30 | + end | |
|
31 | + | |
|
32 | + test "root login in in single_user mode" do | |
|
33 | + GraderConfiguration.find_by(key: GraderConfiguration::SINGLE_USER_KEY).update_attributes(value: 'true') | |
|
34 | + GraderConfiguration.reload | |
|
35 | + get root_path | |
|
36 | + assert_response :success | |
|
37 | + post login_login_path, {login: "admin", password: "admin" } | |
|
38 | + assert_redirected_to main_list_path | |
|
12 | 39 | end |
|
13 | 40 | end |
@@ -1,10 +1,14 | |||
|
1 | 1 | ENV["RAILS_ENV"] = "test" |
|
2 | 2 | require File.expand_path('../../config/environment', __FILE__) |
|
3 | 3 | require 'rails/test_help' |
|
4 | 4 | |
|
5 | + #reporter | |
|
6 | + require "minitest/reporters" | |
|
7 | + Minitest::Reporters.use! | |
|
8 | + | |
|
5 | 9 | class ActiveSupport::TestCase |
|
6 | 10 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. |
|
7 | 11 | # |
|
8 | 12 | # Note: You'll currently still have to declare fixtures explicitly in integration tests |
|
9 | 13 | # -- they do not yet inherit this setting |
|
10 | 14 | fixtures :all |
You need to be logged in to leave comments.
Login now