Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pd_funnel_6_12 #147

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0a436ff
saving progress
allison-code-dot-org Aug 7, 2024
d56bc11
pd_funnel_6_12
allison-code-dot-org Aug 8, 2024
a99d178
rebasing
allison-code-dot-org Aug 13, 2024
60c5ce6
Merge branch 'main' of https://github.com/code-dot-org/analytics into…
allison-code-dot-org Aug 22, 2024
0fd7dba
Merge branch 'main' into feature/pd
jordan-springer Sep 2, 2024
6c51449
Merge branch 'main' of https://github.com/code-dot-org/analytics into…
allison-code-dot-org Sep 17, 2024
fe2866f
Merge branch 'main' of https://github.com/code-dot-org/analytics into…
allison-code-dot-org Sep 19, 2024
746840b
Merge branch 'main' of https://github.com/code-dot-org/analytics into…
allison-code-dot-org Oct 31, 2024
d3b460f
adding K-5 PD info
allison-code-dot-org Oct 31, 2024
233a7fa
Merge branch 'main' of https://github.com/code-dot-org/analytics into…
allison-code-dot-org Oct 31, 2024
b483dee
Merge branch 'main' of https://github.com/code-dot-org/analytics into…
allison-code-dot-org Dec 2, 2024
6eeea34
Merge branch 'main' of https://github.com/code-dot-org/analytics into…
allison-code-dot-org Dec 6, 2024
5dd5e19
adding rp association
allison-code-dot-org Dec 7, 2024
ee3e5a4
some changes
allison-code-dot-org Dec 16, 2024
aa13251
Merge branch 'main' of https://github.com/code-dot-org/analytics into…
allison-code-dot-org Dec 16, 2024
45d5ed7
Merge branch 'main' of https://github.com/code-dot-org/analytics into…
allison-code-dot-org Dec 19, 2024
82203ea
finishing model 1
allison-code-dot-org Dec 20, 2024
1917d60
small changes
allison-code-dot-org Dec 20, 2024
642df40
Merge branch 'main' of https://github.com/code-dot-org/analytics into…
allison-code-dot-org Dec 20, 2024
893fb47
saving progress
allison-code-dot-org Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions dbt/data/seed_pl_grade_band_mappings.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
topic,grade_band
Teaching How AI Makes Decisions,K-5
Teaching Elementary Game Design,K-5
Teaching micro:bit Maker Module,K-5
Computer Science Basics for K-5 Teachers,Skills-focused
Teaching CS Fundamentals,K-5
Teaching CS Connections,K-5
Teaching Exploring Generative AI,9-12
Teaching Coding with AI,9-12
Teaching Interactive Animations and Games,6-8
Teaching Computer Science Discoveries,6-8
Teaching CS Discoveries,6-8
Teaching Problem Solving and Computing,6-8
Teaching AI and Machine Learning,6-8
Teaching Data and Society,6-8
Teaching the Design Process,6-8
Teaching Web Development,6-8
AI 101 ,Skills-focused
Teaching Computer Vision,9-12
Teaching Computer Science Principles,9-12
Getting Started wtih Code.org Self-Paced PL,Skills-focused
Equity Self-Paced PL,Skills-focused
Debugging Self-Paced PL,Skills-focused
Foundations of CS PL,9-12
Data Science PL,9-12
Computer Systems & Devices PL,9-12
Intro to Programming/Python PL,9-12
Networks and the Internet PL,9-12
Cybersecurity PL,9-12
Creativity with AI PL,9-12
K-5 Music Lab PL,K-5
CSD Music Lab PL,6-8
18 changes: 17 additions & 1 deletion dbt/models/intermediate/_intermediate__models.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
version: 2

models:
models:
- name: int_application_status_times
description: |
For every application to PD, this model gives the # days spent in each application status until they are in a final state (e.g. accepted, withdrawn, declined)
columns:
- name: pd_application_id
- name: days_in_pending
description: the number of days the application was in the status of "pending"
- name: days_in_unreviewed
description: the number of days the application was in the status of "unreviewed"
- name: days_in_incomplete
description: the number of days the application was in the status of "incomplete"
- name: days_in_pending_space_availability
description: the number of days the application was in the status of "pending space availability"
- name: days_in_awaiting_admin_approval
description: the number of days the application was in the status of "awaiting admin approval"

