Description:
- update show max score
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r594:ad5ce58ac280 - - 4 files changed: 69 inserted, 17 deleted

new file 100644
@@ -3,59 +3,68
3 3 before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize]
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 + def max_score
16 + end
17 +
15 18 def show_max_score
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)
16 25 end
17 26
18 - def get_max_score
19 - #process list of problems
20 -
21 - #process submission range
22 - if params[:commit] == 'download csv'
23 - @problems = Problem.all
27 + #users
28 + @users = if params[:user] == "all" then
29 + User.find(:all, :include => [:contests, :contest_stat])
24 30 else
25 - @problems = Problem.find_available_problems
31 + User.includes(:contests).includes(:contest_stat).where(enabled: true)
26 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 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 40 @users.each do |u|
33 41 ustat = Array.new
34 42 ustat[0] = u
35 43 @problems.each do |p|
36 44 max_points = 0
37 45 Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub|
38 46 max_points = sub.points if sub and sub.points and (sub.points > max_points)
39 47 end
40 48 ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)]
41 49 end
42 50 @scorearray << ustat
43 51 end
44 52
45 53 if params[:commit] == 'download csv' then
46 54 csv = gen_csv_from_scorearray(@scorearray,@problems)
47 55 send_data csv, filename: 'max_score.csv'
48 56 else
49 - render template: 'user_admin/user_stat'
57 + #render template: 'user_admin/user_stat'
58 + render 'max_score'
50 59 end
51 60
52 61 end
53 62
54 63 def score
55 64 if params[:commit] == 'download csv'
56 65 @problems = Problem.all
57 66 else
58 67 @problems = Problem.find_available_problems
59 68 end
60 69 @users = User.includes(:contests, :contest_stat).where(enabled: true) #find(:all, :include => [:contests, :contest_stat]).where(enabled: true)
61 70 @scorearray = Array.new
@@ -1,43 +1,85
1 1 %h1 Maximum score
2 2
3 - = form_tag report_max_score_path
3 + = form_tag report_show_max_score_path
4 4 .row
5 5 .col-md-4
6 6 .panel.panel-primary
7 7 .panel-heading
8 8 Problems
9 9 .panel-body
10 - = label_tag :problems, "Problems"
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' }
10 + %p
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 16 .col-md-4
13 17 .panel.panel-primary
14 18 .panel-heading
15 19 Submission range
16 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 23 .form-group
18 - = label_tag :from, "From"
24 + = label_tag :from, "Min"
19 25 = text_field_tag 'from_id', nil, class: "form-control"
20 26 .form-group
21 - = label_tag :from, "To"
27 + = label_tag :from, "Max"
22 28 = text_field_tag 'to_id', nil, class: "form-control"
23 29 .col-md-4
24 30 .panel.panel-primary
25 31 .panel-heading
26 32 Users
27 33 .panel-body
28 34 .radio
29 35 %label
30 36 = radio_button_tag 'users', 'all', true
31 37 All users
32 38 .radio
33 39 %label
34 40 = radio_button_tag 'users', 'enabled'
35 41 Only enabled users
36 42 .row
37 43 .col-md-12
38 44 = button_tag 'Show', class: "btn btn-primary btn-large"
39 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 82 /.col-md-4.col-md-offset-1
41 83 / = button_tag 'Show', class: "btn btn-primary btn-block"
42 84 /.col-md-4.col-md-offset-2
43 85 / = button_tag 'Download CSV', class: "btn btn-primary btn-block"
@@ -43,24 +43,25
43 43 match 'tasks/view/:file.:ext' => 'tasks#view'
44 44 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
45 45 match 'heartbeat/:id/edit' => 'heartbeat#edit'
46 46
47 47 #main
48 48 get "main/list"
49 49 get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
50 50
51 51 #report
52 52 get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof'
53 53 get "report/login"
54 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 57 #grader
57 58 get 'graders/list', to: 'graders#list', as: 'grader_list'
58 59
59 60
60 61 match 'heartbeat/:id/edit' => 'heartbeat#edit'
61 62
62 63 # See how all your routes lay out with "rake routes"
63 64
64 65 # This is a legacy wild controller route that's not recommended for RESTful applications.
65 66 # Note: This route will make all actions in every controller accessible via GET requests.
66 67 match ':controller(/:action(/:id))(.:format)'
You need to be logged in to leave comments. Login now