Description:
merge with algo-bm
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r429:82e5ff05bd49 - - 18 files changed: 310 inserted, 30 deleted
@@ -0,0 +1,8 | |||||
|
|
1 | + %h2 Paid in Full | ||
|
|
2 | + User with highest number of problem solved | ||
|
|
3 | + | ||
|
|
4 | + %h2 Polymaths | ||
|
|
5 | + User with highest number of problems each solved by more than 1 languages. | ||
|
|
6 | + | ||
|
|
7 | + %h2 Icebreakers | ||
|
|
8 | + If you solve the problem before 95% of your friends, you are an icebreaker. |
@@ -0,0 +1,62 | |||||
|
|
1 | + :css | ||
|
|
2 | + .hof_user { color: orangered; font-style: italic; } | ||
|
|
3 | + .hof_language { color: green; font-style: italic; } | ||
|
|
4 | + .hof_value { color: deeppink;font-style: italic; } | ||
|
|
5 | + | ||
|
|
6 | + %h2 Overall | ||
|
|
7 | + | ||
|
|
8 | + - if @best | ||
|
|
9 | + %b Best Runtime: | ||
|
|
10 | + by <span class="hof_user">#{@best[:runtime][:user]}</span> using <span class="hof_language">#{@best[:runtime][:lang]}</span> with <span class="hof_value">#{@best[:runtime][:value] * 1000} milliseconds</span> at submission | ||
|
|
11 | + = link_to("#" + @best[:runtime][:sub_id].to_s, controller: 'graders', action: 'submission', id:@best[:runtime][:sub_id]) | ||
|
|
12 | + %br/ | ||
|
|
13 | + | ||
|
|
14 | + %b Best Memory Usage: | ||
|
|
15 | + by <span class="hof_user">#{@best[:memory][:user]}</span> using <span class="hof_language">#{@best[:memory][:lang]}</span> with <span class="hof_value">#{@best[:memory][:value]} kbytes </span> at submission | ||
|
|
16 | + = link_to("#" + @best[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id:@best[:memory][:sub_id]) | ||
|
|
17 | + %br/ | ||
|
|
18 | + | ||
|
|
19 | + %b Shortest Code: | ||
|
|
20 | + by <span class="hof_user">#{@best[:length][:user]}</span> using <span class="hof_language">#{@best[:length][:lang]}</span> with <span class="hof_value">#{@best[:length][:value]} bytes</span> at submission | ||
|
|
21 | + = link_to("#" + @best[:length][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:length][:sub_id]) | ||
|
|
22 | + %br/ | ||
|
|
23 | + | ||
|
|
24 | + %b First solver: | ||
|
|
25 | + <span class="hof_user">#{@best[:first][:user]}</span> is the first solver using <span class="hof_language">#{@best[:first][:lang]}</span> on <span class="hof_value">#{@best[:first][:value]}</span> at submission | ||
|
|
26 | + = link_to("#" + @best[:first][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:first][:sub_id]) | ||
|
|
27 | + %br/ | ||
|
|
28 | + | ||
|
|
29 | + | ||
|
|
30 | + %p | ||
|
|
31 | + This counts only for submission with 100% score <br/> | ||
|
|
32 | + Right now, java is excluded from memory usage competition. (Because it always uses 2GB memory...) | ||
|
|
33 | + | ||
|
|
34 | + %h2 By language | ||
|
|
35 | + | ||
|
|
36 | + %table.info | ||
|
|
37 | + %thead | ||
|
|
38 | + %tr.info-head | ||
|
|
39 | + %th Language | ||
|
|
40 | + %th Best runtime (ms) | ||
|
|
41 | + %th Best memory (kbytes) | ||
|
|
42 | + %th Shortest Code (bytes) | ||
|
|
43 | + %th First solver | ||
|
|
44 | + %tbody | ||
|
|
45 | + - @by_lang.each do |lang,value| | ||
|
|
46 | + %tr{class: cycle('info-even','info-odd')} | ||
|
|
47 | + %td= lang | ||
|
|
48 | + %td | ||
|
|
49 | + = "#{value[:runtime][:user]} (#{(value[:runtime][:value] * 1000).to_i} @" | ||
|
|
50 | + = "#{link_to("#" + value[:runtime][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:runtime][:sub_id])} )".html_safe | ||
|
|
51 | + %td | ||
|
|
52 | + = "#{value[:memory][:user]} (#{value[:memory][:value]} @" | ||
|
|
53 | + = "#{link_to("#" + value[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:memory][:sub_id])} )".html_safe | ||
|
|
54 | + %td | ||
|
|
55 | + = "#{value[:length][:user]} (#{value[:length][:value]} @" | ||
|
|
56 | + = "#{link_to("#" + value[:length][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:length][:sub_id])} )".html_safe | ||
|
|
57 | + %td | ||
|
|
58 | + = "#{value[:first][:user]} (#{value[:first][:value]} @" | ||
|
|
59 | + = "#{link_to("#" + value[:first][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:first][:sub_id])} )".html_safe | ||
|
|
60 | + | ||
|
|
61 | + - else | ||
|
|
62 | + %h3 No submissions |
@@ -0,0 +1,22 | |||||
|
|
1 | + | ||
|
|
2 | + /- if params[:id] | ||
|
|
3 | + / %h1 Tasks Hall of Fame | ||
|
|
4 | + / = link_to('[back to All-Time Hall of Fame]', action: 'problem_hof', id: nil ) | ||
|
|
5 | + /- else | ||
|
|
6 | + / %h1 All-Time Hall of Fame | ||
|
|
7 | + | ||
|
|
8 | + | ||
|
|
9 | + %h1 Tasks Hall of Fame | ||
|
|
10 | + .task-menu | ||
|
|
11 | + Tasks | ||
|
|
12 | + %br/ | ||
|
|
13 | + - @problems.each do |prob| | ||
|
|
14 | + = link_to( "[#{prob.name}]", {id: prob.id}) | ||
|
|
15 | + | ||
|
|
16 | + - unless params[:id] | ||
|
|
17 | + /=render partial: 'all_time_hof' | ||
|
|
18 | + Please select a problem. | ||
|
|
19 | + - else | ||
|
|
20 | + =render partial: 'task_hof' | ||
|
|
21 | + | ||
|
|
22 | + |
@@ -0,0 +1,7 | |||||
|
|
1 | + class AddMoreDetailToSubmission < ActiveRecord::Migration | ||
|
|
2 | + def change | ||
|
|
3 | + add_column :submissions, :max_runtime, :float | ||
|
|
4 | + add_column :submissions, :peak_memory, :integer | ||
|
|
5 | + add_column :submissions, :effective_code_length, :integer | ||
|
|
6 | + end | ||
|
|
7 | + end |
@@ -32,24 +32,26 | |||||
|
32 |
|
32 | ||
|
33 | # Deploy with Capistrano |
|
33 | # Deploy with Capistrano |
|
34 | # gem 'capistrano' |
|
34 | # gem 'capistrano' |
|
35 |
|
35 | ||
|
36 | # To use debugger |
|
36 | # To use debugger |
|
37 | # gem 'debugger' |
|
37 | # gem 'debugger' |
|
38 | # |
|
38 | # |
|
39 |
|
39 | ||
|
40 | gem 'jquery-rails' |
|
40 | gem 'jquery-rails' |
|
41 | gem 'jquery-ui-sass-rails' |
|
41 | gem 'jquery-ui-sass-rails' |
|
42 | gem 'jquery-timepicker-addon-rails' |
|
42 | gem 'jquery-timepicker-addon-rails' |
|
43 |
|
43 | ||
|
|
44 | + #syntax highlighter | ||
|
|
45 | + gem 'rouge' | ||
|
44 |
|
46 | ||
|
45 | gem "haml" |
|
47 | gem "haml" |
|
46 | gem "mail" |
|
48 | gem "mail" |
|
47 | gem "rdiscount" |
|
49 | gem "rdiscount" |
|
48 | gem "test-unit" |
|
50 | gem "test-unit" |
|
49 | gem 'will_paginate', '~> 3.0.0' |
|
51 | gem 'will_paginate', '~> 3.0.0' |
|
50 | gem 'dynamic_form' |
|
52 | gem 'dynamic_form' |
|
51 | gem 'in_place_editing' |
|
53 | gem 'in_place_editing' |
|
52 | gem 'verification', :git => 'git://github.com/sikachu/verification.git' |
|
54 | gem 'verification', :git => 'git://github.com/sikachu/verification.git' |
|
53 |
|
55 | ||
|
54 | group :test, :development do |
|
56 | group :test, :development do |
|
55 | gem "rspec-rails", "~> 2.0" |
|
57 | gem "rspec-rails", "~> 2.0" |
@@ -95,24 +95,25 | |||||
|
95 | railties (= 3.2.19) |
|
95 | railties (= 3.2.19) |
|
96 | railties (3.2.19) |
|
96 | railties (3.2.19) |
|
97 | actionpack (= 3.2.19) |
|
97 | actionpack (= 3.2.19) |
|
98 | activesupport (= 3.2.19) |
|
98 | activesupport (= 3.2.19) |
|
99 | rack-ssl (~> 1.3.2) |
|
99 | rack-ssl (~> 1.3.2) |
|
100 | rake (>= 0.8.7) |
|
100 | rake (>= 0.8.7) |
|
101 | rdoc (~> 3.4) |
|
101 | rdoc (~> 3.4) |
|
102 | thor (>= 0.14.6, < 2.0) |
|
102 | thor (>= 0.14.6, < 2.0) |
|
103 | rake (10.3.2) |
|
103 | rake (10.3.2) |
|
104 | rdiscount (2.1.7.1) |
|
104 | rdiscount (2.1.7.1) |
|
105 | rdoc (3.12.2) |
|
105 | rdoc (3.12.2) |
|
106 | json (~> 1.4) |
|
106 | json (~> 1.4) |
|
|
107 | + rouge (1.6.2) | ||
|
107 | rspec-collection_matchers (1.0.0) |
|
108 | rspec-collection_matchers (1.0.0) |
|
108 | rspec-expectations (>= 2.99.0.beta1) |
|
109 | rspec-expectations (>= 2.99.0.beta1) |
|
109 | rspec-core (2.99.2) |
|
110 | rspec-core (2.99.2) |
|
110 | rspec-expectations (2.99.2) |
|
111 | rspec-expectations (2.99.2) |
|
111 | diff-lcs (>= 1.1.3, < 2.0) |
|
112 | diff-lcs (>= 1.1.3, < 2.0) |
|
112 | rspec-mocks (2.99.2) |
|
113 | rspec-mocks (2.99.2) |
|
113 | rspec-rails (2.99.0) |
|
114 | rspec-rails (2.99.0) |
|
114 | actionpack (>= 3.0) |
|
115 | actionpack (>= 3.0) |
|
115 | activemodel (>= 3.0) |
|
116 | activemodel (>= 3.0) |
|
116 | activesupport (>= 3.0) |
|
117 | activesupport (>= 3.0) |
|
117 | railties (>= 3.0) |
|
118 | railties (>= 3.0) |
|
118 | rspec-collection_matchers |
|
119 | rspec-collection_matchers |
@@ -149,18 +150,19 | |||||
|
149 | coffee-rails (~> 3.2.1) |
|
150 | coffee-rails (~> 3.2.1) |
|
150 | dynamic_form |
|
151 | dynamic_form |
|
151 | haml |
|
152 | haml |
|
152 | in_place_editing |
|
153 | in_place_editing |
|
153 | jquery-rails |
|
154 | jquery-rails |
|
154 | jquery-timepicker-addon-rails |
|
155 | jquery-timepicker-addon-rails |
|
155 | jquery-ui-sass-rails |
|
156 | jquery-ui-sass-rails |
|
156 |
|
157 | ||
|
157 | mysql2 |
|
158 | mysql2 |
|
158 | prototype-rails |
|
159 | prototype-rails |
|
159 | rails (= 3.2.19) |
|
160 | rails (= 3.2.19) |
|
160 | rdiscount |
|
161 | rdiscount |
|
|
162 | + rouge | ||
|
161 | rspec-rails (~> 2.0) |
|
163 | rspec-rails (~> 2.0) |
|
162 | sass-rails (~> 3.2.3) |
|
164 | sass-rails (~> 3.2.3) |
|
163 | test-unit |
|
165 | test-unit |
|
164 | uglifier (>= 1.0.3) |
|
166 | uglifier (>= 1.0.3) |
|
165 | verification! |
|
167 | verification! |
|
166 | will_paginate (~> 3.0.0) |
|
168 | will_paginate (~> 3.0.0) |
@@ -1,37 +1,46 | |||||
|
1 | class ApplicationController < ActionController::Base |
|
1 | class ApplicationController < ActionController::Base |
|
2 | protect_from_forgery |
|
2 | protect_from_forgery |
|
3 |
|
3 | ||
|
4 | SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode' |
|
4 | SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode' |
|
5 |
|
5 | ||
|
6 | def admin_authorization |
|
6 | def admin_authorization |
|
7 | return false unless authenticate |
|
7 | return false unless authenticate |
|
8 | user = User.find(session[:user_id], :include => ['roles']) |
|
8 | user = User.find(session[:user_id], :include => ['roles']) |
|
9 | - redirect_to :controller => 'main', :action => 'login' unless user.admin? |
|
9 | + unless user.admin? |
|
|
10 | + flash[:notice] = 'You are not authorized to view the page you requested' | ||
|
|
11 | + redirect_to :controller => 'main', :action => 'login' unless user.admin? | ||
|
|
12 | + return false | ||
|
|
13 | + end | ||
|
|
14 | + return true | ||
|
10 | end |
|
15 | end |
|
11 |
|
16 | ||
|
12 | def authorization_by_roles(allowed_roles) |
|
17 | def authorization_by_roles(allowed_roles) |
|
13 | return false unless authenticate |
|
18 | return false unless authenticate |
|
14 | user = User.find(session[:user_id]) |
|
19 | user = User.find(session[:user_id]) |
|
15 | unless user.roles.detect { |role| allowed_roles.member?(role.name) } |
|
20 | unless user.roles.detect { |role| allowed_roles.member?(role.name) } |
|
16 | flash[:notice] = 'You are not authorized to view the page you requested' |
|
21 | flash[:notice] = 'You are not authorized to view the page you requested' |
|
17 | redirect_to :controller => 'main', :action => 'login' |
|
22 | redirect_to :controller => 'main', :action => 'login' |
|
18 | return false |
|
23 | return false |
|
19 | end |
|
24 | end |
|
20 | end |
|
25 | end |
|
21 |
|
26 | ||
|
22 | protected |
|
27 | protected |
|
23 |
|
28 | ||
|
24 | def authenticate |
|
29 | def authenticate |
|
25 | unless session[:user_id] |
|
30 | unless session[:user_id] |
|
|
31 | + flash[:notice] = 'You need to login' | ||
|
|
32 | + if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] | ||
|
|
33 | + flash[:notice] = 'You need to login but you cannot log in at this time' | ||
|
|
34 | + end | ||
|
26 | redirect_to :controller => 'main', :action => 'login' |
|
35 | redirect_to :controller => 'main', :action => 'login' |
|
27 | return false |
|
36 | return false |
|
28 | end |
|
37 | end |
|
29 |
|
38 | ||
|
30 | # check if run in single user mode |
|
39 | # check if run in single user mode |
|
31 | if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] |
|
40 | if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] |
|
32 | user = User.find(session[:user_id]) |
|
41 | user = User.find(session[:user_id]) |
|
33 | if user==nil or (not user.admin?) |
|
42 | if user==nil or (not user.admin?) |
|
34 | flash[:notice] = 'You cannot log in at this time' |
|
43 | flash[:notice] = 'You cannot log in at this time' |
|
35 | redirect_to :controller => 'main', :action => 'login' |
|
44 | redirect_to :controller => 'main', :action => 'login' |
|
36 | return false |
|
45 | return false |
|
37 | end |
|
46 | end |
@@ -1,15 +1,24 | |||||
|
1 | class GradersController < ApplicationController |
|
1 | class GradersController < ApplicationController |
|
2 |
|
2 | ||
|
3 | - before_filter :admin_authorization |
|
3 | + before_filter :admin_authorization, except: [ :submission ] |
|
|
4 | + before_filter(only: [:submission]) { | ||
|
|
5 | + return false unless authenticate | ||
|
|
6 | + | ||
|
|
7 | + if GraderConfiguration["right.user_view_submission"] | ||
|
|
8 | + return true; | ||
|
|
9 | + end | ||
|
|
10 | + | ||
|
|
11 | + admin_authorization | ||
|
|
12 | + } | ||
|
4 |
|
13 | ||
|
5 | verify :method => :post, :only => ['clear_all', |
|
14 | verify :method => :post, :only => ['clear_all', |
|
6 | 'start_exam', |
|
15 | 'start_exam', |
|
7 | 'start_grading', |
|
16 | 'start_grading', |
|
8 | 'stop_all', |
|
17 | 'stop_all', |
|
9 | 'clear_terminated'], |
|
18 | 'clear_terminated'], |
|
10 | :redirect_to => {:action => 'index'} |
|
19 | :redirect_to => {:action => 'index'} |
|
11 |
|
20 | ||
|
12 | def index |
|
21 | def index |
|
13 | redirect_to :action => 'list' |
|
22 | redirect_to :action => 'list' |
|
14 | end |
|
23 | end |
|
15 |
|
24 | ||
@@ -54,24 +63,36 | |||||
|
54 | end |
|
63 | end |
|
55 |
|
64 | ||
|
56 | def test_request |
|
65 | def test_request |
|
57 | @test_request = TestRequest.find(params[:id]) |
|
66 | @test_request = TestRequest.find(params[:id]) |
|
58 | end |
|
67 | end |
|
59 |
|
68 | ||
|
60 | def task |
|
69 | def task |
|
61 | @task = Task.find(params[:id]) |
|
70 | @task = Task.find(params[:id]) |
|
62 | end |
|
71 | end |
|
63 |
|
72 | ||
|
64 | def submission |
|
73 | def submission |
|
65 | @submission = Submission.find(params[:id]) |
|
74 | @submission = Submission.find(params[:id]) |
|
|
75 | + formatter = Rouge::Formatters::HTML.new(css_class: 'highlight', line_numbers: true ) | ||
|
|
76 | + lexer = case @submission.language.name | ||
|
|
77 | + when "c" then Rouge::Lexers::C.new | ||
|
|
78 | + when "cpp" then Rouge::Lexers::Cpp.new | ||
|
|
79 | + when "pas" then Rouge::Lexers::Pas.new | ||
|
|
80 | + when "ruby" then Rouge::Lexers::Ruby.new | ||
|
|
81 | + when "python" then Rouge::Lexers::Python.new | ||
|
|
82 | + when "java" then Rouge::Lexers::Java.new | ||
|
|
83 | + end | ||
|
|
84 | + @formatted_code = formatter.format(lexer.lex(@submission.source)) | ||
|
|
85 | + @css_style = Rouge::Themes::ThankfulEyes.render(scope: '.highlight') | ||
|
|
86 | + | ||
|
66 | end |
|
87 | end |
|
67 |
|
88 | ||
|
68 | # various grader controls |
|
89 | # various grader controls |
|
69 |
|
90 | ||
|
70 | def stop |
|
91 | def stop |
|
71 | grader_proc = GraderProcess.find(params[:id]) |
|
92 | grader_proc = GraderProcess.find(params[:id]) |
|
72 | GraderScript.stop_grader(grader_proc.pid) |
|
93 | GraderScript.stop_grader(grader_proc.pid) |
|
73 | flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.' |
|
94 | flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.' |
|
74 | redirect_to :action => 'list' |
|
95 | redirect_to :action => 'list' |
|
75 | end |
|
96 | end |
|
76 |
|
97 | ||
|
77 | def stop_all |
|
98 | def stop_all |
@@ -1,13 +1,25 | |||||
|
1 | class ReportController < ApplicationController |
|
1 | class ReportController < ApplicationController |
|
|
2 | + | ||
|
|
3 | + before_filter :admin_authorization, only: [:login_stat,:submission_stat] | ||
|
|
4 | + before_filter(only: [:problem_hof]) { |c| | ||
|
|
5 | + return false unless authenticate | ||
|
|
6 | + | ||
|
|
7 | + if GraderConfiguration["right.user_view_submission"] | ||
|
|
8 | + return true; | ||
|
|
9 | + end | ||
|
|
10 | + | ||
|
|
11 | + admin_authorization | ||
|
|
12 | + } | ||
|
|
13 | + | ||
|
2 | def login_stat |
|
14 | def login_stat |
|
3 | @logins = Array.new |
|
15 | @logins = Array.new |
|
4 |
|
16 | ||
|
5 | date_and_time = '%Y-%m-%d %H:%M' |
|
17 | date_and_time = '%Y-%m-%d %H:%M' |
|
6 | begin |
|
18 | begin |
|
7 | @since_time = DateTime.strptime(params[:since_datetime],date_and_time) |
|
19 | @since_time = DateTime.strptime(params[:since_datetime],date_and_time) |
|
8 | rescue |
|
20 | rescue |
|
9 | @since_time = DateTime.new(1000,1,1) |
|
21 | @since_time = DateTime.new(1000,1,1) |
|
10 | end |
|
22 | end |
|
11 | begin |
|
23 | begin |
|
12 | @until_time = DateTime.strptime(params[:until_datetime],date_and_time) |
|
24 | @until_time = DateTime.strptime(params[:until_datetime],date_and_time) |
|
13 | rescue |
|
25 | rescue |
@@ -60,13 +72,117 | |||||
|
60 | a = nil |
|
72 | a = nil |
|
61 | end |
|
73 | end |
|
62 | @submissions[s.user_id][:sub][s.problem_id] = |
|
74 | @submissions[s.user_id][:sub][s.problem_id] = |
|
63 | { prob_name: (a ? a.full_name : '(NULL)'), |
|
75 | { prob_name: (a ? a.full_name : '(NULL)'), |
|
64 | sub_ids: [s.id] } |
|
76 | sub_ids: [s.id] } |
|
65 | else |
|
77 | else |
|
66 | @submissions[s.user_id][:sub][s.problem_id][:sub_ids] << s.id |
|
78 | @submissions[s.user_id][:sub][s.problem_id][:sub_ids] << s.id |
|
67 | end |
|
79 | end |
|
68 | @submissions[s.user_id][:count] += 1 |
|
80 | @submissions[s.user_id][:count] += 1 |
|
69 | end |
|
81 | end |
|
70 | end |
|
82 | end |
|
71 | end |
|
83 | end |
|
|
84 | + | ||
|
|
85 | + def problem_hof | ||
|
|
86 | + # gen problem list | ||
|
|
87 | + @user = User.find(session[:user_id]) | ||
|
|
88 | + @problems = @user.available_problems | ||
|
|
89 | + | ||
|
|
90 | + # get selected problems or the default | ||
|
|
91 | + if params[:id] | ||
|
|
92 | + begin | ||
|
|
93 | + @problem = Problem.available.find(params[:id]) | ||
|
|
94 | + rescue | ||
|
|
95 | + redirect_to action: :problem_hof | ||
|
|
96 | + flash[:notice] = 'Error: submissions for that problem are not viewable.' | ||
|
|
97 | + return | ||
|
|
98 | + end | ||
|
|
99 | + end | ||
|
|
100 | + | ||
|
|
101 | + if @problem | ||
|
|
102 | + #aggregrate by language | ||
|
|
103 | + @by_lang = {} | ||
|
|
104 | + Submission.where(problem_id: @problem.id).find_each do |sub| | ||
|
|
105 | + lang = Language.find_by_id(sub.language_id) | ||
|
|
106 | + next unless lang | ||
|
|
107 | + next unless sub.points >= @problem.full_score | ||
|
|
108 | + | ||
|
|
109 | + #initialize | ||
|
|
110 | + unless @by_lang.has_key?(lang.pretty_name) | ||
|
|
111 | + @by_lang[lang.pretty_name] = { | ||
|
|
112 | + runtime: { avail: false, value: 2**30-1 }, | ||
|
|
113 | + memory: { avail: false, value: 2**30-1 }, | ||
|
|
114 | + length: { avail: false, value: 2**30-1 }, | ||
|
|
115 | + first: { avail: false, value: DateTime.new(3000,1,1) } | ||
|
|
116 | + } | ||
|
|
117 | + end | ||
|
|
118 | + | ||
|
|
119 | + if sub.max_runtime and sub.max_runtime < @by_lang[lang.pretty_name][:runtime][:value] | ||
|
|
120 | + @by_lang[lang.pretty_name][:runtime] = { | ||
|
|
121 | + avail: true, | ||
|
|
122 | + user_id: sub.user_id, | ||
|
|
123 | + value: sub.max_runtime, | ||
|
|
124 | + sub_id: sub.id | ||
|
|
125 | + } | ||
|
|
126 | + end | ||
|
|
127 | + | ||
|
|
128 | + if sub.peak_memory and sub.peak_memory < @by_lang[lang.pretty_name][:memory][:value] | ||
|
|
129 | + @by_lang[lang.pretty_name][:memory] = { | ||
|
|
130 | + avail: true, | ||
|
|
131 | + user_id: sub.user_id, | ||
|
|
132 | + value: sub.peak_memory, | ||
|
|
133 | + sub_id: sub.id | ||
|
|
134 | + } | ||
|
|
135 | + end | ||
|
|
136 | + | ||
|
|
137 | + if sub.submitted_at and sub.submitted_at < @by_lang[lang.pretty_name][:first][:value] and | ||
|
|
138 | + !sub.user.admin? | ||
|
|
139 | + @by_lang[lang.pretty_name][:first] = { | ||
|
|
140 | + avail: true, | ||
|
|
141 | + user_id: sub.user_id, | ||
|
|
142 | + value: sub.submitted_at, | ||
|
|
143 | + sub_id: sub.id | ||
|
|
144 | + } | ||
|
|
145 | + end | ||
|
|
146 | + | ||
|
|
147 | + if @by_lang[lang.pretty_name][:length][:value] > sub.effective_code_length | ||
|
|
148 | + @by_lang[lang.pretty_name][:length] = { | ||
|
|
149 | + avail: true, | ||
|
|
150 | + user_id: sub.user_id, | ||
|
|
151 | + value: sub.effective_code_length, | ||
|
|
152 | + sub_id: sub.id | ||
|
|
153 | + } | ||
|
|
154 | + end | ||
|
|
155 | + end | ||
|
|
156 | + | ||
|
|
157 | + #process user_id | ||
|
|
158 | + @by_lang.each do |lang,prop| | ||
|
|
159 | + prop.each do |k,v| | ||
|
|
160 | + v[:user] = User.exists?(v[:user_id]) ? User.find(v[:user_id]).full_name : "(NULL)" | ||
|
|
161 | + end | ||
|
|
162 | + end | ||
|
|
163 | + | ||
|
|
164 | + #sum into best | ||
|
|
165 | + if @by_lang and @by_lang.first | ||
|
|
166 | + @best = @by_lang.first[1] | ||
|
|
167 | + @by_lang.each do |lang,prop| | ||
|
|
168 | + if @best[:runtime][:value] >= prop[:runtime][:value] | ||
|
|
169 | + @best[:runtime] = prop[:runtime] | ||
|
|
170 | + @best[:runtime][:lang] = lang | ||
|
|
171 | + end | ||
|
|
172 | + if @best[:memory][:value] >= prop[:memory][:value] | ||
|
|
173 | + @best[:memory] = prop[:memory] | ||
|
|
174 | + @best[:memory][:lang] = lang | ||
|
|
175 | + end | ||
|
|
176 | + if @best[:length][:value] >= prop[:length][:value] | ||
|
|
177 | + @best[:length] = prop[:length] | ||
|
|
178 | + @best[:length][:lang] = lang | ||
|
|
179 | + end | ||
|
|
180 | + if @best[:first][:value] >= prop[:first][:value] | ||
|
|
181 | + @best[:first] = prop[:first] | ||
|
|
182 | + @best[:first][:lang] = lang | ||
|
|
183 | + end | ||
|
|
184 | + end | ||
|
|
185 | + end | ||
|
|
186 | + end | ||
|
|
187 | + end | ||
|
72 | end |
|
188 | end |
@@ -21,24 +21,28 | |||||
|
21 | menu_items << "<br/>" |
|
21 | menu_items << "<br/>" |
|
22 | end |
|
22 | end |
|
23 |
|
23 | ||
|
24 | # main page |
|
24 | # main page |
|
25 | append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list' |
|
25 | append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list' |
|
26 | append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list' |
|
26 | append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list' |
|
27 |
|
27 | ||
|
28 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
28 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
29 | append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list' |
|
29 | append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list' |
|
30 | append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' |
|
30 | append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' |
|
31 | append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' |
|
31 | append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' |
|
32 | end |
|
32 | end |
|
|
33 | + | ||
|
|
34 | + if GraderConfiguration['right.user_hall_of_fame'] | ||
|
|
35 | + append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof' | ||
|
|
36 | + end | ||
|
33 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
37 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
34 |
|
38 | ||
|
35 | if GraderConfiguration['system.user_setting_enabled'] |
|
39 | if GraderConfiguration['system.user_setting_enabled'] |
|
36 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
|
40 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
|
37 | end |
|
41 | end |
|
38 | append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login' |
|
42 | append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login' |
|
39 |
|
43 | ||
|
40 | menu_items.html_safe |
|
44 | menu_items.html_safe |
|
41 | end |
|
45 | end |
|
42 |
|
46 | ||
|
43 | def append_to(option,label, controller, action) |
|
47 | def append_to(option,label, controller, action) |
|
44 | option << ' ' if option!='' |
|
48 | option << ' ' if option!='' |
@@ -1,22 +1,27 | |||||
|
|
1 | + %style{type: "text/css"} | ||
|
|
2 | + = @css_style | ||
|
|
3 | + | ||
|
1 | %h1= "Submission: #{@submission.id}" |
|
4 | %h1= "Submission: #{@submission.id}" |
|
2 |
|
5 | ||
|
3 | %p |
|
6 | %p |
|
4 | User: |
|
7 | User: |
|
5 | - = "#{@submission.user.login}" |
|
8 | + = "(#{@submission.user.login}) #{@submission.user.full_name}" |
|
6 | %br/ |
|
9 | %br/ |
|
7 | Problem: |
|
10 | Problem: |
|
8 | - if @submission.problem!=nil |
|
11 | - if @submission.problem!=nil |
|
9 | = "#{@submission.problem.full_name}" |
|
12 | = "#{@submission.problem.full_name}" |
|
10 | - else |
|
13 | - else |
|
11 | = "(n/a)" |
|
14 | = "(n/a)" |
|
12 | %br/ |
|
15 | %br/ |
|
13 | = "Number: #{@submission.number}" |
|
16 | = "Number: #{@submission.number}" |
|
14 | %br/ |
|
17 | %br/ |
|
15 | = "Submitted at: #{format_short_time(@submission.submitted_at)}" |
|
18 | = "Submitted at: #{format_short_time(@submission.submitted_at)}" |
|
|
19 | + %br/ | ||
|
|
20 | + = "Points : #{@submission.points}/#{@submission.problem.full_score}" | ||
|
|
21 | + %br/ | ||
|
|
22 | + = "Comment : #{@submission.grader_comment}" | ||
|
16 |
|
23 | ||
|
17 | %b Source code (first 10kb) |
|
24 | %b Source code (first 10kb) |
|
18 |
- %div{:style => "border: 1px solid black; |
|
25 | + //%div.highlight{:style => "border: 1px solid black;"} |
|
19 | - - if @submission.source |
|
26 | + =@formatted_code.html_safe |
|
20 | - %pre |
|
||
|
21 | - =h truncate @submission.source, :length => 10240 |
|
||
|
22 |
|
27 |
@@ -1,6 +1,7 | |||||
|
1 |
|
1 | ||
|
2 | .task-menu |
|
2 | .task-menu |
|
3 | Reports |
|
3 | Reports |
|
4 | %br/ |
|
4 | %br/ |
|
|
5 | + = link_to '[Hall of Fame]', :action => 'problem_hof' | ||
|
5 | = link_to '[Submission]', :action => 'submission_stat' |
|
6 | = link_to '[Submission]', :action => 'submission_stat' |
|
6 | = link_to '[Login]', :action => 'login_stat' |
|
7 | = link_to '[Login]', :action => 'login_stat' |
@@ -1,25 +1,23 | |||||
|
1 | - content_for :header do |
|
1 | - content_for :header do |
|
2 | = javascript_include_tag 'new' |
|
2 | = javascript_include_tag 'new' |
|
3 |
|
3 | ||
|
4 | %script{:type=>"text/javascript"} |
|
4 | %script{:type=>"text/javascript"} |
|
5 | $(function () { |
|
5 | $(function () { |
|
6 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
6 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
7 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
7 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
8 | }); |
|
8 | }); |
|
9 |
|
9 | ||
|
10 | - |
|
||
|
11 | %h1 Login status |
|
10 | %h1 Login status |
|
12 |
|
11 | ||
|
13 | - |
|
||
|
14 | =render partial: 'report_menu' |
|
12 | =render partial: 'report_menu' |
|
15 | =render partial: 'date_range', locals: {param_text: 'Login date range:', title: 'Query login stat in the range' } |
|
13 | =render partial: 'date_range', locals: {param_text: 'Login date range:', title: 'Query login stat in the range' } |
|
16 |
|
14 | ||
|
17 | %table.info |
|
15 | %table.info |
|
18 | %thead |
|
16 | %thead |
|
19 | %tr.info-head |
|
17 | %tr.info-head |
|
20 | %th login |
|
18 | %th login |
|
21 | %th full name |
|
19 | %th full name |
|
22 | %th login count |
|
20 | %th login count |
|
23 | %th earliest |
|
21 | %th earliest |
|
24 | %th latest |
|
22 | %th latest |
|
25 | %tbody |
|
23 | %tbody |
@@ -1,27 +1,23 | |||||
|
1 | - content_for :header do |
|
1 | - content_for :header do |
|
2 | = javascript_include_tag 'new' |
|
2 | = javascript_include_tag 'new' |
|
3 |
|
3 | ||
|
4 | %script{:type=>"text/javascript"} |
|
4 | %script{:type=>"text/javascript"} |
|
5 | $(function () { |
|
5 | $(function () { |
|
6 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
6 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
7 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
7 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
8 | }); |
|
8 | }); |
|
9 |
|
9 | ||
|
10 | - |
|
||
|
11 | %h1 Login status |
|
10 | %h1 Login status |
|
12 |
|
11 | ||
|
13 | - |
|
||
|
14 | - |
|
||
|
15 | - |
|
||
|
16 | =render partial: 'report_menu' |
|
12 | =render partial: 'report_menu' |
|
17 | =render partial: 'date_range', locals: {param_text: 'Submission date range:', title: 'Query submission stat in the range' } |
|
13 | =render partial: 'date_range', locals: {param_text: 'Submission date range:', title: 'Query submission stat in the range' } |
|
18 |
|
14 | ||
|
19 | %table.info |
|
15 | %table.info |
|
20 | %thead |
|
16 | %thead |
|
21 | %tr.info-head |
|
17 | %tr.info-head |
|
22 | %th login |
|
18 | %th login |
|
23 | %th full name |
|
19 | %th full name |
|
24 | %th total submissions |
|
20 | %th total submissions |
|
25 | %th submissions |
|
21 | %th submissions |
|
26 | %tbody |
|
22 | %tbody |
|
27 | - @submissions.each do |user_id,data| |
|
23 | - @submissions.each do |user_id,data| |
@@ -50,15 +50,15 | |||||
|
50 | # Enforce whitelist mode for mass assignment. |
|
50 | # Enforce whitelist mode for mass assignment. |
|
51 | # This will create an empty whitelist of attributes available for mass-assignment for all models |
|
51 | # This will create an empty whitelist of attributes available for mass-assignment for all models |
|
52 | # in your app. As such, your models will need to explicitly whitelist or blacklist accessible |
|
52 | # in your app. As such, your models will need to explicitly whitelist or blacklist accessible |
|
53 | # parameters by using an attr_accessible or attr_protected declaration. |
|
53 | # parameters by using an attr_accessible or attr_protected declaration. |
|
54 | config.active_record.whitelist_attributes = false |
|
54 | config.active_record.whitelist_attributes = false |
|
55 |
|
55 | ||
|
56 | # Enable the asset pipeline |
|
56 | # Enable the asset pipeline |
|
57 | config.assets.enabled = true |
|
57 | config.assets.enabled = true |
|
58 |
|
58 | ||
|
59 | # Version of your assets, change this if you want to expire all your assets |
|
59 | # Version of your assets, change this if you want to expire all your assets |
|
60 | config.assets.version = '1.0' |
|
60 | config.assets.version = '1.0' |
|
61 |
|
61 | ||
|
62 | - config.assets.precompile += ['announcement_refresh.js','effects.js','site_update.js','graders.css','problems.css'] |
|
62 | + config.assets.precompile += ['announcement_refresh.js','effects.js','site_update.js','graders.css','problems.css','new.js'] |
|
63 | end |
|
63 | end |
|
64 | end |
|
64 | end |
@@ -11,24 +11,25 | |||||
|
11 |
|
11 | ||
|
12 | go_ahead_to: "Go ahead to" |
|
12 | go_ahead_to: "Go ahead to" |
|
13 | go_back_to: "Go back to" |
|
13 | go_back_to: "Go back to" |
|
14 | login_page: "login page" |
|
14 | login_page: "login page" |
|
15 | home_page: "home page" |
|
15 | home_page: "home page" |
|
16 |
|
16 | ||
|
17 | menu: |
|
17 | menu: |
|
18 | main: 'Main' |
|
18 | main: 'Main' |
|
19 | messages: 'Messages' |
|
19 | messages: 'Messages' |
|
20 | tasks: 'Tasks' |
|
20 | tasks: 'Tasks' |
|
21 | submissions: 'Submissions' |
|
21 | submissions: 'Submissions' |
|
22 | test: 'Test Interface' |
|
22 | test: 'Test Interface' |
|
|
23 | + hall_of_fame: 'Hall of Fame' | ||
|
23 | help: 'Help' |
|
24 | help: 'Help' |
|
24 | settings: 'Settings' |
|
25 | settings: 'Settings' |
|
25 | log_out: 'Log out' |
|
26 | log_out: 'Log out' |
|
26 |
|
27 | ||
|
27 | title_bar: |
|
28 | title_bar: |
|
28 | current_time: "Current time is" |
|
29 | current_time: "Current time is" |
|
29 | remaining_time: "Time left: " |
|
30 | remaining_time: "Time left: " |
|
30 | contest_not_started: "The contest has not started." |
|
31 | contest_not_started: "The contest has not started." |
|
31 |
|
32 | ||
|
32 | login: |
|
33 | login: |
|
33 | message: 'Please login to see the problem list' |
|
34 | message: 'Please login to see the problem list' |
|
34 | login_submit: 'Login' |
|
35 | login_submit: 'Login' |
@@ -11,24 +11,25 | |||||
|
11 |
|
11 | ||
|
12 | go_ahead_to: "ไปยัง" |
|
12 | go_ahead_to: "ไปยัง" |
|
13 | go_back_to: "กลับไปยัง" |
|
13 | go_back_to: "กลับไปยัง" |
|
14 | login_page: "หน้าเข้าใช้ระบบ" |
|
14 | login_page: "หน้าเข้าใช้ระบบ" |
|
15 | home_page: "หน้าแรก" |
|
15 | home_page: "หน้าแรก" |
|
16 |
|
16 | ||
|
17 | menu: |
|
17 | menu: |
|
18 | main: 'หน้าหลัก' |
|
18 | main: 'หน้าหลัก' |
|
19 | messages: 'ข้อความ' |
|
19 | messages: 'ข้อความ' |
|
20 | tasks: 'โจทย์' |
|
20 | tasks: 'โจทย์' |
|
21 | submissions: 'โปรแกรมที่ส่ง' |
|
21 | submissions: 'โปรแกรมที่ส่ง' |
|
22 | test: 'ทดสอบโปรแกรม' |
|
22 | test: 'ทดสอบโปรแกรม' |
|
|
23 | + hall_of_fame: 'หอเกียรติยศ' | ||
|
23 | help: 'ความช่วยเหลือ' |
|
24 | help: 'ความช่วยเหลือ' |
|
24 | settings: 'เปลี่ยนรหัสผ่าน' |
|
25 | settings: 'เปลี่ยนรหัสผ่าน' |
|
25 | log_out: 'ออกจากระบบ' |
|
26 | log_out: 'ออกจากระบบ' |
|
26 |
|
27 | ||
|
27 | title_bar: |
|
28 | title_bar: |
|
28 | current_time: "เวลาปัจจุบันคือ" |
|
29 | current_time: "เวลาปัจจุบันคือ" |
|
29 | remaining_time: "เหลือเวลาอีก" |
|
30 | remaining_time: "เหลือเวลาอีก" |
|
30 | contest_not_started: "ยังไม่เริ่มแข่งขัน" |
|
31 | contest_not_started: "ยังไม่เริ่มแข่งขัน" |
|
31 |
|
32 | ||
|
32 | login: |
|
33 | login: |
|
33 | message: 'กรุณา login เพื่อเข้าสู่ระบบ' |
|
34 | message: 'กรุณา login เพื่อเข้าสู่ระบบ' |
|
34 | login_submit: 'เข้าใช้ระบบ' |
|
35 | login_submit: 'เข้าใช้ระบบ' |
@@ -1,102 +1,116 | |||||
|
1 | CONFIGURATIONS = |
|
1 | CONFIGURATIONS = |
|
2 | [ |
|
2 | [ |
|
3 | { |
|
3 | { |
|
4 | :key => 'system.single_user_mode', |
|
4 | :key => 'system.single_user_mode', |
|
5 | :value_type => 'boolean', |
|
5 | :value_type => 'boolean', |
|
6 | :default_value => 'false', |
|
6 | :default_value => 'false', |
|
7 | :description => 'Only admins can log in to the system when running under single user mode.' |
|
7 | :description => 'Only admins can log in to the system when running under single user mode.' |
|
8 | }, |
|
8 | }, |
|
9 | - |
|
9 | + |
|
10 | { |
|
10 | { |
|
11 | :key => 'ui.front.title', |
|
11 | :key => 'ui.front.title', |
|
12 | :value_type => 'string', |
|
12 | :value_type => 'string', |
|
13 | :default_value => 'Grader' |
|
13 | :default_value => 'Grader' |
|
14 | }, |
|
14 | }, |
|
15 | - |
|
15 | + |
|
16 | { |
|
16 | { |
|
17 | :key => 'ui.front.welcome_message', |
|
17 | :key => 'ui.front.welcome_message', |
|
18 | :value_type => 'string', |
|
18 | :value_type => 'string', |
|
19 | :default_value => 'Welcome!' |
|
19 | :default_value => 'Welcome!' |
|
20 | }, |
|
20 | }, |
|
21 | - |
|
21 | + |
|
22 | { |
|
22 | { |
|
23 | :key => 'ui.show_score', |
|
23 | :key => 'ui.show_score', |
|
24 | :value_type => 'boolean', |
|
24 | :value_type => 'boolean', |
|
25 | :default_value => 'true' |
|
25 | :default_value => 'true' |
|
26 | }, |
|
26 | }, |
|
27 | - |
|
27 | + |
|
28 | { |
|
28 | { |
|
29 | :key => 'contest.time_limit', |
|
29 | :key => 'contest.time_limit', |
|
30 | :value_type => 'string', |
|
30 | :value_type => 'string', |
|
31 | :default_value => 'unlimited', |
|
31 | :default_value => 'unlimited', |
|
32 | :description => 'Time limit in format hh:mm, or "unlimited" for contests with no time limits. This config is CACHED. Restart the server before the change can take effect.' |
|
32 | :description => 'Time limit in format hh:mm, or "unlimited" for contests with no time limits. This config is CACHED. Restart the server before the change can take effect.' |
|
33 | }, |
|
33 | }, |
|
34 | - |
|
34 | + |
|
35 | { |
|
35 | { |
|
36 | :key => 'system.mode', |
|
36 | :key => 'system.mode', |
|
37 | :value_type => 'string', |
|
37 | :value_type => 'string', |
|
38 | :default_value => 'standard', |
|
38 | :default_value => 'standard', |
|
39 | :description => 'Current modes are "standard", "contest", "indv-contest", and "analysis".' |
|
39 | :description => 'Current modes are "standard", "contest", "indv-contest", and "analysis".' |
|
40 | }, |
|
40 | }, |
|
41 | - |
|
41 | + |
|
42 | { |
|
42 | { |
|
43 | :key => 'contest.name', |
|
43 | :key => 'contest.name', |
|
44 | :value_type => 'string', |
|
44 | :value_type => 'string', |
|
45 | :default_value => 'Grader', |
|
45 | :default_value => 'Grader', |
|
46 | :description => 'This name will be shown on the user header bar.' |
|
46 | :description => 'This name will be shown on the user header bar.' |
|
47 | }, |
|
47 | }, |
|
48 | - |
|
48 | + |
|
49 | { |
|
49 | { |
|
50 | :key => 'contest.multisites', |
|
50 | :key => 'contest.multisites', |
|
51 | :value_type => 'boolean', |
|
51 | :value_type => 'boolean', |
|
52 | :default_value => 'false', |
|
52 | :default_value => 'false', |
|
53 | :description => 'If the server is in contest mode and this option is true, on the log in of the admin a menu for site selections is shown.' |
|
53 | :description => 'If the server is in contest mode and this option is true, on the log in of the admin a menu for site selections is shown.' |
|
54 | }, |
|
54 | }, |
|
55 | - |
|
55 | + |
|
56 | { |
|
56 | { |
|
57 | - :key => 'system.online_registration', |
|
57 | + :key => 'right.user_hall_of_fame', |
|
58 | :value_type => 'boolean', |
|
58 | :value_type => 'boolean', |
|
59 | :default_value => 'false', |
|
59 | :default_value => 'false', |
|
60 | - :description => 'This option enables online registration.' |
|
60 | + :description => 'If true, any user can access hall of fame page.' |
|
61 | }, |
|
61 | }, |
|
62 | - |
|
62 | + |
|
|
63 | + { | ||
|
|
64 | + :key => 'right.user_view_submission', | ||
|
|
65 | + :value_type => 'boolean', | ||
|
|
66 | + :default_value => 'false', | ||
|
|
67 | + :description => 'If true, any user can view submissions of every one.' | ||
|
|
68 | + }, | ||
|
|
69 | + | ||
|
63 | # If Configuration['system.online_registration'] is true, the |
|
70 | # If Configuration['system.online_registration'] is true, the |
|
64 | # system allows online registration, and will use these |
|
71 | # system allows online registration, and will use these |
|
65 | # information for sending confirmation emails. |
|
72 | # information for sending confirmation emails. |
|
66 | { |
|
73 | { |
|
67 | :key => 'system.online_registration.smtp', |
|
74 | :key => 'system.online_registration.smtp', |
|
68 | :value_type => 'string', |
|
75 | :value_type => 'string', |
|
69 | :default_value => 'smtp.somehost.com' |
|
76 | :default_value => 'smtp.somehost.com' |
|
70 | }, |
|
77 | }, |
|
71 | - |
|
78 | + |
|
72 | { |
|
79 | { |
|
73 | :key => 'system.online_registration.from', |
|
80 | :key => 'system.online_registration.from', |
|
74 | :value_type => 'string', |
|
81 | :value_type => 'string', |
|
75 | :default_value => 'your.email@address' |
|
82 | :default_value => 'your.email@address' |
|
76 | }, |
|
83 | }, |
|
77 | - |
|
84 | + |
|
78 | { |
|
85 | { |
|
79 | :key => 'system.admin_email', |
|
86 | :key => 'system.admin_email', |
|
80 | :value_type => 'string', |
|
87 | :value_type => 'string', |
|
81 | :default_value => 'admin@admin.email' |
|
88 | :default_value => 'admin@admin.email' |
|
82 | }, |
|
89 | }, |
|
83 | - |
|
90 | + |
|
84 | { |
|
91 | { |
|
85 | :key => 'system.user_setting_enabled', |
|
92 | :key => 'system.user_setting_enabled', |
|
86 | :value_type => 'boolean', |
|
93 | :value_type => 'boolean', |
|
87 | :default_value => 'true', |
|
94 | :default_value => 'true', |
|
88 | :description => 'If this option is true, users can change their settings' |
|
95 | :description => 'If this option is true, users can change their settings' |
|
89 | }, |
|
96 | }, |
|
90 | - |
|
97 | + |
|
|
98 | + { | ||
|
|
99 | + :key => 'system.user_setting_enabled', | ||
|
|
100 | + :value_type => 'boolean', | ||
|
|
101 | + :default_value => 'true', | ||
|
|
102 | + :description => 'If this option is true, users can change their settings' | ||
|
|
103 | + } | ||
|
|
104 | + | ||
|
91 | # If Configuration['contest.test_request.early_timeout'] is true |
|
105 | # If Configuration['contest.test_request.early_timeout'] is true |
|
92 | # the user will not be able to use test request at 30 minutes |
|
106 | # the user will not be able to use test request at 30 minutes |
|
93 | # before the contest ends. |
|
107 | # before the contest ends. |
|
94 | { |
|
108 | { |
|
95 | :key => 'contest.test_request.early_timeout', |
|
109 | :key => 'contest.test_request.early_timeout', |
|
96 | :value_type => 'boolean', |
|
110 | :value_type => 'boolean', |
|
97 | :default_value => 'false' |
|
111 | :default_value => 'false' |
|
98 | }, |
|
112 | }, |
|
99 |
|
113 | ||
|
100 | { |
|
114 | { |
|
101 | :key => 'system.multicontests', |
|
115 | :key => 'system.multicontests', |
|
102 | :value_type => 'boolean', |
|
116 | :value_type => 'boolean', |
@@ -106,25 +120,25 | |||||
|
106 | { |
|
120 | { |
|
107 | :key => 'contest.confirm_indv_contest_start', |
|
121 | :key => 'contest.confirm_indv_contest_start', |
|
108 | :value_type => 'boolean', |
|
122 | :value_type => 'boolean', |
|
109 | :default_value => 'false' |
|
123 | :default_value => 'false' |
|
110 | }, |
|
124 | }, |
|
111 |
|
125 | ||
|
112 | { |
|
126 | { |
|
113 | :key => 'contest.default_contest_name', |
|
127 | :key => 'contest.default_contest_name', |
|
114 | :value_type => 'string', |
|
128 | :value_type => 'string', |
|
115 | :default_value => 'none', |
|
129 | :default_value => 'none', |
|
116 | :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest." |
|
130 | :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest." |
|
117 | } |
|
131 | } |
|
118 | - |
|
132 | + |
|
119 | ] |
|
133 | ] |
|
120 |
|
134 | ||
|
121 |
|
135 | ||
|
122 | def create_configuration_key(key, |
|
136 | def create_configuration_key(key, |
|
123 | value_type, |
|
137 | value_type, |
|
124 | default_value, |
|
138 | default_value, |
|
125 | description='') |
|
139 | description='') |
|
126 | conf = (GraderConfiguration.find_by_key(key) || |
|
140 | conf = (GraderConfiguration.find_by_key(key) || |
|
127 | GraderConfiguration.new(:key => key, |
|
141 | GraderConfiguration.new(:key => key, |
|
128 | :value_type => value_type, |
|
142 | :value_type => value_type, |
|
129 | :value => default_value)) |
|
143 | :value => default_value)) |
|
130 | conf.description = description |
|
144 | conf.description = description |
@@ -185,14 +199,25 | |||||
|
185 |
|
199 | ||
|
186 | root.roles << Role.find_by_name('admin') |
|
200 | root.roles << Role.find_by_name('admin') |
|
187 |
|
201 | ||
|
188 | root.activated = true |
|
202 | root.activated = true |
|
189 | root.save |
|
203 | root.save |
|
190 | end |
|
204 | end |
|
191 |
|
205 | ||
|
192 | def seed_users_and_roles |
|
206 | def seed_users_and_roles |
|
193 | seed_roles |
|
207 | seed_roles |
|
194 | seed_root |
|
208 | seed_root |
|
195 | end |
|
209 | end |
|
196 |
|
210 | ||
|
|
211 | + def seed_more_languages | ||
|
|
212 | + Language.delete_all | ||
|
|
213 | + Language.create( name: 'c', pretty_name: 'C', ext: 'c', common_ext: 'c' ) | ||
|
|
214 | + Language.create( name: 'cpp', pretty_name: 'C++', ext: 'cpp', common_ext: 'cpp,cc' ) | ||
|
|
215 | + Language.create( name: 'pas', pretty_name: 'Pascal', ext: 'pas', common_ext: 'pas' ) | ||
|
|
216 | + Language.create( name: 'ruby', pretty_name: 'Ruby', ext: 'rb', common_ext: 'rb' ) | ||
|
|
217 | + Language.create( name: 'python', pretty_name: 'Python', ext: 'py', common_ext: 'py' ) | ||
|
|
218 | + Language.create( name: 'java', pretty_name: 'Java', ext: 'java', common_ext: 'java' ) | ||
|
|
219 | + end | ||
|
|
220 | + | ||
|
197 | seed_config |
|
221 | seed_config |
|
198 | seed_users_and_roles |
|
222 | seed_users_and_roles |
|
|
223 | + seed_more_languages |
You need to be logged in to leave comments.
Login now