Description:
put to master
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r720:debc8d9f3f74 - - 1 file changed: 1 inserted, 1 deleted
@@ -1,103 +1,103 | |||
|
1 | 1 | require 'csv' |
|
2 | 2 | |
|
3 | 3 | class ReportController < ApplicationController |
|
4 | 4 | |
|
5 | 5 | before_filter :authenticate |
|
6 | 6 | |
|
7 | - before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize, :show_max_score] | |
|
7 | + before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize, :show_max_score, :current_score] | |
|
8 | 8 | |
|
9 | 9 | before_filter(only: [:problem_hof]) { |c| |
|
10 | 10 | return false unless authenticate |
|
11 | 11 | |
|
12 | 12 | admin_authorization unless GraderConfiguration["right.user_view_submission"] |
|
13 | 13 | } |
|
14 | 14 | |
|
15 | 15 | def max_score |
|
16 | 16 | end |
|
17 | 17 | |
|
18 | 18 | def current_score |
|
19 | 19 | @problems = Problem.available_problems |
|
20 | 20 | @users = User.includes(:contests).includes(:contest_stat).where(enabled: true) |
|
21 | 21 | @scorearray = calculate_max_score(@problems, @users,0,0,true) |
|
22 | 22 | |
|
23 | 23 | #rencer accordingly |
|
24 | 24 | if params[:button] == 'download' then |
|
25 | 25 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
26 | 26 | send_data csv, filename: 'max_score.csv' |
|
27 | 27 | else |
|
28 | 28 | #render template: 'user_admin/user_stat' |
|
29 | 29 | render 'current_score' |
|
30 | 30 | end |
|
31 | 31 | end |
|
32 | 32 | |
|
33 | 33 | def show_max_score |
|
34 | 34 | #process parameters |
|
35 | 35 | #problems |
|
36 | 36 | @problems = [] |
|
37 | 37 | if params[:problem_id] |
|
38 | 38 | params[:problem_id].each do |id| |
|
39 | 39 | next unless id.strip != "" |
|
40 | 40 | pid = Problem.find_by_id(id.to_i) |
|
41 | 41 | @problems << pid if pid |
|
42 | 42 | end |
|
43 | 43 | end |
|
44 | 44 | |
|
45 | 45 | #users |
|
46 | 46 | @users = if params[:user] == "all" then |
|
47 | 47 | User.includes(:contests).includes(:contest_stat) |
|
48 | 48 | else |
|
49 | 49 | User.includes(:contests).includes(:contest_stat).where(enabled: true) |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | #set up range from param |
|
53 | 53 | @since_id = params.fetch(:from_id, 0).to_i |
|
54 | 54 | @until_id = params.fetch(:to_id, 0).to_i |
|
55 | 55 | @since_id = nil if @since_id == 0 |
|
56 | 56 | @until_id = nil if @until_id == 0 |
|
57 | 57 | |
|
58 | 58 | #calculate the routine |
|
59 | 59 | @scorearray = calculate_max_score(@problems, @users, @since_id, @until_id) |
|
60 | 60 | |
|
61 | 61 | #rencer accordingly |
|
62 | 62 | if params[:button] == 'download' then |
|
63 | 63 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
64 | 64 | send_data csv, filename: 'max_score.csv' |
|
65 | 65 | else |
|
66 | 66 | #render template: 'user_admin/user_stat' |
|
67 | 67 | render 'max_score' |
|
68 | 68 | end |
|
69 | 69 | |
|
70 | 70 | end |
|
71 | 71 | |
|
72 | 72 | def score |
|
73 | 73 | if params[:commit] == 'download csv' |
|
74 | 74 | @problems = Problem.all |
|
75 | 75 | else |
|
76 | 76 | @problems = Problem.available_problems |
|
77 | 77 | end |
|
78 | 78 | @users = User.includes(:contests, :contest_stat).where(enabled: true) |
|
79 | 79 | @scorearray = Array.new |
|
80 | 80 | @users.each do |u| |
|
81 | 81 | ustat = Array.new |
|
82 | 82 | ustat[0] = u |
|
83 | 83 | @problems.each do |p| |
|
84 | 84 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
85 | 85 | if (sub!=nil) and (sub.points!=nil) and p and p.full_score |
|
86 | 86 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
87 | 87 | else |
|
88 | 88 | ustat << [0,false] |
|
89 | 89 | end |
|
90 | 90 | end |
|
91 | 91 | @scorearray << ustat |
|
92 | 92 | end |
|
93 | 93 | if params[:commit] == 'download csv' then |
|
94 | 94 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
95 | 95 | send_data csv, filename: 'last_score.csv' |
|
96 | 96 | else |
|
97 | 97 | render template: 'user_admin/user_stat' |
|
98 | 98 | end |
|
99 | 99 | |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | def login_stat |
|
103 | 103 | @logins = Array.new |
You need to be logged in to leave comments.
Login now