Skip to content

Commit

Permalink
add engagement totals mart table marts__combined_total_course_engagem…
Browse files Browse the repository at this point in the history
…ents (#1444)

* add engagement totals mart table marts__combined_total_course_engagements
  • Loading branch information
KatelynGit authored Jan 22, 2025
1 parent c30474d commit 9f8f8f1
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/ol_dbt/models/marts/combined/_marts__combined__models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,44 @@ models:
if courserun_start_on is in the past and blank courserun_end_on, or courserun_start_on
is in the past and courserun_end_on is in the future.

- name: marts__combined_total_course_engagements
description: Total courserun engagement statistics from MITx Online, xPro, edX.org,
Residential MITx.
columns:
- name: platform
description: str, open edx platform, e.g., MITx Online, edX.org, xPro, Residential
MITx.
tests:
- not_null
- name: courserun_readable_id
description: str, the open edX course ID formatted as course-v1:{org}+{course
code}+{run_tag} for MITxOnline, xPro, Residential courses, {org}/{course}/{run_tag}
for edX.org courses.
tests:
- not_null
- name: total_courserun_problems
description: int, number of problems in a courserun
- name: total_courserun_videos
description: int, number of videos in a courserun
- name: total_courserun_discussions
description: int, number of discussions in a courserun
- name: courserun_title
description: str, title of the course run
- name: course_readable_id
description: str, Open edX ID formatted as course-v1:{org}+{course code} for MITx
Online, xPro or Residential courses, {org}/{course} for edX.org courses.
- name: courserun_is_current
description: boolean, indicating if the course run is currently running. True
if courserun_start_on is in the past and blank courserun_end_on, or courserun_start_on
is in the past and courserun_end_on is in the future.
- name: courserun_start_on
description: timestamp, datetime on when the course begins
- name: courserun_end_on
description: timestamp, datetime on when the course ends
tests:
- dbt_expectations.expect_compound_columns_to_be_unique:
column_list: ["platform", "courserun_readable_id"]

- name: marts__combined_course_engagements
description: Learners daily course engagement statistics from MITx Online, xPro,
edX.org, Residential MITx.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
with combined_engagements as (
select
platform
, courserun_readable_id
, count(
distinct
case
when coursestructure_block_category = 'discussion'
then coursestructure_block_id
end
) as total_courserun_discussions
, count(
distinct
case
when coursestructure_block_category = 'video'
then coursestructure_block_id
end
) as total_courserun_videos
, count(
distinct
case
when coursestructure_block_category = 'problem'
then coursestructure_block_id
end
) as total_courserun_problems
from {{ ref('int__combined__course_structure') }}
group by
platform
, courserun_readable_id
)

, combined_runs as (
select *
from {{ ref('int__combined__course_runs') }}
where courserun_readable_id is not null
)

select
combined_runs.platform
, combined_runs.courserun_readable_id
, combined_engagements.total_courserun_problems
, combined_engagements.total_courserun_videos
, combined_engagements.total_courserun_discussions
, combined_runs.courserun_title
, combined_runs.course_readable_id
, combined_runs.courserun_is_current
, combined_runs.courserun_start_on
, combined_runs.courserun_end_on
from combined_runs
inner join combined_engagements
on
combined_runs.courserun_readable_id = combined_engagements.courserun_readable_id
and combined_runs.platform = combined_engagements.platform

0 comments on commit 9f8f8f1

Please sign in to comment.