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 | 4 | SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode' |
|
5 | 5 | |
|
6 | 6 | def admin_authorization |
|
7 | 7 | return false unless authenticate |
|
8 | 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 | 15 | end |
|
11 | 16 | |
|
12 | 17 | def authorization_by_roles(allowed_roles) |
|
13 | 18 | return false unless authenticate |
|
14 | 19 | user = User.find(session[:user_id]) |
|
15 | 20 | unless user.roles.detect { |role| allowed_roles.member?(role.name) } |
@@ -1,9 +1,18 | |||
|
1 | 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 | 14 | verify :method => :post, :only => ['clear_all', |
|
6 | 15 | 'start_exam', |
|
7 | 16 | 'start_grading', |
|
8 | 17 | 'stop_all', |
|
9 | 18 | 'clear_terminated'], |
@@ -1,13 +1,13 | |||
|
1 | 1 | class ReportController < ApplicationController |
|
2 | 2 | |
|
3 | 3 | before_filter :admin_authorization, only: [:login_stat,:submission_stat] |
|
4 | - before_filter { |c| | |
|
4 | + before_filter(only: [:problem_hof]) { |c| | |
|
5 | 5 | return false unless authenticate |
|
6 | 6 | |
|
7 | - if GraderConfiguration["system.hall_of_fame_available"] | |
|
7 | + if GraderConfiguration["right.user_view_submission"] | |
|
8 | 8 | return true; |
|
9 | 9 | end |
|
10 | 10 | |
|
11 | 11 | admin_authorization |
|
12 | 12 | } |
|
13 | 13 | |
@@ -153,33 +153,33 | |||
|
153 | 153 | end |
|
154 | 154 | end |
|
155 | 155 | |
|
156 | 156 | #process user_id |
|
157 | 157 | @by_lang.each do |lang,prop| |
|
158 | 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 | 160 | end |
|
161 | 161 | end |
|
162 | 162 | |
|
163 | 163 | #sum into best |
|
164 | 164 | if @by_lang and @by_lang.first |
|
165 | 165 | @best = @by_lang.first[1] |
|
166 | 166 | @by_lang.each do |lang,prop| |
|
167 | - if @best[:runtime][:value] > prop[:runtime][:value] | |
|
167 | + if @best[:runtime][:value] >= prop[:runtime][:value] | |
|
168 | 168 | @best[:runtime] = prop[:runtime] |
|
169 | 169 | @best[:runtime][:lang] = lang |
|
170 | 170 | end |
|
171 | - if @best[:memory][:value] > prop[:memory][:value] | |
|
171 | + if @best[:memory][:value] >= prop[:memory][:value] | |
|
172 | 172 | @best[:memory] = prop[:memory] |
|
173 | 173 | @best[:memory][:lang] = lang |
|
174 | 174 | end |
|
175 | - if @best[:length][:value] > prop[:length][:value] | |
|
175 | + if @best[:length][:value] >= prop[:length][:value] | |
|
176 | 176 | @best[:length] = prop[:length] |
|
177 | 177 | @best[:length][:lang] = lang |
|
178 | 178 | end |
|
179 | - if @best[:first][:value] > prop[:first][:value] | |
|
179 | + if @best[:first][:value] >= prop[:first][:value] | |
|
180 | 180 | @best[:first] = prop[:first] |
|
181 | 181 | @best[:first][:lang] = lang |
|
182 | 182 | end |
|
183 | 183 | end |
|
184 | 184 | end |
|
185 | 185 | end |
@@ -28,13 +28,13 | |||
|
28 | 28 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
29 | 29 | append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list' |
|
30 | 30 | append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' |
|
31 | 31 | append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' |
|
32 | 32 | end |
|
33 | 33 | |
|
34 |
- if GraderConfiguration[' |
|
|
34 | + if GraderConfiguration['right.user_hall_of_fame'] | |
|
35 | 35 | append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof' |
|
36 | 36 | end |
|
37 | 37 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
38 | 38 | |
|
39 | 39 | if GraderConfiguration['system.user_setting_enabled'] |
|
40 | 40 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
@@ -2,13 +2,13 | |||
|
2 | 2 | = @css_style |
|
3 | 3 | |
|
4 | 4 | %h1= "Submission: #{@submission.id}" |
|
5 | 5 | |
|
6 | 6 | %p |
|
7 | 7 | User: |
|
8 | - = "#{@submission.user.login}" | |
|
8 | + = "(#{@submission.user.login}) #{@submission.user.full_name}" | |
|
9 | 9 | %br/ |
|
10 | 10 | Problem: |
|
11 | 11 | - if @submission.problem!=nil |
|
12 | 12 | = "#{@submission.problem.full_name}" |
|
13 | 13 | - else |
|
14 | 14 | = "(n/a)" |
@@ -4,16 +4,14 | |||
|
4 | 4 | %script{:type=>"text/javascript"} |
|
5 | 5 | $(function () { |
|
6 | 6 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
7 | 7 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
8 | 8 | }); |
|
9 | 9 | |
|
10 | - | |
|
11 | 10 | %h1 Login status |
|
12 | 11 | |
|
13 | - | |
|
14 | 12 | =render partial: 'report_menu' |
|
15 | 13 | =render partial: 'date_range', locals: {param_text: 'Login date range:', title: 'Query login stat in the range' } |
|
16 | 14 | |
|
17 | 15 | %table.info |
|
18 | 16 | %thead |
|
19 | 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 | 9 | %h1 Tasks Hall of Fame |
|
2 | - | |
|
3 | 10 | .task-menu |
|
4 | 11 | Tasks |
|
5 | 12 | %br/ |
|
6 | 13 | - @problems.each do |prob| |
|
7 | 14 | = link_to( "[#{prob.name}]", {id: prob.id}) |
|
8 | 15 | |
|
9 | - | |
|
10 | - | |
|
11 | - | |
|
12 | - %h2 Overall | |
|
13 | - | |
|
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/ | |
|
16 | + - unless params[:id] | |
|
17 | + /=render partial: 'all_time_hof' | |
|
18 | + Please select a problem. | |
|
19 | + - else | |
|
20 | + =render partial: 'task_hof' | |
|
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 | 51 | :value_type => 'boolean', |
|
52 | 52 | :default_value => 'false', |
|
53 | 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 | 58 | :value_type => 'boolean', |
|
59 | 59 | :default_value => 'false', |
|
60 | 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 | 70 | # If Configuration['system.online_registration'] is true, the |
|
64 | 71 | # system allows online registration, and will use these |
|
65 | 72 | # information for sending confirmation emails. |
|
66 | 73 | { |
|
67 | 74 | :key => 'system.online_registration.smtp', |
|
68 | 75 | :value_type => 'string', |
You need to be logged in to leave comments.
Login now