diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -215,4 +215,41 @@ @struggle = @struggle[0..50] end + + def multiple_login + #user with multiple IP + raw = Submission.joins(:user).joins(:problem).where("problems.available != 0").group("login,ip_address").order(:login) + last,count = 0,0 + first = 0 + @users = [] + raw.each do |r| + if last != r.user.login + count = 1 + last = r.user.login + first = r + else + @users << first if count == 1 + @users << r + count += 1 + end + end + + #IP with multiple user + raw = Submission.joins(:user).joins(:problem).where("problems.available != 0").group("login,ip_address").order(:ip_address) + last,count = 0,0 + first = 0 + @ip = [] + raw.each do |r| + if last != r.ip_address + count = 1 + last = r.ip_address + first = r + else + @ip << first if count == 1 + @ip << r + count += 1 + end + end + end + end diff --git a/app/controllers/user_admin_controller.rb b/app/controllers/user_admin_controller.rb --- a/app/controllers/user_admin_controller.rb +++ b/app/controllers/user_admin_controller.rb @@ -150,6 +150,12 @@ end @scorearray << ustat end + if params[:commit] == 'download csv' then + csv = gen_csv_from_scorearray(@scorearray,@problems) + send_data csv, filename: 'last_score.csv' + else + render template: 'user_admin/user_stat' + end end def user_stat_max diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -13,7 +13,7 @@ append_to menu_items, '[Problems]', 'problems', 'index' append_to menu_items, '[Users]', 'user_admin', 'index' append_to menu_items, '[Results]', 'user_admin', 'user_stat' - append_to menu_items, '[Report]', 'report', 'login_stat' + append_to menu_items, '[Report]', 'report', 'multiple_login' append_to menu_items, '[Graders]', 'graders', 'list' append_to menu_items, '[Contests]', 'contest_management', 'index' append_to menu_items, '[Sites]', 'sites', 'index' diff --git a/app/views/problems/stat.html.haml b/app/views/problems/stat.html.haml --- a/app/views/problems/stat.html.haml +++ b/app/views/problems/stat.html.haml @@ -34,6 +34,7 @@ %th Submitted_at %th Points %th comment + %th IP %tbody - row_odd,curr = true,'' - @submissions.each do |sub| @@ -46,6 +47,7 @@ %td= time_ago_in_words(sub.submitted_at) + " ago" %td= sub.points %td.fix-width= sub.grader_comment + %td= sub.ip_address - else No submission diff --git a/app/views/report/_report_menu.html.haml b/app/views/report/_report_menu.html.haml --- a/app/views/report/_report_menu.html.haml +++ b/app/views/report/_report_menu.html.haml @@ -5,3 +5,4 @@ = link_to '[Hall of Fame]', :action => 'problem_hof' = link_to '[Struggle]', :action => 'stuck' = link_to '[Login]', :action => 'login_stat' + = link_to '[Multiple Login]', :action => 'multiple_login' diff --git a/app/views/report/multiple_login.html.haml b/app/views/report/multiple_login.html.haml new file mode 100644 --- /dev/null +++ b/app/views/report/multiple_login.html.haml @@ -0,0 +1,37 @@ +- content_for :header do + = stylesheet_link_tag 'tablesorter-theme.cafe' + = javascript_include_tag 'local_jquery' + +%h1 Login status + +=render partial: 'report_menu' + +Checking for all submissions with the currently available problem + +%h2 Users with Multiple IP +%table.tablesorter-cafe#my_table + %thead + %tr + %th login + %th full name + %th IP + %tbody + - @users.each do |l| + %tr{class: cycle('info-even','info-odd')} + %td= link_to l.user.login, controller: 'users', action: 'profile', id: l[:id] + %td= l.user.full_name + %td= l[:ip_address] + +%h2 IP with multiple users +%table.tablesorter-cafe#my_table + %thead + %tr + %th IP + %th login + %th full name + %tbody + - @ip.each do |l| + %tr{class: cycle('info-even','info-odd')} + %td= l[:ip_address] + %td= link_to l.user.login, controller: 'users', action: 'profile', id: l[:id] + %td= l.user.full_name