11require 'portable_csv'
22
33class ParticipantsController < ApplicationController
4+ include PointVisualisation
45 before_action :set_organization , only : [ :index ]
56
67 def index
@@ -61,8 +62,6 @@ def index
6162 def show
6263 @user = User . find ( params [ :id ] )
6364 authorize! :view_participant_information , @user
64- # TODO: bit ugly
65- @awarded_points = Hash [ AwardedPoint . where ( id : AwardedPoint . all_awarded ( @user ) ) . to_a . sort! . group_by ( &:course_id ) . map { |k , v | [ k , v . map ( &:name ) ] } ]
6665
6766 if current_user . administrator?
6867 add_breadcrumb 'Participants' , :participants_path
@@ -71,27 +70,7 @@ def show
7170 add_breadcrumb 'My stats' , participant_path ( @user )
7271 end
7372
74- @courses = [ ]
75- @missing_points = { }
76- @percent_completed = { }
77- @group_completion_ratios = { }
78- for course_id in @awarded_points . keys
79- course = Course . find ( course_id )
80- if !course . hide_submissions?
81- @courses << course
82-
83- awarded = @awarded_points [ course . id ]
84- missing = AvailablePoint . course_points ( course ) . order! . map ( &:name ) - awarded
85- @missing_points [ course_id ] = missing
86-
87- if awarded . size + missing . size > 0
88- @percent_completed [ course_id ] = 100 * ( awarded . size . to_f / ( awarded . size + missing . size ) )
89- else
90- @percent_completed [ course_id ] = 0
91- end
92- @group_completion_ratios [ course_id ] = course . exercise_group_completion_ratio_for_user ( @user )
93- end
94- end
73+ define_point_stats ( @user )
9574
9675 if current_user . administrator? || current_user . id == @user . id
9776 @submissions = @user . submissions . order ( 'created_at DESC' ) . includes ( :user ) . includes ( :course )
@@ -102,7 +81,6 @@ def show
10281 @submissions = @submissions . limit ( 100 ) unless !!params [ :view_all ]
10382
10483 Submission . eager_load_exercises ( @submissions )
105-
10684 end
10785
10886 def me
0 commit comments