Skip to content
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
4 changes: 4 additions & 0 deletions models/_docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ The section, subsection, unit, and part number of the problem block. In the form
Boolean indicating whether the responses were correct
{% enddocs %}

{% docs problem_id %}
Unique identifier for the problem
{% enddocs %}

{% docs object_tag_source %}
Course objects and their associated tags from CMS events:
`COURSE_CREATED, XBLOCK_CREATED, LIBRARY_BLOCK_CREATED, CONTENT_OBJECT_ASSOCIATIONS_CHANGED`
Expand Down
15 changes: 14 additions & 1 deletion models/navigation/fact_navigation_completion.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ select
pages.item_count as page_count,
pages.section_with_name as section_with_name,
pages.subsection_with_name as subsection_with_name,
date(navigation.emission_time) as visited_on
max(date(navigation.emission_time)) as visited_on,
pages.subsection_block_id as subsection_block_id,
pages.section_block_id as section_block_id
from {{ ref("navigation_events") }} navigation
join
{{ ref("dim_course_blocks") }} blocks
Expand All @@ -27,3 +29,14 @@ join
and pages.section_number = blocks.section_number
and pages.subsection_number = blocks.subsection_number
)
group by
org,
course_key,
block_id,
course_order,
actor_id,
page_count,
section_with_name,
subsection_with_name,
subsection_block_id,
section_block_id
71 changes: 35 additions & 36 deletions models/navigation/fact_pageview_engagement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,33 @@ with
select
org,
course_key,
course_order,
actor_id,
'section' as section_content_level,
'subsection' as subsection_content_level,
page_count,
count(block_id) as pages_visited,
section_with_name,
subsection_with_name
subsection_with_name,
subsection_block_id,
section_block_id
from {{ ref("fact_navigation_completion") }}
group by
org,
course_key,
course_order,
actor_id,
page_count,
section_with_name,
subsection_with_name
subsection_with_name,
subsection_block_id,
section_block_id
),
pageview_engagement as (
select
org,
course_key,
course_order,
actor_id,
sum(pages_visited) as pages_visited,
sum(page_count) as page_count,
case
when pages_visited = 0
then 'No pages viewed yet'
Expand All @@ -36,48 +39,44 @@ with
end as section_subsection_page_engagement,
section_with_name,
section_subsection_name,
content_level
content_level,
block_id
from pageview_section_subsection ARRAY
join
arrayConcat(
[subsection_with_name], [section_with_name]
) as section_subsection_name,
arrayConcat(
[subsection_content_level], [section_content_level]
) as content_level
) as content_level,
arrayConcat([subsection_block_id], [section_block_id]) as block_id
group by
org,
course_key,
course_order,
actor_id,
section_subsection_page_engagement,
section_subsection_name,
section_with_name,
content_level
),
final_results as (
select
pageview_engagement.org as org,
pageview_engagement.course_key as course_key,
pageview_engagement.section_subsection_name as section_subsection_name,
pageview_engagement.content_level as content_level,
pageview_engagement.actor_id as actor_id,
pageview_engagement.section_subsection_page_engagement
as section_subsection_page_engagement,
pageview_engagement.section_with_name as section_with_name,
pageview_engagement.course_order as course_order,
users.username as username,
users.name as name,
users.email as email
from pageview_engagement
left outer join
{{ ref("dim_user_pii") }} users
on (
pageview_engagement.actor_id like 'mailto:%'
and SUBSTRING(pageview_engagement.actor_id, 8) = users.email
)
or pageview_engagement.actor_id = toString(users.external_user_id)
where section_subsection_name <> ''
content_level,
block_id
)
select
pageview_engagement.org as org,
pageview_engagement.course_key as course_key,
pageview_engagement.section_subsection_name as section_subsection_name,
pageview_engagement.content_level as content_level,
pageview_engagement.actor_id as actor_id,
pageview_engagement.section_subsection_page_engagement
as section_subsection_page_engagement,
pageview_engagement.section_with_name as section_with_name,
users.username as username,
users.name as name,
users.email as email
from pageview_engagement
left outer join
{{ ref("dim_user_pii") }} users
on (
pageview_engagement.actor_id like 'mailto:%'
and SUBSTRING(pageview_engagement.actor_id, 8) = users.email
)
select *
from final_results
or pageview_engagement.actor_id = toString(users.external_user_id)
where section_subsection_name <> ''
6 changes: 6 additions & 0 deletions models/navigation/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ models:
- name: visited_on
data_type: Date
description: '{{ doc("emission_time") }}'
- name: subsection_block_id
data_type: String
description: '{{ doc("subsection_block_id") }}'
- name: section_block_id
data_type: String
description: '{{ doc("section_block_id") }}'

- name: fact_pageview_engagement
description: "A view for analyzing the number of page views per learner per section and subsection"
Expand Down
79 changes: 79 additions & 0 deletions models/problems/dim_problem_coursewide_avg.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{{
config(
materialized="materialized_view",
engine=get_engine("ReplacingMergeTree()"),
order_by="(org, course_key, problem_id, actor_id)",
primary_key="(org, course_key, problem_id, actor_id)",
)
}}

