Skip to content

Commit

Permalink
Merge pull request #1830 from TEAMSchools/dibels_data_model_revamp
Browse files Browse the repository at this point in the history
Dibels data model revamp
  • Loading branch information
cbini authored Sep 25, 2024
2 parents d7a9e87 + cd15012 commit d006148
Show file tree
Hide file tree
Showing 9 changed files with 612 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ with
`date`,
form,
`remote`,
score,
score as mclass_measure_standard_score,
benchmark_status,
national_dds_percentile,
national_dds_percentile as mclass_measure_percentile,
district_percentile,
school_percentile,

split(name_column, '|')[0] as measure,
split(name_column, '|')[0] as mclass_measure_standard,
split(name_column, '|')[1] as assessment_period,

from
{{ ref("stg_amplify__dibels_data_farming") }} unpivot (
(
Expand Down Expand Up @@ -239,48 +240,83 @@ with
) as 'orf_errors|End'
)
)
)
),

select
*,
df_data as (

case
assessment_period
when 'Beginning'
then 'BOY'
when 'Middle'
then 'MOY'
when 'End'
then 'EOY'
end as mclass_period,
select
*,

case
benchmark_status
when 'Core^ Support'
then 'Above Benchmark'
when 'Core Support'
then 'At Benchmark'
when 'Strategic Support'
then 'Below Benchmark'
when 'Intensive Support'
then 'Well Below Benchmark'
end as mclass_measure_level,
case
mclass_measure_standard
when 'Composite'
then 'Composite'
when 'Reading Comprehension (Maze)'
then 'Comprehension'
else
substr(
mclass_measure_standard,
strpos(mclass_measure_standard, '(') + 1,
3
)
end as mclass_measure_name_code,

case
benchmark_status
when 'Core^ Support'
then 4
when 'Core Support'
then 3
when 'Strategic Support'
then 2
when 'Intensive Support'
then 1
end as mclass_measure_level_int,
case
assessment_period
when 'Beginning'
then 'BOY'
when 'Middle'
then 'MOY'
when 'End'
then 'EOY'
end as mclass_period,

{{
dbt_utils.generate_surrogate_key(
["student_id", "academic_year", "assessment_period"]
)
}} as surrogate_key,
from df_unpivot
case
benchmark_status
when 'Core^ Support'
then 'Above Benchmark'
when 'Core Support'
then 'At Benchmark'
when 'Strategic Support'
then 'Below Benchmark'
when 'Intensive Support'
then 'Well Below Benchmark'
end as mclass_measure_standard_level,

case
benchmark_status
when 'Core^ Support'
then 4
when 'Core Support'
then 3
when 'Strategic Support'
then 2
when 'Intensive Support'
then 1
end as mclass_measure_standard_level_int,

{{
dbt_utils.generate_surrogate_key(
["student_id", "academic_year", "assessment_period"]
)
}} as surrogate_key,
from df_unpivot
)

select
*,
case
mclass_measure_name_code
when 'LNF'
then 'Letter Names'
when 'PSF'
then 'Phonological Awareness'
when 'NWF'
then 'Nonsense Word Fluency'
when 'WRF'
then 'Word Reading Fluency'
when 'ORF'
then 'Oral Reading Fluency'
else mclass_measure_name_code
end as mclass_measure_name,
from df_data
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ with
bss.client_date as mclass_client_date,
bss.sync_date as mclass_sync_date,

u.measure as mclass_measure,
u.score as mclass_measure_score,
u.level as mclass_measure_level,
u.level_int as mclass_measure_level_int,
u.national_norm_percentile as mclass_measure_percentile,
u.semester_growth as mclass_measure_semester_growth,
u.year_growth as mclass_measure_year_growth,
u.mclass_measure_name,
u.mclass_measure_name_code,
u.mclass_measure_standard,
u.mclass_measure_standard_score,
u.mclass_measure_standard_level,
u.mclass_measure_standard_level_int,
u.mclass_measure_percentile,
u.mclass_measure_semester_growth,
u.mclass_measure_year_growth,

