-
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.
Create MITx Online user activities intermediate model, updates to xPro (
#795) * Create MITx Online user activities intermediate model, updates to xPro * updates for production data * Create MITx Online user activities intermediate model, updates to xPro
- Loading branch information
1 parent
298b5db
commit 9dad1df
Showing
10 changed files
with
409 additions
and
153 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
65 changes: 65 additions & 0 deletions
65
src/ol_dbt/models/intermediate/mitxonline/int__mitxonline__user_courseactivities.sql
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,65 @@ | ||
with course_activities as ( | ||
select * from {{ ref('stg__mitxonline__openedx__tracking_logs__user_activity') }} | ||
where courserun_readable_id is not null | ||
) | ||
|
||
, course_activities_video as ( | ||
select * from {{ ref('int__mitxonline__user_courseactivity_video') }} | ||
) | ||
|
||
, problem_check as ( | ||
select * from {{ ref('int__mitxonline__user_courseactivity_problemcheck') }} | ||
) | ||
|
||
, problem_check_stats as ( | ||
select | ||
user_username | ||
, courserun_readable_id | ||
, max(useractivity_timestamp) as courseactivity_last_problem_check_timestamp | ||
from problem_check | ||
group by user_username, courserun_readable_id | ||
) | ||
|
||
, play_video_stats as ( | ||
select | ||
user_username | ||
, courserun_readable_id | ||
, count(distinct useractivity_video_id) as courseactivity_num_unique_play_video | ||
, count(*) as courseactivity_num_play_video | ||
, max(useractivity_timestamp) as courseactivity_last_play_video_timestamp | ||
from course_activities_video | ||
where useractivity_event_type = 'play_video' | ||
group by user_username, courserun_readable_id | ||
) | ||
|
||
, all_course_activities_stats as ( | ||
select | ||
user_username | ||
, courserun_readable_id | ||
, count(distinct date(from_iso8601_timestamp(useractivity_timestamp))) as courseactivity_num_days_activity | ||
, count(*) as courseactivity_num_events | ||
, min(useractivity_timestamp) as courseactivity_first_event_timestamp | ||
, max(useractivity_timestamp) as courseactivity_last_event_timestamp | ||
from course_activities | ||
group by user_username, courserun_readable_id | ||
) | ||
|
||
select | ||
all_course_activities_stats.user_username | ||
, all_course_activities_stats.courserun_readable_id | ||
, all_course_activities_stats.courseactivity_num_days_activity | ||
, all_course_activities_stats.courseactivity_num_events | ||
, play_video_stats.courseactivity_num_unique_play_video | ||
, play_video_stats.courseactivity_num_play_video | ||
, play_video_stats.courseactivity_last_play_video_timestamp | ||
, problem_check_stats.courseactivity_last_problem_check_timestamp | ||
, all_course_activities_stats.courseactivity_first_event_timestamp | ||
, all_course_activities_stats.courseactivity_last_event_timestamp | ||
from all_course_activities_stats | ||
left join play_video_stats | ||
on | ||
all_course_activities_stats.user_username = play_video_stats.user_username | ||
and all_course_activities_stats.courserun_readable_id = play_video_stats.courserun_readable_id | ||
left join problem_check_stats on | ||
all_course_activities_stats.user_username = problem_check_stats.user_username | ||
and all_course_activities_stats.courserun_readable_id = problem_check_stats.courserun_readable_id |
24 changes: 24 additions & 0 deletions
24
..._dbt/models/intermediate/mitxonline/int__mitxonline__user_courseactivity_problemcheck.sql
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,24 @@ | ||
{{ config(materialized='view') }} | ||
|
||
with course_activities as ( | ||
select * from {{ ref('stg__mitxonline__openedx__tracking_logs__user_activity') }} | ||
where courserun_readable_id is not null | ||
) | ||
|
||
select | ||
user_username | ||
, courserun_readable_id | ||
, openedx_user_id | ||
, useractivity_event_type | ||
, useractivity_timestamp | ||
, json_query(useractivity_context_object, 'lax $.module.display_name' omit quotes) as useractivity_problem_name | ||
, json_query(useractivity_event_object, 'lax $.problem_id' omit quotes) as useractivity_problem_id | ||
, json_query(useractivity_event_object, 'lax $.attempts' omit quotes) as useractivity_problem_attempts | ||
, json_query(useractivity_event_object, 'lax $.success' omit quotes) as useractivity_problem_success | ||
, json_query(useractivity_event_object, 'lax $.grade' omit quotes) as useractivity_problem_current_grade | ||
, json_query(useractivity_event_object, 'lax $.max_grade' omit quotes) as useractivity_problem_max_grade | ||
from course_activities | ||
where useractivity_event_type = 'problem_check' | ||
--- This event emitted by the browser contain all of the GET parameters, | ||
-- only events emitted by the server are useful | ||
and useractivity_event_source = 'server' |
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
Oops, something went wrong.