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/dim ambassador events #265

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions dbt/models/marts/misc/_misc_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,40 @@ models:
description: Defined by global team from the languages available in the Code.org platform as of December 2024. In case of multilingual countries, one of the languages selected as primary for reporting simplicity. In case the country's language is not used on the Code.org platform, the primary foreign language is indicated in the brackets (e.g. "other (French)" means the country has a different primary language, but French is the most widely spoken foreign language)
data_tests:
- not_null
config:
tags: ['released']

- name: dim_ambassador_events
description: |
this model provides information about every ambassador-led event, including the ambassador's responses in the event impact survey and/or their associated students' activity in the platform.
columns:
- name: user_id
description: unique ID for the ambassador's teacher account
data_tests:
- not_null
- name: code_studio_name
description: the name in code studio for the ambassador's teacher account
- name: email
description: the email associated with the ambassador's teacher account; this is PII and should not be shared externally without a privacy review.
- name: school_year
description: the school year associated with when the ambassador filled out the registration survey
- name: event_type
description: experience_cs or connect_with_cs; this is the event type the ambassador entered via the impact survey or, if they have >0 sections, it is labeled as experience_cs
- name: event_date
description: the event date as entered via the event impact survey, or in the case of no survey response, the date the first section was created
- name: survey_total_participants
description: the total number of participants at their event as entered on the event impact survey
- name: survey_num_pre_enrollment
description: the number of students indicating intent to enroll in CS at the start of the event
- name: survey_num_post_enrollment
description: the number of students indicating intent to enroll in CS at the end of the event
- name: impact_eval_flag
description: 1 if both pre and post enrollment numbers were reported and can be used to evaluate program impact, 0 otherwise
- name: num_sections
description: the number of sections associated with the ambassador's teacher account in that school year
- name: num_students_in_section
description: the number of students associated with the ambassador's sections in that school year
- name: courses_touched
description: the courses associated with the student activity in the ambassador's sections in that school year. Note that if the students in their section are doing courses outside of the ambassador's event, there is no way to differentiate this activity and it would count as a course here.
config:
tags: ['released']
3 changes: 2 additions & 1 deletion dbt/models/marts/misc/dim_ambassador_activity.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ select distinct
fs.user_id
, fs.code_studio_name
, fs.email
, fs.school_year
, s.section_id
, s.section_name
, s.created_at as section_created_dt
, sy.school_year
, sy.school_year as section_activity_school_year
, f.student_id
, cs.course_name
, cs.script_name
Expand Down
79 changes: 79 additions & 0 deletions dbt/models/marts/misc/dim_ambassador_events.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
with

amb_section_metrics as (
select
user_id,
code_studio_name,
email,
school_year,
min(section_created_dt) as section_created_dt,
count(distinct section_id) as num_sections,
count(distinct student_id) as num_students
from {{ ref('dim_ambassador_activity') }}
group by 1,2,3,4
having num_sections > 0
),

section_course_list as (
select
user_id,
school_year,
listagg(distinct course_name, ', ') within group (order by user_id, school_year) as courses_touched
from {{ ref('dim_ambassador_activity') }}
group by 1,2
),

event_impact_survey as (
select *
from (select
foorm_submission_id, user_id, school_year, item_name, response_text
from {{ ref('dim_foorms') }}
where form_name = 'surveys/teachers/cs_ambassador_event')
pivot(max(response_text) for item_name in (
'event_date',
'event_type',
'total_participants',
'num_pre_enrollment',
'num_post_enrollment'
)
)
)

select
asm.user_id,
asm.code_studio_name,
asm.email,
asm.school_year,
case
when eis.event_type = 'experience cs (in code studio)' then 'experience_cs'
when eis.event_type = 'connect with cs (not in code studio)' then 'connect with cs'
else
case
when asm.num_sections > 0 then 'experience_cs'
else eis.event_type
end
end as event_type,
coalesce(to_timestamp(eis.event_date, 'YYYY-MM-DD HH24:MI:SS'), date_trunc('day', asm.section_created_dt)) as event_date,
eis.total_participants as survey_total_participants,
eis.num_pre_enrollment as survey_num_pre_enrollment,
eis.num_post_enrollment as survey_num_post_enrollment,
case
when eis.num_pre_enrollment is not null and eis.num_post_enrollment is not null
then 1
else 0
end as impact_eval_flag,
asm.num_sections,
asm.num_students as num_students_in_section,
scl.courses_touched as section_courses_touched

from amb_section_metrics as asm

left join section_course_list as scl
on asm.user_id = scl.user_id
and asm.school_year = scl.school_year

left join event_impact_survey as eis
on asm.user_id = eis.user_id
and asm.school_year = eis.school_year


6 changes: 5 additions & 1 deletion dbt/models/marts/misc/dim_foorms.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ foorm_surveys as (
fsss.foorm_submission_id,
fsss.user_id,
fsss.created_at,
fsr.item_name,
case
when fsr.item_name = 'pre_enrollment' then 'num_pre_enrollment'
when fsr.item_name = 'post_enrollment' then 'num_post_enrollment'
else fsr.item_name
end as item_name,
fsr.matrix_item_name,
fsr.response_value,
fsr.response_text,
Expand Down