Description:
add authorization for show max score
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r595:ad86e593f5b0 - - 1 file changed: 1 inserted, 1 deleted
@@ -1,51 +1,51 | |||
|
1 | 1 | class ReportController < ApplicationController |
|
2 | 2 | |
|
3 | - before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize] | |
|
3 | + before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize, :show_max_score] | |
|
4 | 4 | |
|
5 | 5 | before_filter(only: [:problem_hof]) { |c| |
|
6 | 6 | return false unless authenticate |
|
7 | 7 | |
|
8 | 8 | if GraderConfiguration["right.user_view_submission"] |
|
9 | 9 | return true; |
|
10 | 10 | end |
|
11 | 11 | |
|
12 | 12 | admin_authorization |
|
13 | 13 | } |
|
14 | 14 | |
|
15 | 15 | def max_score |
|
16 | 16 | end |
|
17 | 17 | |
|
18 | 18 | def show_max_score |
|
19 | 19 | #process parameters |
|
20 | 20 | #problems |
|
21 | 21 | @problems = [] |
|
22 | 22 | params[:problem_id].each do |id| |
|
23 | 23 | next unless id.strip != "" |
|
24 | 24 | @problems << Problem.find(id.to_i) |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | 27 | #users |
|
28 | 28 | @users = if params[:user] == "all" then |
|
29 | 29 | User.find(:all, :include => [:contests, :contest_stat]) |
|
30 | 30 | else |
|
31 | 31 | User.includes(:contests).includes(:contest_stat).where(enabled: true) |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | #set up range from param |
|
35 | 35 | since_id = params.fetch(:min_id, 0).to_i |
|
36 | 36 | until_id = params.fetch(:max_id, 0).to_i |
|
37 | 37 | |
|
38 | 38 | #get data |
|
39 | 39 | @scorearray = Array.new |
|
40 | 40 | @users.each do |u| |
|
41 | 41 | ustat = Array.new |
|
42 | 42 | ustat[0] = u |
|
43 | 43 | @problems.each do |p| |
|
44 | 44 | max_points = 0 |
|
45 | 45 | Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub| |
|
46 | 46 | max_points = sub.points if sub and sub.points and (sub.points > max_points) |
|
47 | 47 | end |
|
48 | 48 | ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] |
|
49 | 49 | end |
|
50 | 50 | @scorearray << ustat |
|
51 | 51 | end |
You need to be logged in to leave comments.
Login now