'Benchmark' as assessment_type,
null as mclass_probe_number,
null as mclass_total_number_of_probes,
null as mclass_score_change,

row_number() over (
partition by u.surrogate_key, u.measure order by u.level_int desc
partition by u.surrogate_key, u.mclass_measure_standard
order by u.mclass_measure_standard_level_int desc
) as rn_highest,

row_number() over (
Expand All @@ -50,11 +53,14 @@ with
mclass_period,
`date` as mclass_client_date,
`date` as mclass_sync_date,
measure as mclass_measure,
score as mclass_measure_score,
mclass_measure_level,
mclass_measure_level_int,
national_dds_percentile as mclass_measure_percentile,

mclass_measure_name,
mclass_measure_name_code,
mclass_measure_standard,
mclass_measure_standard_score,
mclass_measure_standard_level,
mclass_measure_standard_level_int,
mclass_measure_percentile,

cast(null as string) as mclass_measure_semester_growth,
cast(null as string) as mclass_measure_year_growth,
Expand All @@ -64,16 +70,16 @@ with
null as mclass_score_change,

row_number() over (
partition by surrogate_key, measure
order by mclass_measure_level_int desc
partition by surrogate_key, mclass_measure_standard
order by mclass_measure_standard_level_int desc
) as rn_highest,

row_number() over (
partition by academic_year, student_id order by `date`
) as rn_distinct,
from {{ ref("int_amplify__dibels_data_farming_unpivot") }}
where
measure
mclass_measure_standard
in ('Reading Fluency (ORF)', 'Reading Comprehension (Maze)', 'Composite')

union all
Expand All @@ -86,12 +92,14 @@ with
pm_period as mclass_period,
client_date as mclass_client_date,
sync_date as mclass_sync_date,
measure as mclass_measure,
score as mclass_measure_score,
mclass_measure_name,
mclass_measure_name_code,
measure as mclass_measure_standard,
mclass_measure_standard_score,

'NA' as mclass_measure_level,
'NA' as mclass_measure_standard_level,

null as mclass_measure_level_int,
null as mclass_measure_standard_level_int,
null as mclass_measure_percentile,

'NA' as mclass_measure_semester_growth,
Expand All @@ -100,10 +108,11 @@ with

probe_number as mclass_probe_number,
total_number_of_probes as mclass_total_number_of_probes,
score_change as mclass_score_change,
mclass_measure_standard_score_change,

row_number() over (
partition by surrogate_key, measure order by score desc
partition by surrogate_key, measure
order by mclass_measure_standard_score desc
) as rn_highest,

row_number() over (
Expand All @@ -120,9 +129,9 @@ with
mclass_academic_year,
mclass_student_number,
mclass_period,
mclass_measure_level,
mclass_measure_standard_level,
from assessments_scores
where mclass_measure = 'Composite' and rn_highest = 1
where mclass_measure_standard = 'Composite' and rn_highest = 1
),

overall_composite_by_window as (
Expand All @@ -135,7 +144,8 @@ with
coalesce(p.eoy, 'No data') as eoy,
from
composite_only pivot (
max(mclass_measure_level) for mclass_period in ('BOY', 'MOY', 'EOY')
max(mclass_measure_standard_level) for mclass_period
in ('BOY', 'MOY', 'EOY')
) as p
),

Expand Down Expand Up @@ -172,10 +182,12 @@ select
s.mclass_period,
s.mclass_client_date,
s.mclass_sync_date,
s.mclass_measure,
s.mclass_measure_score,
s.mclass_measure_level,
s.mclass_measure_level_int,
s.mclass_measure_name,
s.mclass_measure_name_code,
s.mclass_measure_standard,
s.mclass_measure_standard_score,
s.mclass_measure_standard_level,
s.mclass_measure_standard_level_int,
s.mclass_measure_percentile,
s.mclass_measure_semester_growth,
s.mclass_measure_year_growth,
Expand Down
Loading

0 comments on commit d006148

Please sign in to comment.