- name: int_ap_agg_exam_results_union_agg_school_level
description: |
This intermediate model unions together:
Expand Down
35 changes: 35 additions & 0 deletions dbt/models/intermediate/int_application_status_times.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
with

pd_applications_status_logs as (
select *
from {{ ref('stg_dashboard_pii__pd_applications_status_logs') }}
),

days_in_status as (
select
logs_1.pd_application_id
, logs_1.application_status
, case
when logs_2.changed_status_dt is not null
then datediff('day', logs_1.changed_status_dt, logs_2.changed_status_dt)
else datediff('day', logs_1.changed_status_dt, current_date)
end as days_in_status
from pd_applications_status_logs as logs_1
left join pd_applications_status_logs as logs_2
on logs_1.change_order = logs_2.change_order - 1
and logs_1.pd_application_id = logs_2.pd_application_id
order by logs_1.pd_application_id
)

select *
from days_in_status
pivot (
avg(days_in_status)
for application_status in (
'pending' as days_in_pending
,'unreviewed' as days_in_unreviewed
,'incomplete' as days_in_incomplete
,'pending_space_availability' as days_in_pending_space_availability
,'awaiting_admin_approval' as days_in_awaiting_admin_approval
)
)
27 changes: 26 additions & 1 deletion dbt/models/marts/districts/dim_districts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ school_districts as (
from {{ ref('stg_dashboard__school_districts') }}
),

regional_partners as (
select *
from {{ ref('dim_regional_partners') }}
),

rp_mappings as (
select *
from {{ ref('stg_dashboard_pii__pd_regional_partner_mappings') }}
),

