File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -501,8 +501,7 @@ def exercise_group_completion_by_user
501501 end
502502
503503 # Returns a hash of exercise group => {
504- # :available_points => number of available points,
505- # :points_by_user => {user_id => number_of_points}
504+ # { awarded: double, late: double }
506505 # }
507506 def exercise_group_completion_ratio_for_user ( user )
508507 # TODO: clean up exercise group discovery
@@ -515,16 +514,19 @@ def exercise_group_completion_ratio_for_user(user)
515514 next if available_points . empty?
516515
517516 sql = <<-EOS
518- SELECT COUNT(*)
517+ SELECT awarded_after_soft_deadline, COUNT(*)
519518 FROM awarded_points
520519 WHERE course_id = #{ conn . quote ( id ) } AND
521520 name IN (#{ available_points . map { |ap | conn . quote ( ap ) } . join ( ',' ) } ) AND
522521 user_id = #{ conn . quote ( user . id ) }
523- GROUP BY user_id
522+ GROUP BY awarded_after_soft_deadline
524523 EOS
525524
526- res = conn . select_rows ( sql )
527- result [ group ] = res . empty? ? 0 : res [ 0 ] [ 0 ] . to_f / available_points . length
525+ res = conn . execute ( sql ) . values . to_h
526+ result [ group ] = {
527+ awarded : res . empty? ? 0 : res [ "f" ] ,
528+ late : res . empty? ? 0 : res [ "t" ] ,
529+ }
528530 end
529531 end
530532
Original file line number Diff line number Diff line change 4747 </ div >
4848 </ div >
4949 <% if @group_completion_ratios [ course . id ] %>
50- <% @group_completion_ratios [ course . id ] . each do |group , ratio | %>
50+ <% @group_completion_ratios [ course . id ] . each do |group , ratios | %>
5151 < br >
5252 < span class ="progress-label "> Awarded points for <%= group %> </ span >
5353 < div class ="progress course-points-progress ">
54- <% unless ratio . zero? %>
55- < div class ="progress-bar bg-info " role ="progressbar " style ="width: <%= ratio * 100 %> % " aria-valuenow ="<%= ratio * 100 %> " aria-valuemin ="0 " aria-valuemax ="100 ">
56- <%= sprintf ( "%.0f" , ratio * 100 ) %> %
54+ <% unless ( ratios [ :awarded ] + ratios [ :late ] ) . zero? %>
55+ <% calculated_ratio = ratios [ :awarded ] + ratios [ :late ] * course . soft_deadline_point_multiplier %>
56+ < div class ="progress-bar bg-info " role ="progressbar " style ="width: <%= calculated_ratio * 100 %> % " aria-valuenow ="<%= calculated_ratio * 100 %> " aria-valuemin ="0 " aria-valuemax ="100 ">
57+ <%= sprintf ( "%.0f" , calculated_ratio * 100 ) %> %
5758 </ div >
5859 <% end %>
5960 </ div >
You can’t perform that action at this time.
0 commit comments