Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add block ordering to models #82

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion macros/items_per_subsection.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
course_key,
section_number,
subsection_number,
course_order,
graded,
count(*) as item_count
from {{ ref("dim_course_blocks") }}
where block_id like '{{ block_pattern }}'
group by org, course_key, section_number, subsection_number, graded
group by
org, course_key, section_number, subsection_number, course_order, graded
)

select
Expand All @@ -20,6 +22,7 @@
section_blocks.display_name_with_location as section_with_name,
ips.subsection_number as subsection_number,
subsection_blocks.display_name_with_location as subsection_with_name,
ips.course_order as course_order,
ips.graded as graded,
ips.item_count as item_count
from items_per_subsection ips
Expand Down
9 changes: 8 additions & 1 deletion models/courses/course_block_names.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
("block_name", "String"),
("course_key", "String"),
("graded", "Bool"),
("course_order", "Int32"),
("display_name_with_location", "String"),
],
primary_key="location",
Expand Down Expand Up @@ -35,6 +36,7 @@ with
JSONExtractInt(xblock_data_json, 'subsection') as subsection,
JSONExtractInt(xblock_data_json, 'unit') as unit,
JSONExtractBool(xblock_data_json, 'graded') as graded,
`order` as course_order,
course_key,
dump_id,
time_last_dumped,
Expand All @@ -44,6 +46,11 @@ with
from {{ source("event_sink", "course_blocks") }}
)
select
location, display_name as block_name, course_key, graded, display_name_with_location
location,
display_name as block_name,
course_key,
graded,
course_order,
display_name_with_location
from most_recent_course_blocks
where rn = 1
1 change: 1 addition & 0 deletions models/courses/dim_course_blocks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ select
as subsection_number,
splitByString(' - ', blocks.display_name_with_location)[1] as hierarchy_location,
blocks.display_name_with_location as display_name_with_location,
course_order,
graded,
case
when block_id like '%@chapter+block@%'
Expand Down
1 change: 1 addition & 0 deletions models/courses/dim_course_blocks_extended.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ select
blocks.hierarchy_location as hierarchy_location,
blocks.display_name_with_location as display_name_with_location,
blocks.graded as graded,
blocks.course_order as course_order,
blocks.block_type as block_type,
section_blocks.display_name_with_location as section_with_name,
subsection_blocks.display_name_with_location as subsection_with_name
Expand Down
9 changes: 9 additions & 0 deletions models/courses/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ models:
- name: block_type
data_type: String
description: "The type of block. This can be a section, subsection, unit, or the block type"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"

- name: course_block_names
description: "A table of course blocks with their names"
Expand All @@ -59,6 +62,9 @@ models:
- name: display_name_with_location
data_type: String
description: "The block's display name with section, subsection, and unit prepended to the name. This provides additional context when looking at block names and can help data consumers understand which block they are analyzing"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"

- name: course_names
description: "A table of courses with their names"
Expand Down Expand Up @@ -121,3 +127,6 @@ models:
- name: subsection_with_name
data_type: string
description: "The name of the section this subsection belongs to, with subsection_number prepended"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"
1 change: 1 addition & 0 deletions models/navigation/fact_navigation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ select
navigation.block_id as block_id,
blocks.block_name as block_name,
blocks.display_name_with_location as block_name_with_location,
blocks.course_order as course_order,
navigation.object_type as object_type,
navigation.starting_position as starting_position,
navigation.ending_point as ending_point,
Expand Down
1 change: 1 addition & 0 deletions models/navigation/fact_navigation_completion.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ select
visits.course_run as course_run,
pages.section_with_name as section_with_name,
pages.subsection_with_name as subsection_with_name,
pages.course_order as course_order,
pages.page_count as page_count,
visits.actor_id as actor_id,
visits.block_id as block_id,
Expand Down
8 changes: 7 additions & 1 deletion models/navigation/fact_navigation_dropoff.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
with
blocks as (
select org, course_key, display_name_with_location, hierarchy_location
select
org,
course_key,
display_name_with_location,
hierarchy_location,
course_order
from {{ ref("dim_course_blocks") }}
where block_id like '%@chapter+block@%' or block_id like '%@sequential+block@%'
),
Expand Down Expand Up @@ -63,6 +68,7 @@ select
page_views.course_key as course_key,
page_views.rollup_name as rollup_name,
blocks.display_name_with_location as block_name,
blocks.course_order as course_order,
page_views.actor_id as actor_id,
page_views.total_views as total_views,
users.username as username,
Expand Down
10 changes: 8 additions & 2 deletions models/navigation/int_pages_per_subsection.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
with
pages_per_subsection as (
select
org, course_key, section_number, subsection_number, count(*) as page_count
org,
course_key,
section_number,
subsection_number,
course_order,
count(*) as page_count
from {{ ref("dim_course_blocks") }}
where block_id like '%@vertical+block@%'
group by org, course_key, section_number, subsection_number
group by org, course_key, section_number, subsection_number, course_order
)

select
Expand All @@ -14,6 +19,7 @@ select
section_blocks.display_name_with_location as section_with_name,
pps.subsection_number as subsection_number,
subsection_blocks.display_name_with_location as subsection_with_name,
pps.course_order as course_order,
pps.page_count as page_count
from pages_per_subsection pps
left join
Expand Down
12 changes: 12 additions & 0 deletions models/navigation/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ models:
- name: email
data_type: String
description: "The email address of the learner"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"

- name: fact_navigation_dropoff
description: "A view for analyzing the number of page visits per learner per section and subsection"
Expand Down Expand Up @@ -120,6 +123,9 @@ models:
- name: email
data_type: String
description: "The email address of the learner"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"

