From c8360f2fd3150d6b91292f1818e83b8840152941 Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Wed, 15 May 2024 15:01:29 -0500 Subject: [PATCH] test: add fact_problem_engagement_v2 --- .../problems/fact_problem_engagement_v2.sql | 52 +++++++++++++++++++ .../problems/section_problem_engagement.sql | 13 ++--- .../subsection_problem_engagement.sql | 6 ++- 3 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 models/problems/fact_problem_engagement_v2.sql diff --git a/models/problems/fact_problem_engagement_v2.sql b/models/problems/fact_problem_engagement_v2.sql new file mode 100644 index 00000000..7d20ee13 --- /dev/null +++ b/models/problems/fact_problem_engagement_v2.sql @@ -0,0 +1,52 @@ +with + subsection_engagement as ( + select + org, + course_key, + course_run, + content_level, + actor_id, + subsection_block_id as block_id, + section_subsection_problem_engagement + from {{ ref("subsection_problem_engagement") }} + ), + section_engagement as ( + select + org, + course_key, + course_run, + content_level, + actor_id, + section_block_id as block_id, + section_subsection_problem_engagement + from {{ ref("section_problem_engagement") }} + ), + problem_engagement as ( + select * + from subsection_engagement + union all + select * + from section_engagement + ) +select + pe.org as org, + pe.course_key as course_key, + pe.course_run as course_run, + course_blocks.display_name_with_location as section_subsection_name, + pe.content_level as content_level, + pe.actor_id as actor_id, + pe.section_subsection_problem_engagement as section_subsection_problem_engagement, + users.username as username, + users.name as name, + users.email as email +from problem_engagement pe +join + {{ ref("dim_course_blocks") }} course_blocks + on ( + pe.org = course_blocks.org + and pe.course_key = course_blocks.course_key + and pe.block_id = course_blocks.block_id + ) +left outer join + {{ ref("dim_user_pii") }} users + on toUUID(pe.actor_id) = users.external_user_id diff --git a/models/problems/section_problem_engagement.sql b/models/problems/section_problem_engagement.sql index 72ff0d80..65afd815 100644 --- a/models/problems/section_problem_engagement.sql +++ b/models/problems/section_problem_engagement.sql @@ -50,8 +50,10 @@ with and responses.problem_id = blocks.block_id ) group by - -- multi-part questions include an extra record for the response to the first - -- part of the question. this group by clause eliminates the duplicate record + -- multi-part questions include an extra record for the response to the + -- first + -- part of the question. this group by clause eliminates the duplicate + -- record emission_time, org, course_key, @@ -151,12 +153,7 @@ with end as engagement_level, section_block_id from subsection_counts - group by - org, - course_key, - course_run, - section_block_id, - actor_id + group by org, course_key, course_run, section_block_id, actor_id ) select diff --git a/models/problems/subsection_problem_engagement.sql b/models/problems/subsection_problem_engagement.sql index b7a72ff2..d4dec067 100644 --- a/models/problems/subsection_problem_engagement.sql +++ b/models/problems/subsection_problem_engagement.sql @@ -50,8 +50,10 @@ with and responses.problem_id = blocks.block_id ) group by - -- multi-part questions include an extra record for the response to the first - -- part of the question. this group by clause eliminates the duplicate record + -- multi-part questions include an extra record for the response to the + -- first + -- part of the question. this group by clause eliminates the duplicate + -- record emission_time, org, course_key,