|
|
|
|
@ -8,179 +8,156 @@ describe SurveyItemResponse, type: :model do
|
|
|
|
|
let(:measure) { create(:measure) }
|
|
|
|
|
|
|
|
|
|
context 'when the measure includes only teacher data' do
|
|
|
|
|
let(:teacher_survey_item_1) { create(:survey_item, survey_item_id: 't-question-1', measure: measure) }
|
|
|
|
|
let(:teacher_survey_item_2) { create(:survey_item, survey_item_id: 't-question-2', measure: measure) }
|
|
|
|
|
let(:teacher_survey_item_3) { create(:survey_item, survey_item_id: 't-question-3', measure: measure) }
|
|
|
|
|
let(:teacher_survey_item_1) { create(:teacher_survey_item, measure: measure) }
|
|
|
|
|
let(:teacher_survey_item_2) { create(:teacher_survey_item, measure: measure) }
|
|
|
|
|
let(:teacher_survey_item_3) { create(:teacher_survey_item, measure: measure) }
|
|
|
|
|
|
|
|
|
|
context "and the number of responses for each of the measure's survey items meets the teacher threshold of 17" do
|
|
|
|
|
before :each do
|
|
|
|
|
17.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_1, academic_year: ay, school: school, likert_score: 3)
|
|
|
|
|
end
|
|
|
|
|
17.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_2, academic_year: ay, school: school, likert_score: 4)
|
|
|
|
|
end
|
|
|
|
|
17.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_3, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
end
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD, survey_item: teacher_survey_item_1, academic_year: ay, school: school, likert_score: 3)
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD, survey_item: teacher_survey_item_2, academic_year: ay, school: school, likert_score: 4)
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD, survey_item: teacher_survey_item_3, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the average of the likert scores of the survey items' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to eq 4
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to eq 4
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affirms that the result meets the threshold' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_teacher_threshold?).to be true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "and the average number of responses across the measure's survey items meets the teacher threshold of 17" do
|
|
|
|
|
before :each do
|
|
|
|
|
19.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_1, academic_year: ay, school: school, likert_score: 3)
|
|
|
|
|
end
|
|
|
|
|
16.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_2, academic_year: ay, school: school, likert_score: 4)
|
|
|
|
|
end
|
|
|
|
|
16.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_3, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
end
|
|
|
|
|
create_list(:survey_item_response, 19, survey_item: teacher_survey_item_1, academic_year: ay, school: school, likert_score: 3)
|
|
|
|
|
create_list(:survey_item_response, 16, survey_item: teacher_survey_item_2, academic_year: ay, school: school, likert_score: 4)
|
|
|
|
|
create_list(:survey_item_response, 16, survey_item: teacher_survey_item_3, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the average of the likert scores of the survey items' do
|
|
|
|
|
average_score = 3.941
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to be_within(0.001).of(average_score)
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to be_within(0.001).of(average_score)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "and none of the measure's survey items meets the teacher threshold of 17" do
|
|
|
|
|
before :each do
|
|
|
|
|
16.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_1, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
16.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_2, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
16.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_3, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
create_list(:survey_item_response, 16, survey_item: teacher_survey_item_1, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
create_list(:survey_item_response, 16, survey_item: teacher_survey_item_2, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
create_list(:survey_item_response, 16, survey_item: teacher_survey_item_3, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to be_nil
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to be_nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affirms that the result does not meet the threshold' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_teacher_threshold?).to be false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "and the average number of responses across the measure's survey items does not meet the teacher threshold of 17" do
|
|
|
|
|
before :each do
|
|
|
|
|
18.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_1, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
16.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_2, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
16.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_3, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
create_list(:survey_item_response, 18, survey_item: teacher_survey_item_1, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
create_list(:survey_item_response, 16, survey_item: teacher_survey_item_2, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
create_list(:survey_item_response, 16, survey_item: teacher_survey_item_3, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to be_nil
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to be_nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affirms that the result does not meet the threshold' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_teacher_threshold?).to be false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when the measure includes only student data' do
|
|
|
|
|
let(:student_survey_item_1) { create(:survey_item, survey_item_id: 's-question-1', measure: measure) }
|
|
|
|
|
let(:student_survey_item_2) { create(:survey_item, survey_item_id: 's-question-2', measure: measure) }
|
|
|
|
|
let(:student_survey_item_3) { create(:survey_item, survey_item_id: 's-question-3', measure: measure) }
|
|
|
|
|
let(:student_survey_item_1) { create(:student_survey_item, measure: measure) }
|
|
|
|
|
let(:student_survey_item_2) { create(:student_survey_item, measure: measure) }
|
|
|
|
|
let(:student_survey_item_3) { create(:student_survey_item, measure: measure) }
|
|
|
|
|
|
|
|
|
|
context "and the number of responses for each of the measure's survey items meets the student threshold of 196" do
|
|
|
|
|
before :each do
|
|
|
|
|
196.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_1, academic_year: ay, school: school, likert_score: 3)
|
|
|
|
|
end
|
|
|
|
|
196.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_2, academic_year: ay, school: school, likert_score: 4)
|
|
|
|
|
end
|
|
|
|
|
196.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_3, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
end
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD, survey_item: student_survey_item_1, academic_year: ay, school: school, likert_score: 3)
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD, survey_item: student_survey_item_2, academic_year: ay, school: school, likert_score: 4)
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD, survey_item: student_survey_item_3, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the average of the likert scores of the survey items' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to eq 4
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to eq 4
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affirms that the result meets the threshold' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_student_threshold?).to be true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "and the average number of responses across the measure's survey items meets the student threshold of 196" do
|
|
|
|
|
before :each do
|
|
|
|
|
200.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_1, academic_year: ay, school: school, likert_score: 3)
|
|
|
|
|
end
|
|
|
|
|
195.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_2, academic_year: ay, school: school, likert_score: 4)
|
|
|
|
|
end
|
|
|
|
|
193.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_3, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
end
|
|
|
|
|
create_list(:survey_item_response, 200, survey_item: student_survey_item_1, academic_year: ay, school: school, likert_score: 3)
|
|
|
|
|
create_list(:survey_item_response, 195, survey_item: student_survey_item_2, academic_year: ay, school: school, likert_score: 4)
|
|
|
|
|
create_list(:survey_item_response, 193, survey_item: student_survey_item_3, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the average of the likert scores of the survey items' do
|
|
|
|
|
average_score = 3.988
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to be_within(0.001).of(average_score)
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to be_within(0.001).of(average_score)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "and none of the measure's survey items meets the student threshold of 196" do
|
|
|
|
|
before :each do
|
|
|
|
|
195.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_1, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
195.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_2, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
195.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_3, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
create_list(:survey_item_response, 195, survey_item: student_survey_item_1, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
create_list(:survey_item_response, 195, survey_item: student_survey_item_2, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
create_list(:survey_item_response, 195, survey_item: student_survey_item_3, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to be_nil
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to be_nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affirms that the result does not meet the threshold' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_student_threshold?).to be false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "and the average number of responses across the measure's survey items does not meet the student threshold of 196" do
|
|
|
|
|
before :each do
|
|
|
|
|
200.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_1, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
196.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_2, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
191.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_3, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
create_list(:survey_item_response, 200, survey_item: student_survey_item_1, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD, survey_item: student_survey_item_2, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
create_list(:survey_item_response, 191, survey_item: student_survey_item_3, academic_year: ay, school: school, likert_score: rand)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to be_nil
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to be_nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affirms that the result does not meet the threshold' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_student_threshold?).to be false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when the measure includes both teacher and student data' do
|
|
|
|
|
let(:teacher_survey_item_1) { create(:survey_item, survey_item_id: 't-question-1', measure: measure) }
|
|
|
|
|
let(:student_survey_item_1) { create(:survey_item, survey_item_id: 's-question-1', measure: measure) }
|
|
|
|
|
let(:teacher_survey_item_1) { create(:teacher_survey_item, measure: measure) }
|
|
|
|
|
let(:student_survey_item_1) { create(:student_survey_item, measure: measure) }
|
|
|
|
|
|
|
|
|
|
context 'and there is sufficient teacher data and sufficient student data' do
|
|
|
|
|
before :each do
|
|
|
|
|
SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD.times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_1, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
end
|
|
|
|
|
SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD.times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_1, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
end
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD, survey_item: teacher_survey_item_1, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD, survey_item: student_survey_item_1, academic_year: ay, school: school, likert_score: 5)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the average of the likert scores of the survey items' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to eq 5
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to eq 5
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affirms that the result does meet the thresholds' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_teacher_threshold?).to be true
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_student_threshold?).to be true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@ -191,7 +168,12 @@ describe SurveyItemResponse, type: :model do
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the average of the likert scores of the teacher survey items' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to eq 5
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to eq 5
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affirms that the result meets the teacher threshold but not the student threshold' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_teacher_threshold?).to be true
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_student_threshold?).to be false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@ -202,22 +184,28 @@ describe SurveyItemResponse, type: :model do
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the average of the likert scores of the student survey items' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to eq 5
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to eq 5
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affirms that the result meets the student threshold but not the teacher threshold' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_teacher_threshold?).to be false
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_student_threshold?).to be true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'and there is insufficient teacher data and insufficient student data' do
|
|
|
|
|
before :each do
|
|
|
|
|
(SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD - 1).times do
|
|
|
|
|
create(:survey_item_response, survey_item: teacher_survey_item_1, academic_year: ay, school: school)
|
|
|
|
|
end
|
|
|
|
|
(SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD - 1).times do
|
|
|
|
|
create(:survey_item_response, survey_item: student_survey_item_1, academic_year: ay, school: school)
|
|
|
|
|
end
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD - 1, survey_item: teacher_survey_item_1, academic_year: ay, school: school)
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD - 1, survey_item: student_survey_item_1, academic_year: ay, school: school)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay)).to be_nil
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).average).to be_nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affirms that the result does not meet either threshold' do
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_teacher_threshold?).to be false
|
|
|
|
|
expect(SurveyItemResponse.score_for_measure(measure: measure, school: school, academic_year: ay).meets_student_threshold?).to be false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@ -228,22 +216,17 @@ describe SurveyItemResponse, type: :model do
|
|
|
|
|
let(:sufficient_measure_1) { create(:measure, subcategory: subcategory) }
|
|
|
|
|
let(:sufficient_measure_2) { create(:measure, subcategory: subcategory) }
|
|
|
|
|
let(:insufficient_measure) { create(:measure, subcategory: subcategory) }
|
|
|
|
|
let(:sufficient_teacher_survey_item) { create(:survey_item, survey_item_id: 't-question-1', measure: sufficient_measure_1) }
|
|
|
|
|
let(:insufficient_teacher_survey_item) { create(:survey_item, survey_item_id: 't-question-2', measure: insufficient_measure) }
|
|
|
|
|
let(:sufficient_student_survey_item) { create(:survey_item, survey_item_id: 's-question-1', measure: sufficient_measure_2) }
|
|
|
|
|
let(:insufficient_student_survey_item) { create(:survey_item, survey_item_id: 's-question-2', measure: insufficient_measure) }
|
|
|
|
|
let(:sufficient_teacher_survey_item) { create(:teacher_survey_item, measure: sufficient_measure_1) }
|
|
|
|
|
let(:insufficient_teacher_survey_item) { create(:teacher_survey_item, measure: insufficient_measure) }
|
|
|
|
|
let(:sufficient_student_survey_item) { create(:student_survey_item, measure: sufficient_measure_2) }
|
|
|
|
|
let(:insufficient_student_survey_item) { create(:student_survey_item, measure: insufficient_measure) }
|
|
|
|
|
|
|
|
|
|
before :each do
|
|
|
|
|
[SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD].max.times do
|
|
|
|
|
create(:survey_item_response, survey_item: sufficient_teacher_survey_item, academic_year: ay, school: school, likert_score: 1)
|
|
|
|
|
create(:survey_item_response, survey_item: sufficient_student_survey_item, academic_year: ay, school: school, likert_score: 4)
|
|
|
|
|
end
|
|
|
|
|
(SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD - 1).times do
|
|
|
|
|
create(:survey_item_response, survey_item: insufficient_teacher_survey_item, academic_year: ay, school: school, likert_score: 1)
|
|
|
|
|
end
|
|
|
|
|
(SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD - 1).times do
|
|
|
|
|
create(:survey_item_response, survey_item: insufficient_student_survey_item, academic_year: ay, school: school, likert_score: 1)
|
|
|
|
|
end
|
|
|
|
|
largest_threshold = [SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD].max
|
|
|
|
|
create_list(:survey_item_response, largest_threshold, survey_item: sufficient_teacher_survey_item, academic_year: ay, school: school, likert_score: 1)
|
|
|
|
|
create_list(:survey_item_response, largest_threshold, survey_item: sufficient_student_survey_item, academic_year: ay, school: school, likert_score: 4)
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::TEACHER_RESPONSE_THRESHOLD - 1, survey_item: insufficient_teacher_survey_item, academic_year: ay, school: school, likert_score: 1)
|
|
|
|
|
create_list(:survey_item_response, SurveyItemResponse::STUDENT_RESPONSE_THRESHOLD - 1, survey_item: insufficient_student_survey_item, academic_year: ay, school: school, likert_score: 1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the average score of all survey item responses for measures meeting their respective thresholds' do
|
|
|
|
|
|