Description:
prepare for better hall of fame
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r425:b86f327e0d75 - - 8 files changed: 45 inserted, 69 deleted

@@ -6,7 +6,12
6 6 def admin_authorization
7 7 return false unless authenticate
8 8 user = User.find(session[:user_id], :include => ['roles'])
9 + unless user.admin?
10 + flash[:notice] = 'You are not authorized to view the page you requested'
9 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)
@@ -1,6 +1,15
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',
@@ -1,10 +1,10
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
@@ -156,7 +156,7
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]).login : "(NULL)"
159 + v[:user] = User.exists?(v[:user_id]) ? User.find(v[:user_id]).full_name : "(NULL)"
160 160 end
161 161 end
162 162
@@ -164,19 +164,19
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
@@ -31,7 +31,7
31 31 append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
32 32 end
33 33
34 - if GraderConfiguration['system.hall_of_fame_available']
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'
@@ -5,7 +5,7
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
@@ -7,10 +7,8
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
@@ -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
@@ -54,12 +54,19
54 54 },
55 55
56 56 {
57 - :key => 'system.hall_of_fame_available',
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.
You need to be logged in to leave comments. Login now