Skip to content

Commit

Permalink
Add assessment for managers and leaders
Browse files Browse the repository at this point in the history
  • Loading branch information
martikat committed Nov 15, 2024
1 parent aa3bdb8 commit 6e0d2bf
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
40 changes: 40 additions & 0 deletions app/models/data_analysis/assessment_for_leaders_and_managers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module DataAnalysis
class AssessmentForLeadersAndManagers
include ToCsv

class << self
# @note Personally identifiable information must not be revealed
# @return [Array<String>]
def column_names
%w[
user_id
training_module
score
passed
started_at
completed_at
]
end

# @return [Array<Hash{Symbol => Mixed}>]
def dashboard
filtered_assessment.select(*column_names).map do |user|
decorator.call user.attributes.symbolize_keys.except(:id)
end
end

# @param mod [Training::Module]
# @return [Integer]
def filtered_assessment
User.with_assessments.leader_or_manager
end

private

# @return [CoercionDecorator]
def decorator
@decorator ||= CoercionDecorator.new
end
end
end
end
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def test_user?
# assessments
scope :with_assessments, -> { joins(:assessments) }
scope :with_passing_assessments, -> { with_assessments.merge(Assessment.passed) }
scope :leader_or_manager, -> { where(role_type: 'Manager or team leader') }

# events
scope :with_events, -> { joins(:events) }
Expand Down
3 changes: 2 additions & 1 deletion app/services/dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Dashboard
{ model: 'DataAnalysis::ReturningUsers', folder: 'users', file: 'returning_users' },
# { model: 'DataAnalysis::LocalAuthorityUser', folder: 'users', file: 'local_authority_users' },

{ model: 'Assessment', folder: 'training', file: 'assessments' },
{ model: 'Assessment', folder: 'training', file: 'assessments' },
{ model: 'DataAnalysis::AssessmentForLeadersAndManagers', folder: 'training', file: 'assessments_managers_and_leaders' },
{ model: 'DataAnalysis::ConfidenceCheckScores', folder: 'training', file: 'confidence_check_scores' },
# { model: 'DataAnalysis::AveragePassScores', folder: 'training', file: 'average_pass_scores' },
# { model: 'DataAnalysis::HighFailQuestions', folder: 'training', file: 'high_fail_questions' },
Expand Down

0 comments on commit 6e0d2bf

Please # to comment.