Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
saraburns1 committed Jan 24, 2025
1 parent 6b16c18 commit 3ffaf49
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 108 deletions.
1 change: 0 additions & 1 deletion models/courses/dim_course_names.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ inner join
on mr.org = co.org
and mr.course_key = co.course_key
and co.time_last_dumped = mr.last_modified

3 changes: 2 additions & 1 deletion models/enrollment/fact_enrollments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ select
users.name as name,
users.email as email
from {{ ref("int_enrollment_events") }} enrollments
join {{ ref("dim_course_names") }} courses on enrollments.course_key = courses.course_key
join
{{ ref("dim_course_names") }} courses on enrollments.course_key = courses.course_key
left outer join
{{ ref("dim_user_pii") }} users
on (actor_id like 'mailto:%' and SUBSTRING(actor_id, 8) = users.email)
Expand Down
7 changes: 1 addition & 6 deletions models/grading/dim_most_recent_course_state.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ with
partition by org, course_key, actor_id order by emission_time desc
) as rn
from {{ ref("int_grading_events") }}
where
verb_id in (
'http://adlnet.gov/expapi/verbs/passed',
'http://adlnet.gov/expapi/verbs/failed'
)
and not empty(approving_state)
where not empty(approving_state)
)

select org, course_key, actor_id, approving_state, emission_time
Expand Down
64 changes: 34 additions & 30 deletions models/navigation/fact_navigation_completion.sql
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
-- number of learners who've viewed all pages in a section/subsection
with visited_subsection_pages as (
select distinct
date(navigation.emission_time) as visited_on,
navigation.org as org,
navigation.course_key as course_key,
blocks.course_name as course_name,
blocks.course_run as course_run,
{{ section_from_display("blocks.display_name_with_location") }} as section_number,
{{ subsection_from_display("blocks.display_name_with_location") }} as subsection_number,
navigation.actor_id as actor_id,
navigation.block_id as block_id,
users.username as username,
users.name as name,
users.email as email
from {{ ref("int_navigation_events") }} navigation
join
{{ ref("dim_course_blocks") }} blocks
on (
navigation.course_key = blocks.course_key
and navigation.block_id = blocks.block_id
)
left outer join
{{ ref("dim_user_pii") }} users
on (actor_id like 'mailto:%' and SUBSTRING(actor_id, 8) = users.email)
or actor_id = toString(users.external_user_id)
),
pages_per_subsection as (
select * from ({{ items_per_subsection("%@vertical+block@%") }})
)
with
visited_subsection_pages as (
select distinct
date(navigation.emission_time) as visited_on,
navigation.org as org,
navigation.course_key as course_key,
blocks.course_name as course_name,
blocks.course_run as course_run,
{{ section_from_display("blocks.display_name_with_location") }}
as section_number,
{{ subsection_from_display("blocks.display_name_with_location") }}
as subsection_number,
navigation.actor_id as actor_id,
navigation.block_id as block_id,
users.username as username,
users.name as name,
users.email as email
from {{ ref("int_navigation_events") }} navigation
join
{{ ref("dim_course_blocks") }} blocks
on (
navigation.course_key = blocks.course_key
and navigation.block_id = blocks.block_id
)
left outer join
{{ ref("dim_user_pii") }} users
on (actor_id like 'mailto:%' and SUBSTRING(actor_id, 8) = users.email)
or actor_id = toString(users.external_user_id)
),
pages_per_subsection as (
select * from ({{ items_per_subsection("%@vertical+block@%") }})
)
select
visits.visited_on as visited_on,
visits.org as org,
Expand All @@ -44,7 +47,8 @@ select
visits.name as name,
visits.email as email
from visited_subsection_pages visits
join pages_per_subsection pages
join
pages_per_subsection pages
on (
visits.org = pages.org
and visits.course_key = pages.course_key
Expand Down
3 changes: 2 additions & 1 deletion models/problems/fact_section_problem_engagement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
)
}}

with fact_problem_responses as (
with
fact_problem_responses as (
select
emission_time as emission_time,
org as org,
Expand Down
5 changes: 3 additions & 2 deletions models/problems/fact_subsection_problem_engagement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
)
}}

with fact_problem_responses as (
with
fact_problem_responses as (
select
emission_time as emission_time,
org as org,
Expand All @@ -24,7 +25,7 @@ with fact_problem_responses as (
success as success,
attempts as attempts,
interaction_type as interaction_type
from {{ ref("int_problem_events") }}
from {{ ref("int_problem_events") }}
where verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated'
group by
-- multi-part questions include an extra record for the response to the
Expand Down
90 changes: 44 additions & 46 deletions models/problems/int_problem_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,54 @@
)
}}