combined as (
select
school_districts.school_district_id,
Expand All @@ -21,6 +31,10 @@ combined as (
school_districts.school_district_zip,
school_districts.last_known_school_year_open,

--regional partner association
rp_mappings.regional_partner_id,
regional_partners.regional_partner_name,

-- school aggregations
count(distinct dim_schools.school_id) as num_schools,
sum(dim_schools.is_stage_el) as num_schools_stage_el,
Expand All @@ -44,8 +58,19 @@ combined as (
from dim_schools
left join school_districts
on dim_schools.school_district_id = school_districts.school_district_id
left join rp_mappings
on (
school_districts.school_district_zip = rp_mappings.zip_code
or (
rp_mappings.zip_code is null
and
school_districts.school_district_state = rp_mappings.state
)
)
left join regional_partners
on regional_partners.regional_partner_id = rp_mappings.regional_partner_id
where dim_schools.school_district_id is not null
{{ dbt_utils.group_by(6) }}
{{ dbt_utils.group_by(8) }}
)

select *
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2

models:
- name: pd_funnel_6_12
description: |
the model represents the entire professional development funnel for the "5 day summer" workshops (csd, csp, csa). It tracks all teachers who apply, enroll, attend, and are considered trained, along with various dimensions about their application (e.g. time between applying and enrolling).
**note**: a teacher may apply through code.org, or through a regional partner's own application process. For the external applicants, they will still be counted as "enrolled" in our system but not "applied".
184 changes: 184 additions & 0 deletions dbt/models/marts/professional_development/dim_pl_activity.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
with

self_paced_activity as (
select
teacher_id,
level_created_school_year as school_year,
course_name_implementation as topic,
'self_paced' as pd_type,
case
when content_area = 'self_paced_pl_k_5' then 'k_5'
when content_area = 'self_paced_pl_6_8' then '6_8'
when content_area = 'self_paced_pl_9_12' then '9_12'
when content_area = 'skills_focused_self_paced_pl' then 'skills_focused'
else null
end as grade_band,
-- , min(level_created_dt) as first_activity_at
-- , max(level_created_dt) as last_activity_at
count(distinct level_script_id) as num_levels
from {{ ref('dim_self_paced_pd_activity') }}
{{ dbt_utils.group_by(5) }}
),

teacher_schools_historical as (
select *
from {{ ref('int_teacher_schools_historical') }}
),

schools as (
select *
from {{ ref('dim_schools') }}
),

districts as (
select *
from {{ ref('dim_districts') }}
),

pd_enrollments as (
select
pd_enrollment_id
, pd_workshop_id
, teacher_id
, enrolled_at
from {{ ref('stg_dashboard_pii__pd_enrollments') }}
where teacher_id is not null
),

pd_attendances as (
select
pd_attendance_id
, pd_session_id
, teacher_id
, school_year
from {{ ref('stg_dashboard_pii__pd_attendances') }}
),

pd_sessions as (
select
pd_session_id
, pd_workshop_id
, school_year
, num_hours
from {{ ref('stg_dashboard_pii__pd_sessions') }}
),

pd_workshops as (
select
pd_workshop_id
, organizer_id
, school_year
, course_name
, grade_band
, subject
, regional_partner_id
, is_byow
from {{ ref('stg_dashboard_pii__pd_workshops') }}
),

course_offerings as (
select *
from {{ ref('stg_dashboard__course_offerings') }}
),

course_offerings_pd_workshops as (
select *
from {{ ref('stg_dashboard_pii__course_offerings_pd_workshops') }}
),

regional_partners as (
select *
from {{ ref('dim_regional_partners') }}
),

pl_grade_band_mappings as (
select *
from {{ ref('stg_external_datasets__pl_grade_band_mappings') }}
),

facilitated_pd as (
select distinct
pda.teacher_id,
pdw.school_year,
'facilitated' as pd_type,
pdw.pd_workshop_id,
pdw.organizer_id,
pdw.regional_partner_id as workshop_regional_partner_id,
districts.regional_partner_id as district_regional_partner_id,
pdw.is_byow,
case
when pdw.course_name = 'build your own workshop'
then co.display_name
else pdw.course_name
end as topic,
coalesce(mappings.grade_band, pdw.grade_band) as grade_band,
tsh.school_id,
schools.school_district_id,
-- pdw.subject,
-- co.display_name
--co.cs_topic,
cast(null as bigint) as num_levels,
sum(pds.num_hours) as num_hours

from pd_attendances pda
join pd_sessions pds
on pda.pd_session_id = pds.pd_session_id
join pd_workshops pdw
on pds.pd_workshop_id = pdw.pd_workshop_id
left join course_offerings_pd_workshops copw
on pdw.pd_workshop_id = copw.pd_workshop_id
left join course_offerings co
on copw.course_offering_id = co.course_offering_id
left join pl_grade_band_mappings mappings
on co.display_name = mappings.topic
left join teacher_schools_historical tsh
on pda.teacher_id = tsh.teacher_id
and pda.school_year = tsh.started_at_sy
left join schools
on tsh.school_id = schools.school_id
left join districts
on schools.school_district_id = districts.school_district_id
{{ dbt_utils.group_by(13) }}
),

self_paced_pd as (
select distinct
spa.teacher_id,
spa.school_year,
spa.pd_type,
cast(null as bigint) as pd_workshop_id,
cast(null as bigint) as organizer_id,
cast(null as bigint) as workshop_regional_partner_id,
districts.regional_partner_id as district_regional_partner_id,
cast(null as bigint) as is_byow,
spa.topic,
-- , spa.first_activity_at
-- , spa.last_activity_at
spa.grade_band,
tsh.school_id,
schools.school_district_id,
spa.num_levels,
cast(null as bigint) as num_hours

from self_paced_activity spa
left join teacher_schools_historical tsh
on spa.teacher_id = tsh.teacher_id
and spa.school_year = tsh.started_at_sy
left join schools
on tsh.school_id = schools.school_id
left join districts
on schools.school_district_id = districts.school_district_id
),

combined as (
select *
from facilitated_pd

union

select *
from self_paced_pd
)

select *
from combined
Loading