-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add confidence check scores for manager or leader (#1385)
- Loading branch information
Showing
6 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
app/models/data_analysis/confidence_check_scores_for_manager_or_leader_and_other.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module DataAnalysis | ||
class ConfidenceCheckScoresForManagerOrLeaderAndOther | ||
include ToCsv | ||
|
||
class << self | ||
# @return [Array<String>] | ||
def column_names | ||
%w[ | ||
Module | ||
Question | ||
Answers | ||
Count | ||
] | ||
end | ||
|
||
# @return [Array<Hash{Symbol => Mixed}>] | ||
def dashboard | ||
confidence_check_scores.map do |(module_name, question_name, answers), count| | ||
{ | ||
module_name: module_name, | ||
question_name: question_name, | ||
answers: answers, | ||
count: count, | ||
} | ||
end | ||
end | ||
|
||
private | ||
|
||
# @return [Hash{Array<String, String, String> => Integer}] | ||
def confidence_check_scores | ||
User.with_confidence_score.leader_or_manager_and_other.order(:question_name).group(:training_module, :question_name, :answers).count | ||
end | ||
end | ||
end | ||
end |
36 changes: 36 additions & 0 deletions
36
app/models/data_analysis/confidence_check_scores_for_manager_or_leader_only.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module DataAnalysis | ||
class ConfidenceCheckScoresForManagerOrLeaderOnly | ||
include ToCsv | ||
|
||
class << self | ||
# @return [Array<String>] | ||
def column_names | ||
%w[ | ||
Module | ||
Question | ||
Answers | ||
Count | ||
] | ||
end | ||
|
||
# @return [Array<Hash{Symbol => Mixed}>] | ||
def dashboard | ||
confidence_check_scores.map do |(module_name, question_name, answers), count| | ||
{ | ||
module_name: module_name, | ||
question_name: question_name, | ||
answers: answers, | ||
count: count, | ||
} | ||
end | ||
end | ||
|
||
private | ||
|
||
# @return [Hash{Array<String, String, String> => Integer}] | ||
def confidence_check_scores | ||
User.with_confidence_score.leader_or_manager_only.order(:question_name).group(:training_module, :question_name, :answers).count | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
spec/models/data_analysis/confidence_check_scores_for_manager_or_leader_and_other_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe DataAnalysis::ConfidenceCheckScoresForManagerOrLeaderAndOther do | ||
let(:headers) do | ||
%w[ | ||
Module | ||
Question | ||
Answers | ||
Count | ||
] | ||
end | ||
|
||
let(:rows) do | ||
[ | ||
{ | ||
module_name: 'alpha', | ||
question_name: '1-3-3-1', | ||
answers: [1], | ||
count: 1, | ||
}, | ||
{ | ||
module_name: 'alpha', | ||
question_name: '1-3-3-2', | ||
answers: [2], | ||
count: 2, | ||
}, | ||
] | ||
end | ||
|
||
before do | ||
user_one = create :user, role_type: 'Manager or team leader', role_type_other: '' | ||
user_two = create :user, role_type: 'other', role_type_other: 'a leader' | ||
user_three = create :user, role_type: 'other', role_type_other: 'a manager' | ||
|
||
create( | ||
:response, | ||
question_name: '1-3-3-1', | ||
training_module: 'alpha', | ||
answers: [1], | ||
correct: true, | ||
user: user_one, | ||
question_type: 'confidence', | ||
) | ||
|
||
create( | ||
:response, | ||
question_name: '1-3-3-2', | ||
training_module: 'alpha', | ||
answers: [2], | ||
correct: true, | ||
user: user_two, | ||
question_type: 'confidence', | ||
) | ||
|
||
create( | ||
:response, | ||
question_name: '1-3-3-2', | ||
training_module: 'alpha', | ||
answers: [2], | ||
correct: true, | ||
user: user_three, | ||
question_type: 'confidence', | ||
) | ||
end | ||
|
||
it_behaves_like 'a data export model' | ||
end |
61 changes: 61 additions & 0 deletions
61
spec/models/data_analysis/confidence_check_scores_for_manager_or_leader_only_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe DataAnalysis::ConfidenceCheckScoresForManagerOrLeaderOnly do | ||
let(:headers) do | ||
%w[ | ||
Module | ||
Question | ||
Answers | ||
Count | ||
] | ||
end | ||
|
||
let(:rows) do | ||
[ | ||
{ | ||
module_name: 'alpha', | ||
question_name: '1-3-3-1', | ||
answers: [1], | ||
count: 1, | ||
}, | ||
] | ||
end | ||
|
||
before do | ||
user_one = create :user, role_type: 'Manager or team leader', role_type_other: '' | ||
user_two = create :user, role_type: 'other', role_type_other: 'a leader' | ||
user_three = create :user, role_type: 'other', role_type_other: 'a manager' | ||
|
||
create( | ||
:response, | ||
question_name: '1-3-3-1', | ||
training_module: 'alpha', | ||
answers: [1], | ||
correct: true, | ||
user: user_one, | ||
question_type: 'confidence', | ||
) | ||
|
||
create( | ||
:response, | ||
question_name: '1-3-3-2', | ||
training_module: 'alpha', | ||
answers: [2], | ||
correct: true, | ||
user: user_two, | ||
question_type: 'confidence', | ||
) | ||
|
||
create( | ||
:response, | ||
question_name: '1-3-3-2', | ||
training_module: 'alpha', | ||
answers: [2], | ||
correct: true, | ||
user: user_three, | ||
question_type: 'confidence', | ||
) | ||
end | ||
|
||
it_behaves_like 'a data export model' | ||
end |