with events as (
select
event_id,
cast(emission_time as DateTime) as emission_time,
actor_id,
object_id,
course_key,
org,
verb_id,
JSON_VALUE(event, '$.result.response') as responses,
JSONExtractFloat(event, 'result', 'score', 'scaled') as scaled_score,
if(
verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',
cast(JSON_VALUE(event, '$.result.success') as Bool),
false
) as success,
toLowCardinality(
JSON_VALUE(event, '$.object.definition.interactionType')
) as interaction_type,
if(
verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',
cast(
JSON_VALUE(
event,
'$.object.definition.extensions."http://id.tincanapi.com/extension/attempt-id"'
) as Int16
),
0
) as attempts,
{{ get_problem_id("object_id") }} as problem_id
from {{ ref("xapi_events_all_parsed") }} xapi
where
verb_id in (
'https://w3id.org/xapi/acrossx/verbs/evaluated',
'http://adlnet.gov/expapi/verbs/passed',
'http://adlnet.gov/expapi/verbs/asked'
)
)
select events.*,
with
events as (
select
event_id,
cast(emission_time as DateTime) as emission_time,
actor_id,
object_id,
course_key,
org,
verb_id,
JSON_VALUE(event, '$.result.response') as responses,
JSONExtractFloat(event, 'result', 'score', 'scaled') as scaled_score,
if(
verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',
cast(JSON_VALUE(event, '$.result.success') as Bool),
false
) as success,
toLowCardinality(
JSON_VALUE(event, '$.object.definition.interactionType')
) as interaction_type,
if(
verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',
cast(
JSON_VALUE(
event,
'$.object.definition.extensions."http://id.tincanapi.com/extension/attempt-id"'
) as Int16
),
0
) as attempts,
{{ get_problem_id("object_id") }} as problem_id
from {{ ref("xapi_events_all_parsed") }} xapi
where
verb_id in (
'https://w3id.org/xapi/acrossx/verbs/evaluated',
'http://adlnet.gov/expapi/verbs/passed',
'http://adlnet.gov/expapi/verbs/asked'
)
)
select
events.*,
course_name,
block_name,
display_name_with_location,
{{ a_tag("object_id", "display_name_with_location") }}
as problem_link,
{{ a_tag("object_id", "display_name_with_location") }} as problem_link,
graded,
course_order
from events
join
join
{{ ref("dim_course_blocks") }} blocks
on (
events.course_key = blocks.course_key
and events.problem_id = blocks.block_id
)
on (events.course_key = blocks.course_key and events.problem_id = blocks.block_id)
2 changes: 1 addition & 1 deletion models/users/dim_user_pii.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
select external_user_id, username, name, email from {{ ref("user_pii") }} user_pii
select external_user_id, username, name, email from {{ ref("user_pii") }} user_pii
44 changes: 24 additions & 20 deletions models/video/fact_video_plays.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,29 @@ with
from {{ ref("int_video_playback_events") }}
where verb_id = 'https://w3id.org/xapi/video/verbs/played'
),
course_blocks_ext as (
select blocks.*, section_blocks.display_name_with_location as section_with_name, subsection_blocks.display_name_with_location as subsection_with_name
from {{ ref("dim_course_blocks") }} blocks
left join
{{ ref("dim_course_blocks") }} section_blocks
on (
blocks.section_number = section_blocks.hierarchy_location
and blocks.org = section_blocks.org
and blocks.course_key = section_blocks.course_key
and section_blocks.block_id like '%@chapter+block@%'
)
left join
{{ ref("dim_course_blocks") }} subsection_blocks
on (
blocks.subsection_number = subsection_blocks.hierarchy_location
and blocks.org = subsection_blocks.org
and blocks.course_key = subsection_blocks.course_key
and subsection_blocks.block_id like '%@sequential+block@%'
course_blocks_ext as (
select
blocks.*,
section_blocks.display_name_with_location as section_with_name,
subsection_blocks.display_name_with_location as subsection_with_name
from {{ ref("dim_course_blocks") }} blocks
left join
{{ ref("dim_course_blocks") }} section_blocks
on (
blocks.section_number = section_blocks.hierarchy_location
and blocks.org = section_blocks.org
and blocks.course_key = section_blocks.course_key
and section_blocks.block_id like '%@chapter+block@%'
)
left join
{{ ref("dim_course_blocks") }} subsection_blocks
on (
blocks.subsection_number = subsection_blocks.hierarchy_location
and blocks.org = subsection_blocks.org
and blocks.course_key = subsection_blocks.course_key
and subsection_blocks.block_id like '%@sequential+block@%'
)
)
)
select
plays.emission_time as emission_time,
plays.org as org,
Expand All @@ -57,7 +60,8 @@ select
blocks.subsection_with_name as subsection_with_name,
blocks.course_order as course_order
from plays
join course_blocks_ext blocks
join
course_blocks_ext blocks
on (plays.course_key = blocks.course_key and plays.video_id = blocks.block_id)
left outer join
{{ ref("dim_user_pii") }} users
Expand Down

0 comments on commit 3ffaf49

Please sign in to comment.