Skip to content

Commit 3dbac76

Browse files
authored
create a new course staff report (#2011)
* create a new course staff report * nitpick from copilot
1 parent 1af6e92 commit 3dbac76

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

src/ol_dbt/models/reporting/_reporting__models.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,3 +1132,41 @@ models:
11321132
tests:
11331133
- dbt_expectations.expect_compound_columns_to_be_unique:
11341134
column_list: ["user_email", "chapter_title", "courserun_readable_id", "platform"]
1135+
1136+
- name: course_staff_report
1137+
description: Report of course staff members (instructors, staff, etc.) across all
1138+
platforms and their last course activity date
1139+
columns:
1140+
- name: platform
1141+
description: string, name of the platform (e.g. MITx Online, xPro, edX.org, Residential
1142+
MITx)
1143+
tests:
1144+
- not_null
1145+
- name: user_username
1146+
description: string, username of the course staff member on the platform
1147+
tests:
1148+
- not_null
1149+
- name: user_email
1150+
description: string, email address of the course staff member
1151+
- name: courserun_readable_id
1152+
description: string, unique identifier for the course run formatted as course-v1:{org}+{course
1153+
code}+{run_tag}
1154+
tests:
1155+
- not_null
1156+
- name: courserun_start_on
1157+
description: timestamp, date and time when the course run starts. May be null.
1158+
- name: courserun_end_on
1159+
description: timestamp, date and time when the course run ends. May be null.
1160+
- name: courserun_is_current
1161+
description: boolean, indicating if the course run is currently running. True
1162+
if courserun_start_on is in the past and blank courserun_end_on, or courserun_start_on
1163+
is in the past and courserun_end_on is in the future.
1164+
- name: course_roles
1165+
description: string, comma-separated list of privilege levels assigned to the
1166+
user for working in this course run (e.g. instructor, staff, beta_testers)
1167+
- name: last_course_activity_date
1168+
description: date, the most recent date the staff member had any course activity
1169+
in this course run. May be null if the staff member has no recorded course activity.
1170+
tests:
1171+
- dbt_expectations.expect_compound_columns_to_be_unique:
1172+
column_list: ["platform", "user_username", "courserun_readable_id"]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
with combined_course_roles as (
2+
select
3+
platform
4+
, user_username
5+
, user_email
6+
, courserun_readable_id
7+
, {{ array_join('array_agg(courseaccess_role order by courseaccess_role)', ", ") }} as course_roles
8+
from {{ ref('int__combined__user_course_roles') }}
9+
group by platform, user_username, user_email, courserun_readable_id
10+
)
11+
12+
, combined_course_runs as (
13+
select * from {{ ref('int__combined__course_runs') }}
14+
)
15+
16+
, course_activities as (
17+
select
18+
platform
19+
, user_username
20+
, courserun_readable_id
21+
, max(courseactivity_date) as last_course_activity_date
22+
from {{ ref('marts__combined_course_engagements') }}
23+
group by platform, user_username, courserun_readable_id
24+
)
25+
26+
select
27+
combined_course_roles.platform
28+
, combined_course_roles.user_username
29+
, combined_course_roles.user_email
30+
, combined_course_roles.courserun_readable_id
31+
, combined_course_runs.courserun_start_on
32+
, combined_course_runs.courserun_end_on
33+
, combined_course_runs.courserun_is_current
34+
, combined_course_roles.course_roles
35+
, course_activities.last_course_activity_date
36+
from combined_course_roles
37+
left join combined_course_runs
38+
on combined_course_runs.platform = combined_course_roles.platform
39+
and combined_course_runs.courserun_readable_id = combined_course_roles.courserun_readable_id
40+
left join course_activities
41+
on course_activities.platform = combined_course_roles.platform
42+
and course_activities.user_username = combined_course_roles.user_username
43+
and course_activities.courserun_readable_id = combined_course_roles.courserun_readable_id

0 commit comments

Comments
 (0)