with
last_response as (
select
org,
course_key,
problem_link,
problem_id,
actor_id,
course_order,
graded,
case when success then attempts else 0 end as success_attempt,
case when not success then attempts else 0 end as incorrect_attempt
from {{ ref("dim_learner_last_response") }}
),
coursewide_attempts as (
select
org,
course_key,
problem_id,
avg(success_attempt) as avg_correct_attempts,
avg(incorrect_attempt) as avg_incorrect_attempts,
cast(countIf(success_attempt > 0) as Float32)
/ count(*) as coursewide_percent_correct
from last_response
group by org, course_key, problem_id
)
select
last_response.org as org,
last_response.course_key as course_key,
last_response.course_order as course_order,
last_response.problem_link as problem_link,
last_response.graded as graded,
last_response.actor_id as actor_id,
last_response.problem_id as problem_id, -- used for primary key
cast(
coursewide_attempts.avg_correct_attempts as Float32
) as avg_correct_attempts_coursewide,
cast(
coursewide_attempts.avg_incorrect_attempts as Float32
) as avg_incorrect_attempts_coursewide,
cast(
coursewide_attempts.coursewide_percent_correct as Float32
) as coursewide_percent_correct,
last_response.success_attempt as correct_attempts_by_learner,
last_response.incorrect_attempt as incorrect_attempts_by_learner,
cast(
CountIf(success_attempt > 0) / count(1) as Float32
) as selected_learner_percent_correct,
cast(
CountIf(incorrect_attempt > 0) / count(1) as Float32
) as selected_learner_percent_incorrect
from last_response
join
coursewide_attempts
on last_response.org = coursewide_attempts.org
and last_response.course_key = coursewide_attempts.course_key
and last_response.problem_id = coursewide_attempts.problem_id
group by
org,
course_key,
course_order,
problem_link,
problem_id,
graded,
actor_id,
avg_correct_attempts_coursewide,
avg_incorrect_attempts_coursewide,
coursewide_percent_correct,
correct_attempts_by_learner,
incorrect_attempts_by_learner
2 changes: 1 addition & 1 deletion models/problems/dim_problem_responses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
config(
materialized="materialized_view",
engine=get_engine("ReplacingMergeTree()"),
primary_key="(course_key, block_id_short)",
primary_key="(course_key, block_id_short, response)",
order_by="(course_key, block_id_short, response)",
)
}}
Expand Down
2 changes: 1 addition & 1 deletion models/problems/dim_problem_results.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
config(
materialized="materialized_view",
engine=get_engine("ReplacingMergeTree()"),
primary_key="(course_key, block_id_short)",
primary_key="(course_key, block_id_short, actor_id)",
order_by="(course_key, block_id_short, actor_id)",
)
}}
Expand Down
51 changes: 51 additions & 0 deletions models/problems/dim_subsection_performance.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{
config(
materialized="materialized_view",
engine=get_engine("ReplacingMergeTree()"),
primary_key="(org, course_key, block_id, score_range)",
order_by="(org, course_key, block_id, score_range)",
)
}}

with
avg_actor as (
select org, course_key, block_id_short, avg(scaled_score) as avg_score, actor_id
from {{ ref("dim_subsection_problem_results") }}
group by org, course_key, block_id_short, actor_id
),
avg_total as (
select org, course_key, block_id_short, avg(scaled_score) as total_avg
from {{ ref("dim_subsection_problem_results") }}
group by org, course_key, block_id_short
),
score_ranges as (
select
org,
course_key,
block_id_short,
case
when round(avg_score * 100, 2) > 90
then '>90%'
when round(avg_score * 100, 2) > 70
then '71-90%'
when round(avg_score * 100, 2) > 50
then '51-70%'
when round(avg_score * 100, 2) > 30
then '31-50%'
when round(avg_score * 100, 2) > 0
then '1-30%'
else '0%'
end as score_range,
count(1) as score_range_count
from avg_actor
group by org, course_key, block_id_short, score_range
)
select
score_ranges.org as org,
score_ranges.course_key as course_key,
score_ranges.block_id_short as block_id,
cast(round(avg_total.total_avg, 2) as Float32) as total_avg,
score_ranges.score_range as score_range,
score_ranges.score_range_count as score_range_count
from score_ranges
join avg_total using (org, course_key, block_id_short)
5 changes: 3 additions & 2 deletions models/problems/dim_subsection_problem_results.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
config(
materialized="materialized_view",
engine=get_engine("ReplacingMergeTree()"),
primary_key="(course_key, block_id_short)",
order_by="(course_key, block_id_short, actor_id)",
primary_key="(course_key, block_id_short, actor_id, problem_id)",
order_by="(course_key, block_id_short, actor_id, problem_id)",
)
}}

Expand Down Expand Up @@ -56,6 +56,7 @@ select
org,
course_key,
block_id_short,
problem_id,
problem_number,
problem_name_location,
actor_id,
Expand Down
3 changes: 0 additions & 3 deletions models/problems/fact_problem_engagement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ with
select
problems.org as org,
problems.course_key as course_key,
items.subsection_course_order as course_order,
problems.actor_id as actor_id,
items.item_count as item_count,
problems.problem_id as problem_id,
Expand Down Expand Up @@ -32,7 +31,6 @@ with
select
org,
course_key,
course_order,
actor_id,
'section' as section_content_level,
'subsection' as subsection_content_level,
Expand All @@ -46,7 +44,6 @@ with
group by
org,
course_key,
course_order,
actor_id,
item_count,
section_block_id,
Expand Down
Loading