Skip to content

Commit ba51bc8

Browse files
authored
add video metrics to instructor reporting (#1797)
* add video metrics to instructor reporting
1 parent 7d67964 commit ba51bc8

2 files changed

Lines changed: 193 additions & 34 deletions

File tree

src/ol_dbt/models/reporting/_reporting__models.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,11 @@ models:
400400
the subsection.
401401
- name: chatbot_type
402402
description: string, type of the chatbot. e.g. Syllabus, Tutor, etc.
403+
- name: estimated_time_played
404+
description: int, estimated video seconds played
405+
- name: video_duration
406+
description: int, legth of the video in seconds
407+
- name: rewatch_indicator
408+
description: boolean, true if the learner is rewatching the video
409+
- name: video_watched_count
410+
description: int, count of videos watched

src/ol_dbt/models/reporting/instructor_module_report.sql

Lines changed: 185 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,189 @@ with chatbot_events as (
1010
select * from {{ ref('dim_user') }}
1111
)
1212

13+
, enrollment_detail as (
14+
select * from {{ ref('marts__combined_course_enrollment_detail') }}
15+
)
16+
17+
, video_events as (
18+
select * from {{ ref('tfact_video_events') }}
19+
)
20+
21+
, video as (
22+
select * from {{ ref('dim_video') }}
23+
)
24+
25+
, video_pre_query as (
26+
select
27+
video_events.user_fk
28+
, video_events.courserun_readable_id
29+
, video_events.video_block_fk
30+
, max(video_events.video_duration) as video_duration
31+
, max(video_events.video_position) as end_time
32+
, min(case when video_events.event_type = 'play_video' then video_events.video_position end) as start_time
33+
from video_events
34+
inner join user
35+
on video_events.user_fk = user.user_pk
36+
where
37+
video_events.event_type in (
38+
'play_video'
39+
, 'seek_video'
40+
, 'pause_video'
41+
, 'stop_video'
42+
, 'complete_video'
43+
)
44+
group by
45+
video_events.user_fk
46+
, video_events.courserun_readable_id
47+
, video_events.video_block_fk
48+
)
49+
50+
, video_watches as (
51+
select
52+
user.email
53+
, video_events.courserun_readable_id
54+
, video_events.video_block_fk
55+
, cast(video_events.event_timestamp as date) as activity_date
56+
, lag(cast(video_events.event_timestamp as date)) over (partition by user.email
57+
, video_events.courserun_readable_id
58+
, video_events.video_block_fk order by cast(video_events.event_timestamp as date)) AS PreviousDATE
59+
from video_events
60+
inner join user
61+
on video_events.user_fk = user.user_pk
62+
where
63+
video_events.event_type in (
64+
'play_video'
65+
)
66+
group by
67+
user.email
68+
, video_events.courserun_readable_id
69+
, video_events.video_block_fk
70+
, cast(video_events.event_timestamp as date)
71+
)
72+
73+
, video_views_table as (
74+
select
75+
a.courserun_readable_id
76+
, a.video_block_fk
77+
, v.block_category
78+
, v.block_title
79+
, cc_section.block_title as section_title
80+
, cc_subsection.block_title as subsection_title
81+
, user.email
82+
, sum(
83+
cast(case when a.end_time = 'null' then '0' else a.end_time end as decimal(30, 10))
84+
- cast(case when a.start_time = 'null' then '0' else a.start_time end as decimal(30, 10))
85+
)
86+
as estimated_time_played
87+
, sum(a.video_duration) as video_duration
88+
from video_pre_query as a
89+
inner join video as c
90+
on
91+
a.courserun_readable_id = c.courserun_readable_id
92+
and a.video_block_fk = substring(c.video_block_pk, regexp_position(c.video_block_pk, 'block@') + 6)
93+
inner join user
94+
on a.user_fk = user.user_pk
95+
left join course_content as v
96+
on
97+
c.content_block_fk = v.content_block_pk
98+
and a.courserun_readable_id = v.courserun_readable_id
99+
left join course_content as cc_subsection
100+
on
101+
v.parent_block_id = cc_subsection.block_id
102+
and a.courserun_readable_id = cc_subsection.courserun_readable_id
103+
and cc_subsection.is_latest = true
104+
left join course_content as cc_section
105+
on
106+
cc_subsection.parent_block_id = cc_section.block_id
107+
and a.courserun_readable_id = cc_section.courserun_readable_id
108+
and cc_section.is_latest = true
109+
group by
110+
a.courserun_readable_id
111+
, a.video_block_fk
112+
, v.block_category
113+
, v.block_title
114+
, cc_section.block_title
115+
, cc_subsection.block_title
116+
, user.email
117+
)
118+
119+
, combined_data as (
120+
select
121+
video_views_table.email as user_email
122+
, video_watches.activity_date
123+
, video_views_table.courserun_readable_id
124+
, 0 as chatbot_used_count
125+
, video_views_table.block_category
126+
, video_views_table.block_title
127+
, video_views_table.section_title
128+
, video_views_table.subsection_title
129+
, null as chatbot_type
130+
, video_views_table.estimated_time_played
131+
, video_views_table.video_duration
132+
, case when video_watches.PreviousDATE is not null then true else false end as rewatch_indicator
133+
, 1 as video_watched_count
134+
from video_views_table
135+
inner join video_watches
136+
on
137+
video_views_table.courserun_readable_id = video_watches.courserun_readable_id
138+
and video_views_table.video_block_fk = video_watches.video_block_fk
139+
and video_views_table.email = video_watches.email
140+
141+
union all
142+
143+
select
144+
user.email as user_email
145+
, cast(chatbot_events.event_timestamp as date) as activity_date
146+
, chatbot_events.courserun_readable_id
147+
, count(distinct chatbot_events.session_id || chatbot_events.block_id) as chatbot_used_count
148+
, c.block_category
149+
, c.block_title
150+
, section.block_title as section_title
151+
, subsection.block_title as subsection_title
152+
, chatbot_events.chatbot_type
153+
, null as estimated_time_played
154+
, null as video_duration
155+
, null as rewatch_indicator
156+
, null as video_watched_count
157+
from chatbot_events
158+
inner join user
159+
on chatbot_events.user_fk = user.user_pk
160+
left join course_content as c
161+
on
162+
chatbot_events.block_id = c.block_id
163+
and c.is_latest = true
164+
left join course_content as section
165+
on
166+
c.chapter_block_id = section.block_id
167+
and section.is_latest = true
168+
left join course_content as subsection
169+
on
170+
c.sequential_block_id = subsection.block_id
171+
and subsection.is_latest = true
172+
where chatbot_events.event_type = 'ol_openedx_chat.drawer.submit'
173+
group by
174+
user.email
175+
, cast(chatbot_events.event_timestamp as date)
176+
, chatbot_events.courserun_readable_id
177+
, c.block_category
178+
, c.block_title
179+
, section.block_title
180+
, subsection.block_title
181+
, chatbot_events.chatbot_type
182+
)
183+
13184
select
14-
user.email as user_email
15-
, cast(chatbot_events.event_timestamp as date) as activity_date
16-
, chatbot_events.courserun_readable_id
17-
, count(distinct chatbot_events.session_id || chatbot_events.block_id) as chatbot_used_count
18-
, c.block_category
19-
, c.block_title
20-
, section.block_title as section_title
21-
, subsection.block_title as subsection_title
22-
, chatbot_events.chatbot_type
23-
from chatbot_events
24-
inner join user
25-
on chatbot_events.user_fk = user.user_pk
26-
left join course_content as c
27-
on
28-
chatbot_events.block_id = c.block_id
29-
and c.is_latest = true
30-
left join course_content as section
31-
on
32-
c.chapter_block_id = section.block_id
33-
and section.is_latest = true
34-
left join course_content as subsection
35-
on
36-
c.sequential_block_id = subsection.block_id
37-
and subsection.is_latest = true
38-
where chatbot_events.event_type = 'ol_openedx_chat.drawer.submit'
39-
group by
40-
user.email
41-
, cast(chatbot_events.event_timestamp as date)
42-
, chatbot_events.courserun_readable_id
43-
, c.block_category
44-
, c.block_title
45-
, section.block_title
46-
, subsection.block_title
47-
, chatbot_events.chatbot_type
185+
user_email
186+
, activity_date
187+
, courserun_readable_id
188+
, chatbot_used_count
189+
, block_category
190+
, block_title
191+
, section_title
192+
, subsection_title
193+
, chatbot_type
194+
, estimated_time_played
195+
, video_duration
196+
, rewatch_indicator
197+
, video_watched_count
198+
from combined_data

0 commit comments

Comments
 (0)