Description:
- update show max score
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r594:ad5ce58ac280 - - 4 files changed: 71 inserted, 19 deleted
new file 100644 |
@@ -12,23 +12,31 | |||||
|
12 | admin_authorization |
|
12 | admin_authorization |
|
13 | } |
|
13 | } |
|
14 |
|
14 | ||
|
15 |
- def |
|
15 | + def max_score |
|
16 | end |
|
16 | end |
|
17 |
|
17 | ||
|
18 |
- def |
|
18 | + def show_max_score |
|
19 | - #process list of problems |
|
19 | + #process parameters |
|
|
20 | + #problems | ||
|
|
21 | + @problems = [] | ||
|
|
22 | + params[:problem_id].each do |id| | ||
|
|
23 | + next unless id.strip != "" | ||
|
|
24 | + @problems << Problem.find(id.to_i) | ||
|
|
25 | + end | ||
|
20 |
|
26 | ||
|
21 | - #process submission range |
|
27 | + #users |
|
22 | - if params[:commit] == 'download csv' |
|
28 | + @users = if params[:user] == "all" then |
|
23 | - @problems = Problem.all |
|
29 | + User.find(:all, :include => [:contests, :contest_stat]) |
|
24 | - else |
|
30 | + else |
|
25 | - @problems = Problem.find_available_problems |
|
31 | + User.includes(:contests).includes(:contest_stat).where(enabled: true) |
|
26 | - end |
|
32 | + end |
|
27 | - @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
33 | + |
|
|
34 | + #set up range from param | ||
|
|
35 | + since_id = params.fetch(:min_id, 0).to_i | ||
|
|
36 | + until_id = params.fetch(:max_id, 0).to_i | ||
|
|
37 | + | ||
|
|
38 | + #get data | ||
|
28 | @scorearray = Array.new |
|
39 | @scorearray = Array.new |
|
29 | - #set up range from param |
|
||
|
30 | - since_id = params.fetch(:since_id, 0).to_i |
|
||
|
31 | - until_id = params.fetch(:until_id, 0).to_i |
|
||
|
32 | @users.each do |u| |
|
40 | @users.each do |u| |
|
33 | ustat = Array.new |
|
41 | ustat = Array.new |
|
34 | ustat[0] = u |
|
42 | ustat[0] = u |
@@ -46,7 +54,8 | |||||
|
46 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
54 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
47 | send_data csv, filename: 'max_score.csv' |
|
55 | send_data csv, filename: 'max_score.csv' |
|
48 | else |
|
56 | else |
|
49 | - render template: 'user_admin/user_stat' |
|
57 | + #render template: 'user_admin/user_stat' |
|
|
58 | + render 'max_score' | ||
|
50 | end |
|
59 | end |
|
51 |
|
60 | ||
|
52 | end |
|
61 | end |
@@ -1,24 +1,30 | |||||
|
1 | %h1 Maximum score |
|
1 | %h1 Maximum score |
|
2 |
|
2 | ||
|
3 | - = form_tag report_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 | - = label_tag :problems, "Problems" |
|
10 | + %p |
|
11 | - = select 'problems', 'problem_id', [[(t 'main.specified_in_header'),'-1']] + Problem.all.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]}, {:selected => '-1'}, { class: 'select2 form-control' } |
|
11 | + Select problem(s) that we wish to know the score. |
|
|
12 | + = label_tag :problem_id, "Problems" | ||
|
|
13 | + = select_tag 'problem_id[]', | ||
|
|
14 | + options_for_select(Problem.all.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]}), | ||
|
|
15 | + { class: 'select2 form-control', multiple: "true" } | ||
|
12 | .col-md-4 |
|
16 | .col-md-4 |
|
13 | .panel.panel-primary |
|
17 | .panel.panel-primary |
|
14 | .panel-heading |
|
18 | .panel-heading |
|
15 | Submission range |
|
19 | Submission range |
|
16 | .panel-body |
|
20 | .panel-body |
|
|
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. | ||
|
17 | .form-group |
|
23 | .form-group |
|
18 |
- = label_tag :from, " |
|
24 | + = label_tag :from, "Min" |
|
19 | = text_field_tag 'from_id', nil, class: "form-control" |
|
25 | = text_field_tag 'from_id', nil, class: "form-control" |
|
20 | .form-group |
|
26 | .form-group |
|
21 |
- = label_tag :from, " |
|
27 | + = label_tag :from, "Max" |
|
22 | = text_field_tag 'to_id', nil, class: "form-control" |
|
28 | = text_field_tag 'to_id', nil, class: "form-control" |
|
23 | .col-md-4 |
|
29 | .col-md-4 |
|
24 | .panel.panel-primary |
|
30 | .panel.panel-primary |
@@ -37,6 +43,42 | |||||
|
37 | .col-md-12 |
|
43 | .col-md-12 |
|
38 | = button_tag 'Show', class: "btn btn-primary btn-large" |
|
44 | = button_tag 'Show', class: "btn btn-primary btn-large" |
|
39 | = button_tag 'Download CSV', class: "btn btn-primary btn-large" |
|
45 | = button_tag 'Download CSV', class: "btn btn-primary btn-large" |
|
|
46 | + | ||
|
|
47 | + - if @scorearray | ||
|
|
48 | + %h2 Result | ||
|
|
49 | + %table.table.sortable.table-striped.table-bordered.table-condensed | ||
|
|
50 | + %thead | ||
|
|
51 | + %tr | ||
|
|
52 | + %th Login | ||
|
|
53 | + %th Name | ||
|
|
54 | + %th Activated? | ||
|
|
55 | + %th Logged_in | ||
|
|
56 | + %th Contest(s) | ||
|
|
57 | + %th Remark | ||
|
|
58 | + - @problems.each do |p| | ||
|
|
59 | + %th.text-right= p.name | ||
|
|
60 | + %th.text-right Total | ||
|
|
61 | + %th.text-right Passed | ||
|
|
62 | + %tbody | ||
|
|
63 | + - @scorearray.each do |sc| | ||
|
|
64 | + %tr | ||
|
|
65 | + - total,num_passed = 0,0 | ||
|
|
66 | + - sc.each_index do |i| | ||
|
|
67 | + - if i == 0 | ||
|
|
68 | + %td= link_to sc[i].login, controller: 'users', action: 'profile', id: sc[i] | ||
|
|
69 | + %td= sc[i].full_name | ||
|
|
70 | + %td= sc[i].activated | ||
|
|
71 | + %td= sc[i].try(:contest_stat).try(:started_at) ? 'yes' : 'no' | ||
|
|
72 | + %td= sc[i].contests.collect {|c| c.name}.join(', ') | ||
|
|
73 | + %td= sc[i].remark | ||
|
|
74 | + - else | ||
|
|
75 | + %td.text-right= sc[i][0] | ||
|
|
76 | + - total += sc[i][0] | ||
|
|
77 | + - num_passed += 1 if sc[i][1] | ||
|
|
78 | + %td.text-right= total | ||
|
|
79 | + %td.text-right= num_passed | ||
|
|
80 | + :javascript | ||
|
|
81 | + $.bootstrapSortable(true,'reversed') | ||
|
40 | /.col-md-4.col-md-offset-1 |
|
82 | /.col-md-4.col-md-offset-1 |
|
41 | / = button_tag 'Show', class: "btn btn-primary btn-block" |
|
83 | / = button_tag 'Show', class: "btn btn-primary btn-block" |
|
42 | /.col-md-4.col-md-offset-2 |
|
84 | /.col-md-4.col-md-offset-2 |
@@ -52,6 +52,7 | |||||
|
52 | get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' |
|
52 | get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' |
|
53 | get "report/login" |
|
53 | get "report/login" |
|
54 | get 'report/max_score', to: 'report#max_score', as: 'report_max_score' |
|
54 | get 'report/max_score', to: 'report#max_score', as: 'report_max_score' |
|
|
55 | + post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score' | ||
|
55 |
|
56 | ||
|
56 | #grader |
|
57 | #grader |
|
57 | get 'graders/list', to: 'graders#list', as: 'grader_list' |
|
58 | get 'graders/list', to: 'graders#list', as: 'grader_list' |
You need to be logged in to leave comments.
Login now