Skip to content

Commit

Permalink
Feature/user levels upstream update content fields (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
coryamanda authored Dec 1, 2024
2 parents be87b1f + 3bfa3b0 commit 55246db
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
26 changes: 18 additions & 8 deletions dbt/models/marts/students/dim_student_script_level_activity.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
-- version: 3.0 (Natalia)
-- 2024-10-01
-- Made changes to include all users with activity in student-facing content
-- 2024-11-27
-- Made changes to include fields content_area and topic_tags to classify curriculum (source:dim_user_levels)

with
/*
Expand All @@ -24,10 +26,12 @@ user_levels as (
created_date as activity_date,
extract('month' from created_date) as activity_month
from {{ ref('dim_user_levels') }}

),

course_structure as (
select
select distinct
content_area,
course_name,
course_id,
script_id,
Expand All @@ -39,12 +43,14 @@ course_structure as (
unit as unit_name,
stage_id as lesson_id,
stage_name as lesson_name,
topic_tags,
published_state
from {{ ref('dim_course_structure') }}
from {{ ref('dim_course_structure')}}
where
content_area like 'curriculum%' -- student-facing curriculum
or content_area in ('hoc') -- HOC activities

where participant_audience = 'student'
-- Note: filter out data we don't want or need as early as possible. If we keep it around, it will be continuously processed as it is referenced in other queries.
),
),

school_years as (
select *
Expand Down Expand Up @@ -72,6 +78,7 @@ student_activity as (
when ul.activity_month in ( 4, 5, 6 ) then 'Q4'
end as activity_quarter,

cs.content_area,
cs.course_name,
cs.level_name,
cs.level_type,
Expand All @@ -80,6 +87,7 @@ student_activity as (
cs.lesson_id,
cs.lesson_name,
cs.published_state,
cs.topic_tags,

-- aggs
ul.total_attempts,
Expand All @@ -88,7 +96,7 @@ student_activity as (

from user_levels as ul

left join course_structure as cs
join course_structure as cs -- Changed to join to keep only student-facing content
on ul.level_script_id = cs.level_script_id

join school_years as sy
Expand Down Expand Up @@ -139,8 +147,8 @@ sections as (
3. Teachers and Schools
a. Use student_id to connect to sections
b. Use teacher, school_id for statuses
c. select * that shit
d. almost forgot user_geo info
c. select *
d. user_geo info
*/

schools as (
Expand Down Expand Up @@ -235,6 +243,7 @@ final as (
sta.activity_quarter,

-- curriculum content of the activity
sta.content_area,
sta.course_name,
sta.unit_name,
sta.script_id,
Expand All @@ -245,6 +254,7 @@ final as (
sta.level_name,
sta.level_type,
sta.published_state,
sta.topic_tags,

-- activity metrics
sta.total_attempts,
Expand Down
6 changes: 5 additions & 1 deletion dbt/models/marts/teachers/dim_self_paced_pd_activity.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ course_structure as (
and instruction_type = 'self_paced'
)
and script_name not in ('alltheselfpacedplthings')
and course_name not like 'pd workshop activity%'
and content_area like '%self_paced_pl%'
),

user_levels as (
Expand Down Expand Up @@ -52,6 +52,8 @@ self_paced_scripts as (
, cs.level_number
, cs.level_script_order
, cs.course_name
, cs.content_area
, cs.topic_tags
, case
when cs.script_name ilike 'k5-onlinepd%' then 'csf'
when cs.script_name like 'self-paced-pl-k5%' then 'csf'
Expand Down Expand Up @@ -83,6 +85,8 @@ select distinct
, sps.stage_name
, sps.level_name
, sps.course_name
, sps.content_area
, sps.topic_tags
, sps.course_name_implementation
, ul.created_date as level_created_dt
, sy.school_year as level_created_school_year
Expand Down

0 comments on commit 55246db

Please sign in to comment.