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: 71 inserted, 19 deleted

new file 100644
@@ -1,97 +1,106
1 1 class ReportController < ApplicationController
2 2
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 show_max_score
15 + def max_score
16 16 end
17 17
18 - def get_max_score
19 - #process list of problems
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)
25 + end
20 26
21 - #process submission range
22 - if params[:commit] == 'download csv'
23 - @problems = Problem.all
24 - else
25 - @problems = Problem.find_available_problems
26 - end
27 - @users = User.find(:all, :include => [:contests, :contest_stat])
27 + #users
28 + @users = if params[:user] == "all" then
29 + User.find(:all, :include => [:contests, :contest_stat])
30 + else
31 + User.includes(:contests).includes(:contest_stat).where(enabled: true)
32 + end
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
62 71 @users.each do |u|
63 72 ustat = Array.new
64 73 ustat[0] = u
65 74 @problems.each do |p|
66 75 sub = Submission.find_last_by_user_and_problem(u.id,p.id)
67 76 if (sub!=nil) and (sub.points!=nil) and p and p.full_score
68 77 ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
69 78 else
70 79 ustat << [0,false]
71 80 end
72 81 end
73 82 @scorearray << ustat
74 83 end
75 84 if params[:commit] == 'download csv' then
76 85 csv = gen_csv_from_scorearray(@scorearray,@problems)
77 86 send_data csv, filename: 'last_score.csv'
78 87 else
79 88 render template: 'user_admin/user_stat'
80 89 end
81 90
82 91 end
83 92
84 93 def login_stat
85 94 @logins = Array.new
86 95
87 96 date_and_time = '%Y-%m-%d %H:%M'
88 97 begin
89 98 md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
90 99 @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i)
91 100 rescue
92 101 @since_time = DateTime.new(1000,1,1)
93 102 end
94 103 begin
95 104 md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
96 105 @until_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i)
97 106 rescue
@@ -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"
@@ -7,61 +7,62
7 7
8 8 resources :sites
9 9
10 10 resources :announcements do
11 11 member do
12 12 get 'toggle','toggle_front'
13 13 end
14 14 end
15 15
16 16 resources :problems do
17 17 member do
18 18 get 'toggle'
19 19 get 'toggle_test'
20 20 end
21 21 collection do
22 22 get 'turn_all_off'
23 23 get 'turn_all_on'
24 24 get 'import'
25 25 get 'manage'
26 26 end
27 27 end
28 28
29 29 resources :grader_configuration, controller: 'configurations'
30 30
31 31 resources :users do
32 32 member do
33 33 get 'toggle_activate', 'toggle_enable'
34 34 end
35 35 end
36 36
37 37 #source code edit
38 38 get 'sources/direct_edit/:pid', to: 'sources#direct_edit', as: 'direct_edit'
39 39 get 'sources/direct_edit_submission/:sid', to: 'sources#direct_edit_submission', as: 'direct_edit_submission'
40 40 get 'sources/get_latest_submission_status/:uid/:pid', to: 'sources#get_latest_submission_status', as: 'get_latest_submission_status'
41 41
42 42
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)'
67 68 end
You need to be logged in to leave comments. Login now