mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-09 07:28:41 -07:00
fix: start fixing problem with variants not getting added to the cleaned csv
This commit is contained in:
parent
a0807295ed
commit
2c9df34fac
1 changed files with 13 additions and 1 deletions
|
|
@ -3,12 +3,24 @@ class SurveyItemValues
|
|||
|
||||
def initialize(row:, headers:, genders:, survey_items:, schools:)
|
||||
@row = row
|
||||
@headers = headers
|
||||
@headers = include_all_headers(headers:)
|
||||
@genders = genders
|
||||
@survey_items = survey_items
|
||||
@schools = schools
|
||||
end
|
||||
|
||||
# Some survey items have variants, i.e. a survey item with an id of s-tint-q1 might have a variant that looks like s-tint-q1-1. We must ensure that all variants in the form of s-tint-q1-1 have a matching pair.
|
||||
# We don't ensure that ids in the form of s-tint-q1 have a matching pair because not all questions have variants
|
||||
def include_all_headers(headers:)
|
||||
alternates = headers.filter(&:present?)
|
||||
.filter { |header| header.end_with? "-1" }
|
||||
alternates.each do |header|
|
||||
main = header.sub(/-1\z/, "")
|
||||
headers.push(main) unless headers.include?(main)
|
||||
end
|
||||
headers
|
||||
end
|
||||
|
||||
def dese_id?
|
||||
dese_id.present?
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue