-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from openedx/cag/problem-performance
feat: move response status to a MV feat: move problem engagement to an mv
- Loading branch information
Showing
13 changed files
with
507 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ on: | |
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
DBT_PROFILES_DIR: ./.github/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,49 @@ | ||
with | ||
subsection_counts as ( | ||
subsection_engagement as ( | ||
select | ||
org, | ||
course_key, | ||
course_run, | ||
section_with_name, | ||
subsection_with_name, | ||
actor_id, | ||
item_count, | ||
count(distinct problem_id) as problems_attempted, | ||
case | ||
when problems_attempted = 0 | ||
then 'No problems attempted yet' | ||
when problems_attempted = item_count | ||
then 'All problems attempted' | ||
else 'At least one problem attempted' | ||
end as engagement_level, | ||
username, | ||
name, | ||
from {{ ref("fact_problem_engagement_per_subsection") }} | ||
group by | ||
org, | ||
course_key, | ||
course_run, | ||
section_with_name, | ||
subsection_with_name, | ||
'subsection' as content_level, | ||
actor_id, | ||
item_count, | ||
username, | ||
name, | ||
subsection_block_id as block_id, | ||
engagement_level as section_subsection_problem_engagement | ||
from {{ ref("subsection_problem_engagement") }} | ||
), | ||
section_counts as ( | ||
section_engagement as ( | ||
select | ||
org, | ||
course_key, | ||
course_run, | ||
section_with_name, | ||
actor_id, | ||
sum(item_count) as item_count, | ||
sum(problems_attempted) as problems_attempted, | ||
case | ||
when problems_attempted = 0 | ||
then 'No problems attempted yet' | ||
when problems_attempted = item_count | ||
then 'All problems attempted' | ||
else 'At least one problem attempted' | ||
end as engagement_level, | ||
username, | ||
name, | ||
from subsection_counts | ||
group by | ||
org, | ||
course_key, | ||
course_run, | ||
section_with_name, | ||
'section' as content_level, | ||
actor_id, | ||
username, | ||
name, | ||
section_block_id as block_id, | ||
engagement_level as section_subsection_problem_engagement | ||
from {{ ref("section_problem_engagement") }} | ||
), | ||
problem_engagement as ( | ||
select | ||
org, | ||
course_key, | ||
course_run, | ||
subsection_with_name as section_subsection_name, | ||
'subsection' as content_level, | ||
actor_id as actor_id, | ||
engagement_level as section_subsection_problem_engagement, | ||
username, | ||
name, | ||
from subsection_counts | ||
select * | ||
from subsection_engagement | ||
union all | ||
select | ||
org, | ||
course_key, | ||
course_run, | ||
section_with_name as section_subsection_name, | ||
'section' as content_level, | ||
actor_id as actor_id, | ||
engagement_level as section_subsection_problem_engagement, | ||
username, | ||
name, | ||
from section_counts | ||
select * | ||
from section_engagement | ||
) | ||
|
||
select | ||
pe.org as org, | ||
pe.course_key as course_key, | ||
pe.course_run as course_run, | ||
pe.section_subsection_name as section_subsection_name, | ||
course_blocks.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, | ||
pe.username as username, | ||
pe.name as name, | ||
pe.email as email | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
-- select one record per (learner, problem, course, org) tuple | ||
-- contains either the first successful attempt | ||
-- or the most recent unsuccessful attempt | ||
-- find the timestamp of the earliest successful response | ||
-- this will be used to pick the xAPI event corresponding to that submission | ||
{{ | ||
config( | ||
materialized="materialized_view", | ||
schema=env_var("ASPECTS_XAPI_DATABASE", "xapi"), | ||
engine=get_engine("ReplacingMergeTree()"), | ||
primary_key="(org, course_key, problem_id)", | ||
order_by="(org, course_key, problem_id, actor_id)", | ||
partition_by="toYYYYMM(emission_time)", | ||
ttl=env_var("ASPECTS_DATA_TTL_EXPRESSION", ""), | ||
) | ||
}} | ||
|
||
with | ||
responses as ( | ||
select emission_time, org, course_key, object_id, problem_id, actor_id, success | ||
from {{ ref("problem_events") }} | ||
where verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated' | ||
), | ||
response_status as ( | ||
select | ||
org, | ||
course_key, | ||
problem_id, | ||
actor_id, | ||
MIN(case when success then emission_time else NULL end) as first_success_at, | ||
MAX(emission_time) as last_attempt_at | ||
from responses | ||
group by org, course_key, problem_id, actor_id | ||
) | ||
select | ||
org, | ||
course_key, | ||
problem_id, | ||
actor_id, | ||
first_success_at, | ||
last_attempt_at, | ||
coalesce(first_success_at, last_attempt_at) as emission_time | ||
from response_status |
Oops, something went wrong.