- name: fact_navigation_completion
description: "A view for analyzing how many pages a learner has visited in a section or subsection"
Expand Down Expand Up @@ -163,6 +169,9 @@ models:
- name: email
data_type: String
description: "The email address of the learner"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"

- name: int_pages_per_subsection
description: "A view for analyzing the number of pages in each subsection"
Expand All @@ -188,3 +197,6 @@ models:
- name: page_count
data_type: uint64
description: The number of pages in the associated subsection
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"
4 changes: 4 additions & 0 deletions models/problems/fact_learner_problem_summary.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ with
problem_id,
problem_name,
problem_name_with_location,
course_order,
actor_id,
success,
attempts,
Expand All @@ -25,6 +26,7 @@ with
problem_id,
problem_name,
problem_name_with_location,
course_order,
actor_id,
null as success,
null as attempts,
Expand All @@ -45,6 +47,7 @@ select
problem_id,
problem_name,
problem_name_with_location,
course_order,
actor_id,
coalesce(any(success), false) as success,
coalesce(any(attempts), 0) as attempts,
Expand All @@ -64,6 +67,7 @@ group by
problem_id,
problem_name,
problem_name_with_location,
course_order,
actor_id,
username,
name,
Expand Down
2 changes: 2 additions & 0 deletions models/problems/fact_problem_engagement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ with
{{ section_from_display("problem_name_with_location") }} as section_number,
{{ subsection_from_display("problem_name_with_location") }}
as subsection_number,
course_order as course_order,
graded,
actor_id,
problem_id
Expand All @@ -24,6 +25,7 @@ select
problems.item_count as item_count,
attempts.actor_id as actor_id,
attempts.problem_id as problem_id,
attempts.course_order as course_order,
attempts.graded as graded,
users.username as username,
users.name as name,
Expand Down
2 changes: 2 additions & 0 deletions models/problems/fact_problem_responses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ select
blocks.display_name_with_location as problem_name_with_location,
{{ a_tag("responses.object_id", "blocks.block_name") }} as problem_link,
blocks.graded as graded,
course_order as course_order,
responses.actor_id as actor_id,
responses.responses as responses,
responses.success as success,
Expand Down Expand Up @@ -59,6 +60,7 @@ group by
responses,
success,
attempts,
course_order,
graded,
interaction_type,
username,
Expand Down
1 change: 1 addition & 0 deletions models/problems/fact_problem_responses_extended.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ select
results.responses as responses,
results.success as success,
results.attempts as attempts,
results.course_order as course_order,
results.graded as graded,
results.interaction_type as interaction_type,
users.username as username,
Expand Down
1 change: 1 addition & 0 deletions models/problems/int_problem_hints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ select
hints.problem_id as problem_id,
blocks.block_name as problem_name,
blocks.display_name_with_location as problem_name_with_location,
blocks.course_order as course_order,
hints.actor_id as actor_id,
hints.help_type as help_type
from hints
Expand Down
1 change: 1 addition & 0 deletions models/problems/int_problem_results.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ select
problem_id,
problem_name,
problem_name_with_location,
course_order,
problem_link,
actor_id,
responses,
Expand Down
21 changes: 21 additions & 0 deletions models/problems/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ models:
- name: email
data_type: String
description: "The email address of the learner"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"

- name: fact_problem_responses
description: "One record for each submitted response to a problem"
Expand Down Expand Up @@ -114,6 +117,9 @@ models:
- name: email
data_type: String
description: "The email address of the learner"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"

- name: int_problem_hints
description: "Internal table for problem hints"
Expand Down Expand Up @@ -148,6 +154,9 @@ models:
- name: help_type
data_type: string
description: "The type of help requested"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"

- name: int_problem_results
description: "Internal table for problem results"
Expand Down Expand Up @@ -197,6 +206,9 @@ models:
- name: interaction_type
data_type: string
description: "The type of interaction - e.g. multiple choice"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"

- name: problem_events
description: "Problem events"
Expand Down Expand Up @@ -265,6 +277,9 @@ models:
- name: item_count
data_type: uint64
description: "The number of problems in this subsection"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"

- name: fact_problem_engagement
description: "A dataset with one record representing a problem attempted by a learner and the section and subsection that problem belongs to"
Expand Down Expand Up @@ -308,6 +323,9 @@ models:
- name: email
data_type: String
description: "The email address of the learner"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"


- name: fact_problem_responses_extended
Expand Down Expand Up @@ -373,3 +391,6 @@ models:
- name: email
data_type: String
description: "The email address of the learner"
- name: course_order
data_type: Int32
description: "The sort order of this block in the course across all course blocks"
1 change: 1 addition & 0 deletions models/video/fact_transcript_usage.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ select
transcripts.video_id as video_id,
blocks.block_name as video_name,
blocks.display_name_with_location as video_name_with_location,
blocks.course_order as course_order,
transcripts.actor_id as actor_id,
users.username as username,
users.name as name,
Expand Down
1 change: 1 addition & 0 deletions models/video/fact_video_engagement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ select
views.course_run,
videos.section_with_name,
videos.subsection_with_name,
videos.course_order,
videos.item_count,
views.actor_id,
views.video_id,
Expand Down
3 changes: 2 additions & 1 deletion models/video/fact_video_plays.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ select
users.name as name,
users.email as email,
blocks.section_with_name as section_with_name,
blocks.subsection_with_name as subsection_with_name
blocks.subsection_with_name as subsection_with_name,
blocks.course_order as course_order
from plays
join
{{ ref("dim_course_blocks_extended") }} blocks
Expand Down
Loading