Skip to content

Commit

Permalink
Merge pull request #32 from SoryRawyer/rds/add-extended-block-name-docs
Browse files Browse the repository at this point in the history
feat: add block name with location to models (FC-0033)
  • Loading branch information
bmtcril authored Oct 17, 2023
2 parents ae81ed2 + d0b5945 commit caaaeba
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 4 deletions.
3 changes: 2 additions & 1 deletion models/base/dim_course_blocks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ select
courses.course_name as course_name,
courses.course_run as course_run,
blocks.location as block_id,
blocks.block_name as block_name
blocks.block_name as block_name,
blocks.display_name_with_location as display_name_with_location
from
{{ source('event_sink', 'course_block_names') }} blocks
join {{ source('event_sink', 'course_names')}} courses
Expand Down
21 changes: 21 additions & 0 deletions models/base/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2

models:
- name: dim_course_blocks
description: "A denormalized table of course block information"
columns:
- name: org
data_type: String
- name: course_key
data_type: String
- name: course_name
data_type: String
- name: course_run
data_type: String
- name: block_id
data_type: String
- name: block_name
data_type: String
- 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"
4 changes: 3 additions & 1 deletion models/base/sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ sources:
- name: org
- name: verb_id
- name: scaled_score

- name: completions_events
identifier: "{{ env_var('ASPECTS_COMPLETION_EVENTS_TABLE', 'completion_events') }}"
columns:
Expand Down Expand Up @@ -117,6 +117,8 @@ sources:
- name: location
- name: block_name
- name: course_key
- name: graded
- name: display_name_with_location

- name: course_names
columns:
Expand Down
1 change: 1 addition & 0 deletions models/completion/fact_completions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ select
courses.course_run as course_run,
completions.entity_id as entity_id,
if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,
if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,
completions.actor_id as actor_id,
cast(completions.scaled_progress as Float) as scaled_progress,
case
Expand Down
15 changes: 14 additions & 1 deletion models/completion/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,32 @@ version: 2

models:
- name: fact_completions
database: "{{ env_var('DBT_PROFILE_TARGET_DATABASE', 'reporting') }}"
description: "One record per completion events for component"
columns:
- name: emission_time
description: "Timestamp, to the second, of when this event was emitted"
data_type: DateTime64(3)
- name: org
data_type: String
- name: course_key
data_type: String
- name: course_name
data_type: String
- name: course_run
data_type: String
- name: entity_id
description: "The block ID or course key for the graded entity"
data_type: String
- name: entity_name
data_type: String
- name: entity_name_with_location
data_type: Nullable(String)
- name: actor_id
- name: progress_percent
data_type: String
- name: scaled_progress
description: "A ratio between 0 and 1, inclusive, of the learner's progress"
data_type: Float32
- name: completion_bucket
description: "A displayable value of progress sorted into 10% buckets. Useful for grouping progress together to show high-level learner performance"
data_type: String
7 changes: 7 additions & 0 deletions models/enrollment/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ models:
columns:
- name: emission_time
description: "Timestamp, to the second, of when this event was emitted"
data_type: DateTime
- name: org
data_type: String
- name: course_name
data_type: String
- name: course_run
data_type: String
- name: actor_id
data_type: String
- name: enrollment_mode
data_type: LowCardinality(String)
- name: enrollment_status
description: "Whether a learner is actively enrolled in a course"
tests:
- accepted_values:
values: ["registered", "unregistered"]
data_type: String
24 changes: 24 additions & 0 deletions models/forum/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 2

