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

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,2
1 + module TestcasesHelper
2 + 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,15 +1,20
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.
@@ -21,7 +26,8
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
@@ -63,16 +69,20
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'
@@ -51,6 +51,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
@@ -111,13 +112,17
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 - power_assert (0.4.1)
121 rack (1.6.5)
126 rack (1.6.5)
122 rack-test (0.6.3)
127 rack-test (0.6.3)
123 rack (>= 1.0)
128 rack (>= 1.0)
@@ -150,6 +155,7
150 rake (12.0.0)
155 rake (12.0.0)
151 rdiscount (2.2.0.1)
156 rdiscount (2.2.0.1)
152 rouge (2.0.7)
157 rouge (2.0.7)
158 + ruby-progressbar (1.8.1)
153 ruby_parser (3.8.3)
159 ruby_parser (3.8.3)
154 sexp_processor (~> 4.1)
160 sexp_processor (~> 4.1)
155 sass (3.4.23)
161 sass (3.4.23)
@@ -170,8 +176,6
170 activesupport (>= 4.0)
176 activesupport (>= 4.0)
171 sprockets (>= 3.0.0)
177 sprockets (>= 3.0.0)
172 sqlite3 (1.3.12)
178 sqlite3 (1.3.12)
173 - test-unit (3.2.3)
174 - power_assert
175 thor (0.19.4)
179 thor (0.19.4)
176 thread_safe (0.3.5)
180 thread_safe (0.3.5)
177 tilt (2.0.5)
181 tilt (2.0.5)
@@ -180,6 +184,9
180 uglifier (3.0.4)
184 uglifier (3.0.4)
181 execjs (>= 0.3.0, < 3)
185 execjs (>= 0.3.0, < 3)
182 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)
183
190
184 PLATFORMS
191 PLATFORMS
185 ruby
192 ruby
@@ -203,6 +210,7
203 jquery-timepicker-addon-rails
210 jquery-timepicker-addon-rails
204 jquery-ui-rails
211 jquery-ui-rails
205 mail
212 mail
213 + minitest-reporters
206 momentjs-rails
214 momentjs-rails
207 mysql2
215 mysql2
208 rails (~> 4.2.0)
216 rails (~> 4.2.0)
@@ -212,10 +220,10
212 sass-rails
220 sass-rails
213 select2-rails
221 select2-rails
214 sqlite3
222 sqlite3
215 - test-unit
216 uglifier
223 uglifier
217 verification!
224 verification!
218 will_paginate (~> 3.0.7)
225 will_paginate (~> 3.0.7)
226 + yaml_db
219
227
220 BUNDLED WITH
228 BUNDLED WITH
221 1.13.6
229 1.13.6
@@ -1,7 +1,7
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'
@@ -37,6 +37,15
37 end
37 end
38 end
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 protected
49 protected
41
50
42 def authenticate
51 def authenticate
@@ -1,6 +1,7
1 class ProblemsController < ApplicationController
1 class ProblemsController < ApplicationController
2
2
3 - before_filter :authenticate, :authorization
3 + before_action :authenticate, :authorization
4 + before_action :testcase_authorization, only: [:show_testcase]
4
5
5 in_place_edit_for :problem, :name
6 in_place_edit_for :problem, :name
6 in_place_edit_for :problem, :full_name
7 in_place_edit_for :problem, :full_name
@@ -221,6 +222,10
221 redirect_to :action => 'manage'
222 redirect_to :action => 'manage'
222 end
223 end
223
224
225 + def show_testcase
226 + @problem = Problem.includes(:testcases).find(params[:id])
227 + end
228 +
224 ##################################
229 ##################################
225 protected
230 protected
226
231
@@ -10,6 +10,8
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'
14 + SINGLE_USER_KEY = 'system.single_user_mode'
13
15
14 cattr_accessor :config_cache
16 cattr_accessor :config_cache
15 cattr_accessor :task_grading_info_cache
17 cattr_accessor :task_grading_info_cache
@@ -70,6 +72,10
70 return (get(SYSTEM_MODE_CONF_KEY)=='analysis')
72 return (get(SYSTEM_MODE_CONF_KEY)=='analysis')
71 end
73 end
72
74
75 + def self.show_testcase
76 + return get(VIEW_TESTCASE)
77 + end
78 +
73 def self.allow_test_request(user)
79 def self.allow_test_request(user)
74 mode = get(SYSTEM_MODE_CONF_KEY)
80 mode = get(SYSTEM_MODE_CONF_KEY)
75 early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY)
81 early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY)
@@ -12,7 +12,7
12 %hr/
12 %hr/
13
13
14 %div{ :style => "border: solid 1px gray; padding: 4px; background: #eeeeff;"}
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 %table
16 %table
17 %tr
17 %tr
18 %td{:align => "right"}
18 %td{:align => "right"}
@@ -24,4 +24,6
24 = link_to "#{t 'main.cmp_msg'}", compiler_msg_submission_path(submission.id), {popup: true,remote: true,class: 'btn btn-xs btn-info'}
24 = link_to "#{t 'main.cmp_msg'}", compiler_msg_submission_path(submission.id), {popup: true,remote: true,class: 'btn btn-xs btn-info'}
25 = link_to "#{t 'main.src_link'}",{:action => 'source', :id => submission.id}, class: 'btn btn-xs btn-info'
25 = link_to "#{t 'main.src_link'}",{:action => 'source', :id => submission.id}, class: 'btn btn-xs btn-info'
26 = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info'
26 = 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
@@ -50,3 +50,14
50 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
50 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
51 Announcement.registerRefreshEventTimer();
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'}} &times;
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
1 + :plain
2 - $("#compiler_msg").html("#{j @submissionhcompiler_msg}")
2 + $("#compiler_msg").html("#{j @submission.compiler_message}");
3 -
3 + $("#compiler").modal();
4 +
@@ -1,2 +1,2
1 - :javascript
1 + :plain
2 $("#latest_status").html("#{j render({partial: 'submission_short', locals: {submission: @submission, problem_name: @problem.name}})}")
2 $("#latest_status").html("#{j render({partial: 'submission_short', locals: {submission: @submission, problem_name: @problem.name}})}")
@@ -3,6 +3,9
3
3
4 root :to => 'main#login'
4 root :to => 'main#login'
5
5
6 + #logins
7 + get 'login/login', to: 'login#login'
8 +
6 resources :contests
9 resources :contests
7
10
8 resources :sites
11 resources :sites
@@ -18,6 +21,7
18 get 'toggle'
21 get 'toggle'
19 get 'toggle_test'
22 get 'toggle_test'
20 get 'stat'
23 get 'stat'
24 + get 'show_testcase'
21 end
25 end
22 collection do
26 collection do
23 get 'turn_all_off'
27 get 'turn_all_off'
@@ -25,6 +29,13
25 get 'import'
29 get 'import'
26 get 'manage'
30 get 'manage'
27 end
31 end
32 +
33 + resources :testcases, only: [] do
34 + member do
35 + get 'download_input'
36 + get 'download_sol'
37 + end
38 + end
28 end
39 end
29
40
30 resources :grader_configuration, controller: 'configurations'
41 resources :grader_configuration, controller: 'configurations'
@@ -14,200 +14,200
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
@@ -215,66 +215,66
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
@@ -89,6 +89,12
89 :description => 'Heart beat response text'
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 # If Configuration['system.online_registration'] is true, the
98 # If Configuration['system.online_registration'] is true, the
93 # system allows online registration, and will use these
99 # system allows online registration, and will use these
94 # information for sending confirmation emails.
100 # information for sending confirmation emails.
@@ -49,10 +49,25
49 output = `#{cmd}`
49 output = `#{cmd}`
50
50
51 Dir.chdir(cur_dir)
51 Dir.chdir(cur_dir)
52 -
52 +
53 return "import CMD: #{cmd}\n" + output
53 return "import CMD: #{cmd}\n" + output
54 end
54 end
55 return ''
55 return ''
56 end
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 end
73 end
@@ -38,6 +38,9
38 @log_msg << import_problem_pdf(dirname)
38 @log_msg << import_problem_pdf(dirname)
39 @log_msg << import_full_score(dirname)
39 @log_msg << import_full_score(dirname)
40
40
41 + #import test data
42 + @log_msg << GraderScript.call_import_testcase(@problem.name)
43 +
41 return true
44 return true
42 end
45 end
43
46
@@ -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 +
@@ -13,10 +13,10
13 salt: <%= salt %>
13 salt: <%= salt %>
14 activated: true
14 activated: true
15
15
16 - mary:
16 + admin:
17 - login: mary
17 + login: admin
18 - full_name: mary
18 + full_name: admin
19 - hashed_password: <%= User.encrypt("goodbye",salt) %>
19 + hashed_password: <%= User.encrypt("admin",salt) %>
20 salt: <%= salt %>
20 salt: <%= salt %>
21 roles: admin
21 roles: admin
22 activated: true
22 activated: true
@@ -5,9 +5,36
5 # assert true
5 # assert true
6 # end
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 get root_path
16 get root_path
10 assert_response :success
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 end
39 end
13 end
40 end
@@ -2,6 +2,10
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 #
You need to be logged in to leave comments. Login now