diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -159,7 +159,6 @@ #stat summary range =65 @histogram = { data: Array.new(range,0), summary: {} } - @histogram[:data] = Array.new(range,0) user = Hash.new(0) @submissions.find_each do |sub| d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 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 @@ -111,7 +111,6 @@ range =65 @histogram = { data: Array.new(range,0), summary: {} } - @histogram[:data] = Array.new(range,0) @summary = {count: 0, solve: 0, attempt: 0} user = Hash.new(0) Submission.where(problem_id: @problem.id).find_each do |sub| diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -111,7 +111,25 @@ def profile @user = User.find(params[:id]) - @submission = Submission.where(user_id: params[:id]).all + @submission = Submission.includes(:problem).where(user_id: params[:id]) + + range = 120 + @histogram = { data: Array.new(range,0), summary: {} } + @summary = {count: 0, solve: 0, attempt: 0} + problem = Hash.new(0) + + @submission.find_each do |sub| + #histogram + d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 + @histogram[:data][d.to_i] += 1 if d < range + + @summary[:count] += 1 + problem[sub.problem] = [problem[sub.problem], (sub.points >= sub.problem.full_score) ? 1 : 0].max + end + + @histogram[:summary][:max] = [@histogram[:data].max,1].max + @summary[:attempt] = problem.count + problem.each_value { |v| @summary[:solve] += 1 if v == 1 } end protected diff --git a/app/views/application/_bar_graph.html.haml b/app/views/application/_bar_graph.html.haml --- a/app/views/application/_bar_graph.html.haml +++ b/app/views/application/_bar_graph.html.haml @@ -18,7 +18,7 @@ font-size:5px; } -%div{style: "position: relative; width: #{graph_width}px; height: 150px; background-color:#fff;" } +%div{style: "position: relative; width: #{graph_width}px; height: 125px; background-color:#fff;" } //draw background - histogram[:data].each_index do |i| - height = histogram[:data][i] * graph_height / histogram[:summary][:max] diff --git a/app/views/report/_task_hof.html.haml b/app/views/report/_task_hof.html.haml --- a/app/views/report/_task_hof.html.haml +++ b/app/views/report/_task_hof.html.haml @@ -1,8 +1,39 @@ +- content_for :header do + = javascript_include_tag 'local_jquery' + +:javascript + $(document).ready( function() { + $("#mem_remark").hover( function() { + $("#mem_remark_box").show(); + }, function() { + $("#mem_remark_box").hide(); + }); + }); + alert("hahaha"); :css .hof_user { color: orangered; font-style: italic; } .hof_language { color: green; font-style: italic; } .hof_value { color: deeppink;font-style: italic; } .info_param { font-weight: bold;text-align: right; } + .tooltip { + font-family: Verdana,sans-serif; + font-weight: normal; + text-align: left; + font-size: 1.0em; + color: black; + line-height: 1.1; + display: none; + min-width: 20em; + position: absolute; + left: 25px; + bottom: 5px; + border: 1px solid; + padding: 5px; + background-color: #FFF; + word-wrap: break-word; + z-index: 9999; + overflow: auto; + } %h1 (#{Problem.find(params[:id]).name}) #{Problem.find(params[:id]).full_name} @@ -30,7 +61,13 @@ = link_to("#" + @best[:runtime][:sub_id].to_s, controller: 'graders', action: 'submission', id:@best[:runtime][:sub_id]) %tr{class: cycle('info-even','info-odd')} - %td.info_param Best Memory Usage + %td.info_param + Best Memory Usage + %sup{ id: "mem_remark", style: "position:relative; color: blue;"} + [?] + %span.tooltip#mem_remark_box + This counts only for submission with 100% score. + Right now, java is excluded from memory usage competition. (Because it always uses 2GB memory...) %td by #{link_to @best[:memory][:user], controller:'users', action:'profile', id:@best[:memory][:user_id]} using #{@best[:memory][:lang]} @@ -56,11 +93,6 @@ at submission = link_to("#" + @best[:first][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:first][:sub_id]) - -%p - This counts only for submission with 100% score
- Right now, java is excluded from memory usage competition. (Because it always uses 2GB memory...) - - if @best %h2 By language diff --git a/app/views/users/profile.html.haml b/app/views/users/profile.html.haml --- a/app/views/users/profile.html.haml +++ b/app/views/users/profile.html.haml @@ -1,9 +1,9 @@ - content_for :header do = javascript_include_tag 'local_jquery' -%script{:type=>"text/javascript"} +:javascript $(function () { - $('#submission_table').tablesorter({widgets: ['zebra']}); + $('#submission_table').tablesorter({widgets: ['zebra']}); }); :css @@ -11,16 +11,30 @@ font-family: Droid Sans Mono,Consolas, monospace, mono, Courier New, Courier; } -%h1= @user.full_name + ' Profile' +%h1= @user.full_name -%h2 Basic info Login: #{@user.login}
Full name: #{@user.full_name}
%h2 Problem Stat +%table.info + %thead + %tr.info-head + %th Stat + %th Value + %tbody + %tr{class: cycle('info-even','info-odd')} + %td.info_param Submissions + %td= @summary[:count] + %tr{class: cycle('info-even','info-odd')} + %td.info_param Solved/Attempted Problem + %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%) -%h2 Submissions +%h2 Submission History + +=render partial: 'application/bar_graph', locals: {histogram: @histogram, param: {bar_width: 7}} + %table.tablesorter-cafe#submission_table %thead