diff --git a/app/helpers/dashboard/analyze_helper.rb b/app/helpers/dashboard/analyze_helper.rb index 5aff130..ab5dc87 100644 --- a/app/helpers/dashboard/analyze_helper.rb +++ b/app/helpers/dashboard/analyze_helper.rb @@ -28,11 +28,14 @@ module Dashboard def analyze_category_link(district:, school:, academic_year:, category:) year = academic_year.range - "/districts/#{district.slug}/schools/#{school.slug}/analyze?year=#{year}&academic_years=#{year}&category=#{category.category_id}" + district_school_analyze_index_path(district, school, + { year:, academic_years: year, category: category.category_id }) end def analyze_subcategory_link(district:, school:, academic_year:, category:, subcategory:) - "/districts/#{district.slug}/schools/#{school.slug}/analyze?year=#{academic_year.range}&category=#{category.category_id}&subcategory=#{subcategory.subcategory_id}" + year = academic_year.range + district_school_analyze_index_path(district, school, + { year: academic_year.range, category: category.category_id, subcategory: subcategory.subcategory_id }) end def colors diff --git a/app/models/dashboard/survey_item_response.rb b/app/models/dashboard/survey_item_response.rb index 1c20f8a..28e9239 100644 --- a/app/models/dashboard/survey_item_response.rb +++ b/app/models/dashboard/survey_item_response.rb @@ -6,13 +6,13 @@ module Dashboard belongs_to :school, class_name: "School", foreign_key: :dashboard_school_id belongs_to :survey_item, class_name: "SurveyItem", foreign_key: :dashboard_survey_item_id belongs_to :academic_year, class_name: "AcademicYear", foreign_key: :dashboard_academic_year_id - belongs_to :dashboard_student, optional: true - belongs_to :dashboard_gender, optional: true - belongs_to :dashboard_income, optional: true - belongs_to :dashboard_ell, optional: true - belongs_to :dashboard_sped, optional: true + belongs_to :student, optional: true, class_name: "Student", foreign_key: :dashboard_student_id + belongs_to :gender, optional: true, class_name: "Gender", foreign_key: :dashboard_gender_id + belongs_to :income, optional: true, class_name: "Income", foreign_key: :dashboard_income_id + belongs_to :ell, optional: true, class_name: "Ell", foreign_key: :dashboard_ell_id + belongs_to :sped, optional: true, class_name: "Sped", foreign_key: :dashboard_sped_id - has_one :dashboard_measure, through: :survey_item + has_one :measure, through: :survey_item validates :likert_score, numericality: { greater_than: 0, less_than_or_equal_to: 5 } diff --git a/app/presenters/dashboard/analyze/graph/column/ell_column/ell.rb b/app/presenters/dashboard/analyze/graph/column/ell_column/ell.rb index f965cd8..c04509d 100644 --- a/app/presenters/dashboard/analyze/graph/column/ell_column/ell.rb +++ b/app/presenters/dashboard/analyze/graph/column/ell_column/ell.rb @@ -25,7 +25,7 @@ module Dashboard end def ell - ::Ell.find_by_slug "ell" + Dashboard::Ell.find_by_slug "ell" end end end diff --git a/app/presenters/dashboard/analyze/graph/column/ell_column/not_ell.rb b/app/presenters/dashboard/analyze/graph/column/ell_column/not_ell.rb index de3085b..9b9174f 100644 --- a/app/presenters/dashboard/analyze/graph/column/ell_column/not_ell.rb +++ b/app/presenters/dashboard/analyze/graph/column/ell_column/not_ell.rb @@ -25,7 +25,7 @@ module Dashboard end def ell - Ell.find_by_slug "not-ell" + Dashboard::Ell.find_by_slug "not-ell" end end end diff --git a/app/presenters/dashboard/analyze/graph/column/ell_column/unknown.rb b/app/presenters/dashboard/analyze/graph/column/ell_column/unknown.rb index 957e382..5347f84 100644 --- a/app/presenters/dashboard/analyze/graph/column/ell_column/unknown.rb +++ b/app/presenters/dashboard/analyze/graph/column/ell_column/unknown.rb @@ -25,7 +25,7 @@ module Dashboard end def ell - Ell.find_by_slug "unknown" + Dashboard::Ell.find_by_slug "unknown" end end end diff --git a/app/presenters/dashboard/analyze/graph/column/gender_column/female.rb b/app/presenters/dashboard/analyze/graph/column/gender_column/female.rb index b85417f..e30e8ac 100644 --- a/app/presenters/dashboard/analyze/graph/column/gender_column/female.rb +++ b/app/presenters/dashboard/analyze/graph/column/gender_column/female.rb @@ -25,7 +25,7 @@ module Dashboard end def gender - ::Gender.find_by_qualtrics_code 1 + Gender.find_by_qualtrics_code 1 end end end diff --git a/app/presenters/dashboard/analyze/graph/column/gender_column/male.rb b/app/presenters/dashboard/analyze/graph/column/gender_column/male.rb index 00c7467..a4789ad 100644 --- a/app/presenters/dashboard/analyze/graph/column/gender_column/male.rb +++ b/app/presenters/dashboard/analyze/graph/column/gender_column/male.rb @@ -25,7 +25,7 @@ module Dashboard end def gender - ::Gender.find_by_qualtrics_code 2 + Gender.find_by_qualtrics_code 2 end end end diff --git a/app/presenters/dashboard/analyze/graph/column/gender_column/non_binary.rb b/app/presenters/dashboard/analyze/graph/column/gender_column/non_binary.rb index 2c90d0d..67aec4b 100644 --- a/app/presenters/dashboard/analyze/graph/column/gender_column/non_binary.rb +++ b/app/presenters/dashboard/analyze/graph/column/gender_column/non_binary.rb @@ -25,7 +25,7 @@ module Dashboard end def gender - ::Gender.find_by_qualtrics_code 4 + Gender.find_by_qualtrics_code 4 end end end diff --git a/app/presenters/dashboard/analyze/graph/column/gender_column/unknown.rb b/app/presenters/dashboard/analyze/graph/column/gender_column/unknown.rb index f114950..54ac97d 100644 --- a/app/presenters/dashboard/analyze/graph/column/gender_column/unknown.rb +++ b/app/presenters/dashboard/analyze/graph/column/gender_column/unknown.rb @@ -25,7 +25,7 @@ module Dashboard end def gender - ::Gender.find_by_qualtrics_code 99 + Gender.find_by_qualtrics_code 99 end end end diff --git a/app/presenters/dashboard/analyze/graph/column/sped_column/not_sped.rb b/app/presenters/dashboard/analyze/graph/column/sped_column/not_sped.rb index 4e424e8..59ef187 100644 --- a/app/presenters/dashboard/analyze/graph/column/sped_column/not_sped.rb +++ b/app/presenters/dashboard/analyze/graph/column/sped_column/not_sped.rb @@ -26,7 +26,7 @@ module Dashboard end def sped - ::Sped.find_by_slug "not-special-education" + Dashboard::Sped.find_by_slug "not-special-education" end end end diff --git a/app/presenters/dashboard/analyze/graph/column/sped_column/sped.rb b/app/presenters/dashboard/analyze/graph/column/sped_column/sped.rb index 5170f0c..e494ced 100644 --- a/app/presenters/dashboard/analyze/graph/column/sped_column/sped.rb +++ b/app/presenters/dashboard/analyze/graph/column/sped_column/sped.rb @@ -26,7 +26,7 @@ module Dashboard end def sped - ::Sped.find_by_slug "special-education" + Dashboard::Sped.find_by_slug "special-education" end end end diff --git a/app/presenters/dashboard/analyze/graph/column/sped_column/unknown.rb b/app/presenters/dashboard/analyze/graph/column/sped_column/unknown.rb index df0efb6..e17d6ee 100644 --- a/app/presenters/dashboard/analyze/graph/column/sped_column/unknown.rb +++ b/app/presenters/dashboard/analyze/graph/column/sped_column/unknown.rb @@ -26,7 +26,7 @@ module Dashboard end def sped - ::Sped.find_by_slug "unknown" + Dashboard::Sped.find_by_slug "unknown" end end end diff --git a/app/services/dashboard/survey_responses_data_loader.rb b/app/services/dashboard/survey_responses_data_loader.rb index 6671f28..e29bf2d 100644 --- a/app/services/dashboard/survey_responses_data_loader.rb +++ b/app/services/dashboard/survey_responses_data_loader.rb @@ -85,9 +85,10 @@ module Dashboard def process_survey_items(row:) student = Student.find_or_create_by(response_id: row.response_id, lasid: row.lasid) - # student.races.delete_all - # tmp_races = row.races.map { |race| races[race] } - # student.races += tmp_races + student.races.delete_all + tmp_races = row.races.map { |race| races[race] } + student.races += tmp_races + student.save row.survey_items.map do |survey_item| likert_score = row.likert_score(survey_item_id: survey_item.survey_item_id) || next @@ -97,11 +98,11 @@ module Dashboard next end response = row.survey_item_response(survey_item:) - build_response(survey_item_response: response, likert_score:, row:, survey_item:, student:) + build_response(survey_item_response: response, likert_score:, row:, survey_item:) end.compact end - def build_response(survey_item_response:, likert_score:, row:, survey_item:, student:) + def build_response(survey_item_response:, likert_score:, row:, survey_item:) gender = genders[row.gender] grade = row.grade income = incomes[row.income.parameterize]