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
501
501
end
502
502
503
503
# 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 }
506
505
# }
507
506
def exercise_group_completion_ratio_for_user ( user )
508
507
# TODO: clean up exercise group discovery
@@ -515,16 +514,19 @@ def exercise_group_completion_ratio_for_user(user)
515
514
next if available_points . empty?
516
515
517
516
sql = <<-EOS
518
- SELECT COUNT(*)
517
+ SELECT awarded_after_soft_deadline, COUNT(*)
519
518
FROM awarded_points
520
519
WHERE course_id = #{ conn . quote ( id ) } AND
521
520
name IN (#{ available_points . map { |ap | conn . quote ( ap ) } . join ( ',' ) } ) AND
522
521
user_id = #{ conn . quote ( user . id ) }
523
- GROUP BY user_id
522
+ GROUP BY awarded_after_soft_deadline
524
523
EOS
525
524
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 [ "f" ] . nil? ? 0 : res [ "f" ] . to_i ,
528
+ late : res [ "t" ] . nil? ? 0 : res [ "t" ] . to_i ,
529
+ }
528
530
end
529
531
end
530
532
Original file line number Diff line number Diff line change 47
47
</ div >
48
48
</ div >
49
49
<% 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 | %>
51
51
< br >
52
52
< span class ="progress-label "> Awarded points for <%= group %> </ span >
53
53
< 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 ) %> %
57
58
</ div >
58
59
<% end %>
59
60
</ div >
You can’t perform that action at this time.
0 commit comments