Description:
prepare for better hall of fame
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r425:b86f327e0d75 - - 8 files changed: 46 inserted, 70 deleted
@@ -3,13 +3,18 | |||||
|
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) } |
@@ -1,9 +1,18 | |||||
|
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'], |
@@ -1,13 +1,13 | |||||
|
1 | class ReportController < ApplicationController |
|
1 | class ReportController < ApplicationController |
|
2 |
|
2 | ||
|
3 | before_filter :admin_authorization, only: [:login_stat,:submission_stat] |
|
3 | before_filter :admin_authorization, only: [:login_stat,:submission_stat] |
|
4 | - before_filter { |c| |
|
4 | + before_filter(only: [:problem_hof]) { |c| |
|
5 | return false unless authenticate |
|
5 | return false unless authenticate |
|
6 |
|
6 | ||
|
7 | - if GraderConfiguration["system.hall_of_fame_available"] |
|
7 | + if GraderConfiguration["right.user_view_submission"] |
|
8 | return true; |
|
8 | return true; |
|
9 | end |
|
9 | end |
|
10 |
|
10 | ||
|
11 | admin_authorization |
|
11 | admin_authorization |
|
12 | } |
|
12 | } |
|
13 |
|
13 | ||
@@ -153,33 +153,33 | |||||
|
153 | end |
|
153 | end |
|
154 | end |
|
154 | end |
|
155 |
|
155 | ||
|
156 | #process user_id |
|
156 | #process user_id |
|
157 | @by_lang.each do |lang,prop| |
|
157 | @by_lang.each do |lang,prop| |
|
158 | prop.each do |k,v| |
|
158 | prop.each do |k,v| |
|
159 |
- v[:user] = User.exists?(v[:user_id]) ? User.find(v[:user_id]). |
|
159 | + v[:user] = User.exists?(v[:user_id]) ? User.find(v[:user_id]).full_name : "(NULL)" |
|
160 | end |
|
160 | end |
|
161 | end |
|
161 | end |
|
162 |
|
162 | ||
|
163 | #sum into best |
|
163 | #sum into best |
|
164 | if @by_lang and @by_lang.first |
|
164 | if @by_lang and @by_lang.first |
|
165 | @best = @by_lang.first[1] |
|
165 | @best = @by_lang.first[1] |
|
166 | @by_lang.each do |lang,prop| |
|
166 | @by_lang.each do |lang,prop| |
|
167 | - if @best[:runtime][:value] > prop[:runtime][:value] |
|
167 | + if @best[:runtime][:value] >= prop[:runtime][:value] |
|
168 | @best[:runtime] = prop[:runtime] |
|
168 | @best[:runtime] = prop[:runtime] |
|
169 | @best[:runtime][:lang] = lang |
|
169 | @best[:runtime][:lang] = lang |
|
170 | end |
|
170 | end |
|
171 | - if @best[:memory][:value] > prop[:memory][:value] |
|
171 | + if @best[:memory][:value] >= prop[:memory][:value] |
|
172 | @best[:memory] = prop[:memory] |
|
172 | @best[:memory] = prop[:memory] |
|
173 | @best[:memory][:lang] = lang |
|
173 | @best[:memory][:lang] = lang |
|
174 | end |
|
174 | end |
|
175 | - if @best[:length][:value] > prop[:length][:value] |
|
175 | + if @best[:length][:value] >= prop[:length][:value] |
|
176 | @best[:length] = prop[:length] |
|
176 | @best[:length] = prop[:length] |
|
177 | @best[:length][:lang] = lang |
|
177 | @best[:length][:lang] = lang |
|
178 | end |
|
178 | end |
|
179 | - if @best[:first][:value] > prop[:first][:value] |
|
179 | + if @best[:first][:value] >= prop[:first][:value] |
|
180 | @best[:first] = prop[:first] |
|
180 | @best[:first] = prop[:first] |
|
181 | @best[:first][:lang] = lang |
|
181 | @best[:first][:lang] = lang |
|
182 | end |
|
182 | end |
|
183 | end |
|
183 | end |
|
184 | end |
|
184 | end |
|
185 | end |
|
185 | end |
@@ -28,13 +28,13 | |||||
|
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 |
|
33 | ||
|
34 |
- if GraderConfiguration[' |
|
34 | + if GraderConfiguration['right.user_hall_of_fame'] |
|
35 | append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof' |
|
35 | append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof' |
|
36 | end |
|
36 | end |
|
37 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
37 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
38 |
|
38 | ||
|
39 | if GraderConfiguration['system.user_setting_enabled'] |
|
39 | if GraderConfiguration['system.user_setting_enabled'] |
|
40 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
|
40 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
@@ -2,13 +2,13 | |||||
|
2 | = @css_style |
|
2 | = @css_style |
|
3 |
|
3 | ||
|
4 | %h1= "Submission: #{@submission.id}" |
|
4 | %h1= "Submission: #{@submission.id}" |
|
5 |
|
5 | ||
|
6 | %p |
|
6 | %p |
|
7 | User: |
|
7 | User: |
|
8 | - = "#{@submission.user.login}" |
|
8 | + = "(#{@submission.user.login}) #{@submission.user.full_name}" |
|
9 | %br/ |
|
9 | %br/ |
|
10 | Problem: |
|
10 | Problem: |
|
11 | - if @submission.problem!=nil |
|
11 | - if @submission.problem!=nil |
|
12 | = "#{@submission.problem.full_name}" |
|
12 | = "#{@submission.problem.full_name}" |
|
13 | - else |
|
13 | - else |
|
14 | = "(n/a)" |
|
14 | = "(n/a)" |
@@ -4,16 +4,14 | |||||
|
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 |
@@ -1,65 +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 | + | ||
|
1 | %h1 Tasks Hall of Fame |
|
9 | %h1 Tasks Hall of Fame |
|
2 | - |
|
||
|
3 | .task-menu |
|
10 | .task-menu |
|
4 | Tasks |
|
11 | Tasks |
|
5 | %br/ |
|
12 | %br/ |
|
6 | - @problems.each do |prob| |
|
13 | - @problems.each do |prob| |
|
7 | = link_to( "[#{prob.name}]", {id: prob.id}) |
|
14 | = link_to( "[#{prob.name}]", {id: prob.id}) |
|
8 |
|
15 | ||
|
9 | - |
|
16 | + - unless params[:id] |
|
10 | - |
|
17 | + /=render partial: 'all_time_hof' |
|
11 | - |
|
18 | + Please select a problem. |
|
12 | - %h2 Overall |
|
19 | + - else |
|
13 | - |
|
20 | + =render partial: 'task_hof' |
|
14 | - - if @best |
|
||
|
15 | - %b Best Runtime: |
|
||
|
16 | - = " by #{@best[:runtime][:user]} with #{@best[:runtime][:value] * 1000} milliseconds at submission " \ |
|
||
|
17 | - = link_to("#" + @best[:runtime][:sub_id].to_s, controller: 'graders', action: 'submission', id:@best[:runtime][:sub_id]) |
|
||
|
18 | - %br/ |
|
||
|
19 | - %b Best Memory Usage: |
|
||
|
20 | - = " by #{@best[:memory][:user]} with #{@best[:memory][:value]} kbytes at submission " |
|
||
|
21 | - = link_to("#" + @best[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id:@best[:memory][:sub_id]) |
|
||
|
22 | - %br/ |
|
||
|
23 | - %b Shortest Code: |
|
||
|
24 | - = " by #{@best[:length][:user]} with #{@best[:length][:value]} at submission " |
|
||
|
25 | - = link_to("#" + @best[:length][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:length][:sub_id]) |
|
||
|
26 | - %br/ |
|
||
|
27 | - %b First solver: |
|
||
|
28 | - = " by #{@best[:first][:user]} is the first solver on #{@best[:first][:value]} at submission " |
|
||
|
29 | - = link_to("#" + @best[:first][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:first][:sub_id]) |
|
||
|
30 | - %br/ |
|
||
|
31 |
|
21 | ||
|
32 |
|
22 | ||
|
33 | - %p |
|
||
|
34 | - This counts only for submission with 100% score <br/> |
|
||
|
35 | - Right now, java is excluded from memory usage competition. (Because it always uses 2GB memory...) |
|
||
|
36 | - |
|
||
|
37 | - %h2 By language |
|
||
|
38 | - |
|
||
|
39 | - %table.info |
|
||
|
40 | - %thead |
|
||
|
41 | - %tr.info-head |
|
||
|
42 | - %th Language |
|
||
|
43 | - %th Best runtime (ms) |
|
||
|
44 | - %th Best memory (kbytes) |
|
||
|
45 | - %th Shortest Code (bytes) |
|
||
|
46 | - %th First solver |
|
||
|
47 | - %tbody |
|
||
|
48 | - - @by_lang.each do |lang,value| |
|
||
|
49 | - %tr{class: cycle('info-even','info-odd')} |
|
||
|
50 | - %td= lang |
|
||
|
51 | - %td |
|
||
|
52 | - = "#{value[:runtime][:user]} (#{(value[:runtime][:value] * 1000).to_i} @" |
|
||
|
53 | - = "#{link_to("#" + value[:runtime][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:runtime][:sub_id])} )".html_safe |
|
||
|
54 | - %td |
|
||
|
55 | - = "#{value[:memory][:user]} (#{value[:memory][:value]} @" |
|
||
|
56 | - = "#{link_to("#" + value[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:memory][:sub_id])} )".html_safe |
|
||
|
57 | - %td |
|
||
|
58 | - = "#{value[:length][:user]} (#{value[:length][:value]} @" |
|
||
|
59 | - = "#{link_to("#" + value[:length][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:length][:sub_id])} )".html_safe |
|
||
|
60 | - %td |
|
||
|
61 | - = "#{value[:first][:user]} (#{value[:first][:value]} @" |
|
||
|
62 | - = "#{link_to("#" + value[:first][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:first][:sub_id])} )".html_safe |
|
||
|
63 | - |
|
||
|
64 | - - else |
|
||
|
65 | - %h3 No submissions |
|
@@ -51,18 +51,25 | |||||
|
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 => ' |
|
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 => 'If true, any user can access hall of fame page.' |
|
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', |
You need to be logged in to leave comments.
Login now