Description:
make report max_score remember user options
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r647:bb242b3ef68d - - 3 files changed: 12 inserted, 10 deleted
@@ -13,67 +13,69 | |||||
|
13 | } |
|
13 | } |
|
14 |
|
14 | ||
|
15 | def max_score |
|
15 | def max_score |
|
16 | end |
|
16 | end |
|
17 |
|
17 | ||
|
18 | def current_score |
|
18 | def current_score |
|
19 | @problems = Problem.available_problems |
|
19 | @problems = Problem.available_problems |
|
20 | @users = User.includes(:contests).includes(:contest_stat).where(enabled: true) |
|
20 | @users = User.includes(:contests).includes(:contest_stat).where(enabled: true) |
|
21 | @scorearray = calculate_max_score(@problems, @users,0,0,true) |
|
21 | @scorearray = calculate_max_score(@problems, @users,0,0,true) |
|
22 |
|
22 | ||
|
23 | #rencer accordingly |
|
23 | #rencer accordingly |
|
24 | if params[:button] == 'download' then |
|
24 | if params[:button] == 'download' then |
|
25 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
25 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
26 | send_data csv, filename: 'max_score.csv' |
|
26 | send_data csv, filename: 'max_score.csv' |
|
27 | else |
|
27 | else |
|
28 | #render template: 'user_admin/user_stat' |
|
28 | #render template: 'user_admin/user_stat' |
|
29 | render 'current_score' |
|
29 | render 'current_score' |
|
30 | end |
|
30 | end |
|
31 | end |
|
31 | end |
|
32 |
|
32 | ||
|
33 | def show_max_score |
|
33 | def show_max_score |
|
34 | #process parameters |
|
34 | #process parameters |
|
35 | #problems |
|
35 | #problems |
|
36 | @problems = [] |
|
36 | @problems = [] |
|
37 |
- params[:problem_id] |
|
37 | + if params[:problem_id] |
|
38 | - next unless id.strip != "" |
|
38 | + params[:problem_id].each do |id| |
|
39 | - pid = Problem.find_by_id(id.to_i) |
|
39 | + next unless id.strip != "" |
|
40 | - @problems << pid if pid |
|
40 | + pid = Problem.find_by_id(id.to_i) |
|
|
41 | + @problems << pid if pid | ||
|
|
42 | + end | ||
|
41 | end |
|
43 | end |
|
42 |
|
44 | ||
|
43 | #users |
|
45 | #users |
|
44 | @users = if params[:user] == "all" then |
|
46 | @users = if params[:user] == "all" then |
|
45 | User.includes(:contests).includes(:contest_stat) |
|
47 | User.includes(:contests).includes(:contest_stat) |
|
46 | else |
|
48 | else |
|
47 | User.includes(:contests).includes(:contest_stat).where(enabled: true) |
|
49 | User.includes(:contests).includes(:contest_stat).where(enabled: true) |
|
48 | end |
|
50 | end |
|
49 |
|
51 | ||
|
50 | #set up range from param |
|
52 | #set up range from param |
|
51 | - since_id = params.fetch(:from_id, 0).to_i |
|
53 | + @since_id = params.fetch(:from_id, 0).to_i |
|
52 | - until_id = params.fetch(:to_id, 0).to_i |
|
54 | + @until_id = params.fetch(:to_id, 0).to_i |
|
53 |
|
55 | ||
|
54 | #calculate the routine |
|
56 | #calculate the routine |
|
55 | - @scorearray = calculate_max_score(@problems, @users,since_id,until_id) |
|
57 | + @scorearray = calculate_max_score(@problems, @users, @since_id, @until_id) |
|
56 |
|
58 | ||
|
57 | #rencer accordingly |
|
59 | #rencer accordingly |
|
58 | if params[:button] == 'download' then |
|
60 | if params[:button] == 'download' then |
|
59 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
61 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
60 | send_data csv, filename: 'max_score.csv' |
|
62 | send_data csv, filename: 'max_score.csv' |
|
61 | else |
|
63 | else |
|
62 | #render template: 'user_admin/user_stat' |
|
64 | #render template: 'user_admin/user_stat' |
|
63 | render 'max_score' |
|
65 | render 'max_score' |
|
64 | end |
|
66 | end |
|
65 |
|
67 | ||
|
66 | end |
|
68 | end |
|
67 |
|
69 | ||
|
68 | def score |
|
70 | def score |
|
69 | if params[:commit] == 'download csv' |
|
71 | if params[:commit] == 'download csv' |
|
70 | @problems = Problem.all |
|
72 | @problems = Problem.all |
|
71 | else |
|
73 | else |
|
72 | @problems = Problem.available_problems |
|
74 | @problems = Problem.available_problems |
|
73 | end |
|
75 | end |
|
74 | @users = User.includes(:contests, :contest_stat).where(enabled: true) |
|
76 | @users = User.includes(:contests, :contest_stat).where(enabled: true) |
|
75 | @scorearray = Array.new |
|
77 | @scorearray = Array.new |
|
76 | @users.each do |u| |
|
78 | @users.each do |u| |
|
77 | ustat = Array.new |
|
79 | ustat = Array.new |
|
78 | ustat[0] = u |
|
80 | ustat[0] = u |
|
79 | @problems.each do |p| |
|
81 | @problems.each do |p| |
@@ -1,49 +1,49 | |||||
|
1 | %h1 Maximum score |
|
1 | %h1 Maximum score |
|
2 |
|
2 | ||
|
3 | = form_tag report_show_max_score_path |
|
3 | = form_tag report_show_max_score_path |
|
4 | .row |
|
4 | .row |
|
5 | .col-md-4 |
|
5 | .col-md-4 |
|
6 | .panel.panel-primary |
|
6 | .panel.panel-primary |
|
7 | .panel-heading |
|
7 | .panel-heading |
|
8 | Problems |
|
8 | Problems |
|
9 | .panel-body |
|
9 | .panel-body |
|
10 | %p |
|
10 | %p |
|
11 | Select problem(s) that we wish to know the score. |
|
11 | Select problem(s) that we wish to know the score. |
|
12 | = label_tag :problem_id, "Problems" |
|
12 | = label_tag :problem_id, "Problems" |
|
13 | = select_tag 'problem_id[]', |
|
13 | = select_tag 'problem_id[]', |
|
14 | options_for_select(Problem.all.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]},params[:problem_id]), |
|
14 | options_for_select(Problem.all.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]},params[:problem_id]), |
|
15 | { class: 'select2 form-control', multiple: "true" } |
|
15 | { class: 'select2 form-control', multiple: "true" } |
|
16 | .col-md-4 |
|
16 | .col-md-4 |
|
17 | .panel.panel-primary |
|
17 | .panel.panel-primary |
|
18 | .panel-heading |
|
18 | .panel-heading |
|
19 | Submission range |
|
19 | Submission range |
|
20 | .panel-body |
|
20 | .panel-body |
|
21 | %p |
|
21 | %p |
|
22 | Input minimum and maximum range of submission ID that should be included. A blank value for min and max means -1 and infinity, respectively. |
|
22 | Input minimum and maximum range of submission ID that should be included. A blank value for min and max means -1 and infinity, respectively. |
|
23 | .form-group |
|
23 | .form-group |
|
24 | = label_tag :from, "Min" |
|
24 | = label_tag :from, "Min" |
|
25 |
- = text_field_tag 'from_id', |
|
25 | + = text_field_tag 'from_id', @since_id, class: "form-control" |
|
26 | .form-group |
|
26 | .form-group |
|
27 | = label_tag :from, "Max" |
|
27 | = label_tag :from, "Max" |
|
28 | - = text_field_tag 'to_id', nil, class: "form-control" |
|
28 | + = text_field_tag 'to_id', @until_id, class: "form-control" |
|
29 | .col-md-4 |
|
29 | .col-md-4 |
|
30 | .panel.panel-primary |
|
30 | .panel.panel-primary |
|
31 | .panel-heading |
|
31 | .panel-heading |
|
32 | Users |
|
32 | Users |
|
33 | .panel-body |
|
33 | .panel-body |
|
34 | .radio |
|
34 | .radio |
|
35 | %label |
|
35 | %label |
|
36 | = radio_button_tag 'users', 'all', true |
|
36 | = radio_button_tag 'users', 'all', true |
|
37 | All users |
|
37 | All users |
|
38 | .radio |
|
38 | .radio |
|
39 | %label |
|
39 | %label |
|
40 | = radio_button_tag 'users', 'enabled' |
|
40 | = radio_button_tag 'users', 'enabled' |
|
41 | Only enabled users |
|
41 | Only enabled users |
|
42 | .row |
|
42 | .row |
|
43 | .col-md-12 |
|
43 | .col-md-12 |
|
44 | = button_tag 'Show', class: "btn btn-primary btn-large", value: "show" |
|
44 | = button_tag 'Show', class: "btn btn-primary btn-large", value: "show" |
|
45 | = button_tag 'Download CSV', class: "btn btn-primary btn-large", value: "download" |
|
45 | = button_tag 'Download CSV', class: "btn btn-primary btn-large", value: "download" |
|
46 |
|
46 | ||
|
47 | - if @scorearray |
|
47 | - if @scorearray |
|
48 | %h2 Result |
|
48 | %h2 Result |
|
49 | =render "score_table" |
|
49 | =render "score_table" |
@@ -1,2 +1,2 | |||||
|
1 | :plain |
|
1 | :plain |
|
2 | - $("body").prepend("<div class=\"alert alert-info\"> Submission #{@submission.id}'s task status has been chaned to \"#{@task.status_str}\" </div>") |
|
2 | + $("body").prepend("<div class=\"alert alert-info\"> Submission #{@submission.id}'s task status has been changed to \"#{@task.status_str}\". It will be re-judged soon. </div>") |
You need to be logged in to leave comments.
Login now