models:
- name: fact_forum_interactions
description: "One record per forum interaction"
columns:
- name: event_id
data_type: UUID
- name: emission_time
data_type: DateTime64(3)
- name: org
data_type: String
- name: course_key
data_type: String
- name: course_name
data_type: String
- name: course_run
data_type: String
- name: object_id
data_type: String
- name: actor_id
data_type: String
- name: verb_id
data_type: LowCardinality(String)
1 change: 1 addition & 0 deletions models/grading/fact_grades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ select
courses.course_run as course_run,
grades.entity_id as entity_id,
if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,
if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,
grades.grade_type as grade_type,
grades.actor_id as actor_id,
cast(grades.scaled_score as Float) as scaled_score,
Expand Down
13 changes: 13 additions & 0 deletions models/grading/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,33 @@ models:
columns:
- name: emission_time
description: "Timestamp, to the second, of when this event was emitted"
data_type: DateTime64(3)
- name: org
data_type: String
- name: course_key
data_type: String
- name: course_name
data_type: String
- name: course_run
data_type: String
- name: entity_id
description: "The block ID or course key for the graded entity"
data_type: String
- name: entity_name
data_type: String
- name: entity_name_with_location
data_type: Nullable(String)
- name: grade_type
description: "The type of object graded"
tests:
- accepted_values:
values: ["course", "subsection", "problem"]
data_type: Nullable(String)
- name: actor_id
data_type: String
- name: scaled_score
description: "A ratio between 0 and 1, inclusive, of the learner's grade"
data_type: Float32
- name: grade_bucket
description: "A displayable value of grades sorted into 10% buckets. Useful for grouping grades together to show high-level learner performance"
data_type: String
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 @@ -8,6 +8,7 @@ with results_with_hints as (
course_run,
problem_id,
problem_name,
problem_name_with_location,
actor_id,
success,
attempts,
Expand All @@ -22,6 +23,7 @@ with results_with_hints as (
course_run,
problem_id,
problem_name,
problem_name_with_location,
actor_id,
null as success,
null as attempts,
Expand All @@ -47,6 +49,7 @@ select
course_run,
problem_id,
problem_name,
problem_name_with_location,
actor_id,
coalesce(any(success), false) as success,
coalesce(any(attempts), 0) as attempts,
Expand All @@ -61,4 +64,5 @@ group by
course_run,
problem_id,
problem_name,
problem_name_with_location,
actor_id
1 change: 1 addition & 0 deletions models/problems/fact_problem_responses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ select
blocks.course_run as course_run,
responses.problem_id as problem_id,
blocks.block_name as problem_name,
blocks.display_name_with_location as problem_name_with_location,
responses.actor_id as actor_id,
responses.responses as responses,
responses.success as success,
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 @@ -24,6 +24,7 @@ select
blocks.course_run as course_run,
hints.problem_id as problem_id,
blocks.block_name as problem_name,
blocks.display_name_with_location as problem_name_with_location,
hints.actor_id as actor_id,
hints.help_type as help_type
from
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 @@ -71,6 +71,7 @@ select
course_run,
problem_id,
problem_name,
problem_name_with_location,
actor_id,
responses,
success,
Expand Down
26 changes: 26 additions & 0 deletions models/problems/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,65 @@ models:
description: "One record per learner per problem in a course"
columns:
- name: org
data_type: String
- name: course_key
data_type: String
- name: course_name
data_type: String
- name: course_run
data_type: String
- name: problem_id
data_type: String
- name: problem_name
data_type: String
- name: problem_name_with_location
data_type: String
- name: actor_id
data_type: String
- name: success
description: "The result of the last submission"
tests:
- not_null
data_type: Bool
- name: attempts
description: "The number of attempts made"
tests:
- not_null
data_type: Int16
- name: num_hints_displayed
description: "The number of times a learner asked for a hint"
data_type: UInt64
- name: num_answers_displayed
description: "The number of times a learner requested the answers for the problem"
data_type: UInt64

- name: fact_problem_responses
description: "One record for each submitted response to a problem"
columns:
- name: emission_time
data_type: DateTime
- name: org
data_type: String
- name: course_key
data_type: String
- name: course_name
data_type: String
- name: course_run
data_type: String
- name: problem_id
data_type: String
- name: problem_name
data_type: String
- name: problem_name_with_location
data_type: String
- name: actor_id
data_type: String
- name: responses
description: "The responses for this submission. If a problem has multiple parts, values for all parts will be in this field"
data_type: String
- name: success
description: "Boolean indicating whether the responses were correct"
data_type: Bool
- name: attempts
description: "Number indicating which attempt this was"
data_type: Int16
1 change: 1 addition & 0 deletions models/video/fact_transcript_usage.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ select
blocks.course_run as course_run,
transcripts.video_id as video_id,
blocks.block_name as video_name,
blocks.display_name_with_location as video_name_with_location,
transcripts.actor_id as actor_id
from
transcripts
Expand Down
1 change: 1 addition & 0 deletions models/video/fact_video_plays.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ select
blocks.course_run as course_run,
plays.video_id as video_id,
blocks.block_name as video_name,
blocks.display_name_with_location as video_name_with_location,
plays.actor_id as actor_id
from
plays
Expand Down
20 changes: 20 additions & 0 deletions models/video/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,42 @@ models:
description: "One record for each time a learner played a video"
columns:
- name: emission_time
data_type: DateTime
- name: org
data_type: String
- name: course_key
data_type: String
- name: course_name
data_type: String
- name: course_run
data_type: String
- name: video_id
data_type: String
- name: video_name
data_type: String
- name: video_name_with_location
data_type: String
- name: actor_id
data_type: String

- name: fact_transcript_usage
description: "One record for each time a transcript or closed caption was enabled"
columns:
- name: emission_time
data_type: DateTime
- name: org
data_type: String
- name: course_key
data_type: String
- name: course_name
data_type: String
- name: course_run
data_type: String
- name: video_id
data_type: String
- name: video_name
data_type: String
- name: video_name_with_location
data_type: String
- name: actor_id
data_type: String
2 changes: 1 addition & 1 deletion packages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
packages:
- package: dbt-labs/codegen
version: 0.9.0
version: 0.11.0
- package: dbt-labs/dbt_utils
version: 1.1.0

0 comments on commit caaaeba

Please sign in to comment.