Skip to content

Commit 3089709

Browse files
authored
Merge branch 'main' into fix/country_name_hoc_events
2 parents b163b2b + 7f5749d commit 3089709

File tree

4 files changed

+121
-2
lines changed

4 files changed

+121
-2
lines changed

dbt/models/marts/misc/_misc_models.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,40 @@ models:
202202
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)
203203
data_tests:
204204
- not_null
205+
config:
206+
tags: ['released']
207+
208+
- name: dim_ambassador_events
209+
description: |
210+
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.
211+
columns:
212+
- name: user_id
213+
description: unique ID for the ambassador's teacher account
214+
data_tests:
215+
- not_null
216+
- name: code_studio_name
217+
description: the name in code studio for the ambassador's teacher account
218+
- name: email
219+
description: the email associated with the ambassador's teacher account; this is PII and should not be shared externally without a privacy review.
220+
- name: school_year
221+
description: the school year associated with when the ambassador filled out the registration survey
222+
- name: event_type
223+
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
224+
- name: event_date
225+
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
226+
- name: survey_total_participants
227+
description: the total number of participants at their event as entered on the event impact survey
228+
- name: survey_num_pre_enrollment
229+
description: the number of students indicating intent to enroll in CS at the start of the event
230+
- name: survey_num_post_enrollment
231+
description: the number of students indicating intent to enroll in CS at the end of the event
232+
- name: impact_eval_flag
233+
description: 1 if both pre and post enrollment numbers were reported and can be used to evaluate program impact, 0 otherwise
234+
- name: num_sections
235+
description: the number of sections associated with the ambassador's teacher account in that school year
236+
- name: num_students_in_section
237+
description: the number of students associated with the ambassador's sections in that school year
238+
- name: courses_touched
239+
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.
205240
config:
206241
tags: ['released']

dbt/models/marts/misc/dim_ambassador_activity.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ select distinct
3535
fs.user_id
3636
, fs.code_studio_name
3737
, fs.email
38+
, fs.school_year
3839
, s.section_id
3940
, s.section_name
4041
, s.created_at as section_created_dt
41-
, sy.school_year
42+
, sy.school_year as section_activity_school_year
4243
, f.student_id
4344
, cs.course_name
4445
, cs.script_name
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
with
2+
3+
amb_section_metrics as (
4+
select
5+
user_id,
6+
code_studio_name,
7+
email,
8+
school_year,
9+
min(section_created_dt) as section_created_dt,
10+
count(distinct section_id) as num_sections,
11+
count(distinct student_id) as num_students
12+
from {{ ref('dim_ambassador_activity') }}
13+
group by 1,2,3,4
14+
having num_sections > 0
15+
),
16+
17+
section_course_list as (
18+
select
19+
user_id,
20+
school_year,
21+
listagg(distinct course_name, ', ') within group (order by user_id, school_year) as courses_touched
22+
from {{ ref('dim_ambassador_activity') }}
23+
group by 1,2
24+
),
25+
26+
event_impact_survey as (
27+
select *
28+
from (select
29+
foorm_submission_id, user_id, school_year, item_name, response_text
30+
from {{ ref('dim_foorms') }}
31+
where form_name = 'surveys/teachers/cs_ambassador_event')
32+
pivot(max(response_text) for item_name in (
33+
'event_date',
34+
'event_type',
35+
'total_participants',
36+
'num_pre_enrollment',
37+
'num_post_enrollment'
38+
)
39+
)
40+
)
41+
42+
select
43+
asm.user_id,
44+
asm.code_studio_name,
45+
asm.email,
46+
asm.school_year,
47+
case
48+
when eis.event_type = 'experience cs (in code studio)' then 'experience_cs'
49+
when eis.event_type = 'connect with cs (not in code studio)' then 'connect with cs'
50+
else
51+
case
52+
when asm.num_sections > 0 then 'experience_cs'
53+
else eis.event_type
54+
end
55+
end as event_type,
56+
coalesce(to_timestamp(eis.event_date, 'YYYY-MM-DD HH24:MI:SS'), date_trunc('day', asm.section_created_dt)) as event_date,
57+
cast(eis.total_participants as int) as survey_total_participants,
58+
cast(eis.num_pre_enrollment as int) as survey_num_pre_enrollment,
59+
cast(eis.num_post_enrollment as int) as survey_num_post_enrollment,
60+
case
61+
when eis.num_pre_enrollment is not null and eis.num_post_enrollment is not null
62+
then 1
63+
else 0
64+
end as impact_eval_flag,
65+
asm.num_sections,
66+
asm.num_students as num_students_in_section,
67+
scl.courses_touched as section_courses_touched
68+
69+
from amb_section_metrics as asm
70+
71+
left join section_course_list as scl
72+
on asm.user_id = scl.user_id
73+
and asm.school_year = scl.school_year
74+
75+
left join event_impact_survey as eis
76+
on asm.user_id = eis.user_id
77+
and asm.school_year = eis.school_year
78+
79+

dbt/models/marts/misc/dim_foorms.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ foorm_surveys as (
2828
fsss.foorm_submission_id,
2929
fsss.user_id,
3030
fsss.created_at,
31-
fsr.item_name,
31+
case
32+
when fsr.item_name = 'pre_enrollment' then 'num_pre_enrollment'
33+
when fsr.item_name = 'post_enrollment' then 'num_post_enrollment'
34+
else fsr.item_name
35+
end as item_name,
3236
fsr.matrix_item_name,
3337
fsr.response_value,
3438
fsr.response_text,

0 commit comments

Comments
 (0)