Skip to content

Commit

Permalink
Merge pull request #70 from openedx/cag/user-information
Browse files Browse the repository at this point in the history
feat: join user_pii data with reports
  • Loading branch information
Cristhian Garcia authored Apr 18, 2024
2 parents f5ce938 + 9c96262 commit 1540bd5
Show file tree
Hide file tree
Showing 22 changed files with 258 additions and 37 deletions.
8 changes: 7 additions & 1 deletion models/completion/fact_completions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ select
when scaled_progress >= 0.1 and scaled_progress < 0.2
then '10-19%'
else '0-9%'
end as completion_bucket
end as completion_bucket,
users.username as username,
users.name as name,
users.email as email
from completions
join {{ ref("course_names") }} courses on completions.course_key = courses.course_key
left join
{{ ref("course_block_names") }} blocks on completions.entity_id = blocks.location
left outer join
{{ ref("dim_user_pii") }} users
on toUUID(completions.actor_id) = users.external_user_id
9 changes: 9 additions & 0 deletions models/completion/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ models:
- 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
- name: username
data_type: String
description: "The username of the learner"
- name: name
data_type: String
description: "The full name of the learner"
- name: email
data_type: String
description: "The email address of the learner"

- name: completion_events
description: "A materialized view for xAPI events related to course completions"
Expand Down
7 changes: 6 additions & 1 deletion models/enrollment/fact_enrollments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ select
courses.course_run as course_run,
enrollments.actor_id as actor_id,
enrollments.enrollment_mode as enrollment_mode,
enrollments.enrollment_status as enrollment_status
enrollments.enrollment_status as enrollment_status,
users.username as username,
users.name as name,
users.email as email
from enrollments
join {{ ref("course_names") }} courses on enrollments.course_key = courses.course_key
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
9 changes: 9 additions & 0 deletions models/enrollment/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ models:
- accepted_values:
values: ["registered", "unregistered"]
data_type: String
- name: username
data_type: String
description: "The username of the learner"
- name: name
data_type: String
description: "The full name of the learner"
- name: email
data_type: String
description: "The email address of the learner"

- name: enrollment_events
description: "A materialized view for xAPI events related to course enrollment"
Expand Down
7 changes: 6 additions & 1 deletion models/forum/fact_forum_interactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ select
courses.course_run as course_run,
forum.object_id as object_id,
forum.actor_id as actor_id,
forum.verb_id as verb_id
forum.verb_id as verb_id,
users.username as username,
users.name as name,
users.email as email
from {{ ref("forum_events") }} forum
join {{ ref("course_names") }} courses on (forum.course_key = courses.course_key)
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
9 changes: 9 additions & 0 deletions models/forum/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ models:
- name: verb_id
data_type: LowCardinality(String)
description: "The xAPI verb identifier"
- name: username
data_type: String
description: "The username of the learner"
- name: name
data_type: String
description: "The full name of the learner"
- name: email
data_type: String
description: "The email address of the learner"

- name: forum_events
description: "One record per forum event"
Expand Down
7 changes: 6 additions & 1 deletion models/grading/fact_grades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ select
grades.grade_type as grade_type,
grades.actor_id as actor_id,
grades.scaled_score as scaled_score,
{{ get_bucket("scaled_score") }} as grade_bucket
{{ get_bucket("scaled_score") }} as grade_bucket,
users.username as username,
users.name as name,
users.email as email
from grades
join {{ ref("course_names") }} courses on grades.course_key = courses.course_key
left join {{ ref("course_block_names") }} blocks on grades.entity_id = blocks.location
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
7 changes: 6 additions & 1 deletion models/grading/fact_student_status.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ select
enrollment_mode,
enrollment_status,
course_grade as course_grade,
{{ get_bucket("course_grade") }} as grade_bucket
{{ get_bucket("course_grade") }} as grade_bucket,
users.username as username,
users.name as name,
users.email as email
from {{ ref("fact_enrollment_status") }} fes
left join
{{ ref("fact_learner_course_status") }} lg
Expand All @@ -24,3 +27,5 @@ join
{{ ref("course_names") }} courses
on fes.org = courses.org
and fes.course_key = courses.course_key
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
18 changes: 18 additions & 0 deletions models/grading/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ models:
- 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
- name: username
data_type: String
description: "The username of the learner"
- name: name
data_type: String
description: "The full name of the learner"
- name: email
data_type: String
description: "The email address of the learner"

- name: fact_learner_course_grade
description: "One record per learner per course for the most recent grade"
Expand Down Expand Up @@ -149,3 +158,12 @@ models:
- name: grade_bucket
data_type: string
description: "A displayable value of grades sorted into 10% buckets. Useful for grouping grades together to show high-level learner performance"
- name: username
data_type: String
description: "The username of the learner"
- name: name
data_type: String
description: "The full name of the learner"
- name: email
data_type: String
description: "The email address of the learner"
7 changes: 6 additions & 1 deletion models/navigation/fact_navigation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ select
blocks.display_name_with_location as block_name_with_location,
navigation.object_type as object_type,
navigation.starting_position as starting_position,
navigation.ending_point as ending_point
navigation.ending_point as ending_point,
users.username as username,
users.name as name,
users.email as email
from {{ ref("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 toUUID(actor_id) = users.external_user_id
25 changes: 16 additions & 9 deletions models/navigation/fact_navigation_completion.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ with
date(emission_time) as visited_on,
org,
course_key,
course_name,
course_run,
{{ section_from_display("block_name_with_location") }} as section_number,
{{ subsection_from_display("block_name_with_location") }}
Expand All @@ -15,15 +16,19 @@ with
)

select
visits.visited_on,
visits.org,
visits.course_key,
visits.course_run,
pages.section_with_name,
pages.subsection_with_name,
pages.page_count,
visits.actor_id,
visits.block_id
visits.visited_on as visited_on,
visits.org as org,
visits.course_key as course_key,
visits.course_name as course_name,
visits.course_run as course_run,
pages.section_with_name as section_with_name,
pages.subsection_with_name as subsection_with_name,
pages.page_count as page_count,
visits.actor_id as actor_id,
visits.block_id as block_id,
users.username as username,
users.name as name,
users.email as email
from visited_subsection_pages visits
join
{{ ref("int_pages_per_subsection") }} pages
Expand All @@ -33,3 +38,5 @@ join
and visits.section_number = pages.section_number
and visits.subsection_number = pages.subsection_number
)
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
7 changes: 6 additions & 1 deletion models/navigation/fact_navigation_dropoff.sql
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ select
page_views.rollup_name as rollup_name,
blocks.display_name_with_location as block_name,
page_views.actor_id as actor_id,
page_views.total_views as total_views
page_views.total_views as total_views,
users.username as username,
users.name as name,
users.email as email
from page_views
join
blocks
Expand All @@ -73,3 +76,5 @@ join
and page_views.course_key = blocks.course_key
and page_views.hierarchy_location = blocks.hierarchy_location
)
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
31 changes: 29 additions & 2 deletions models/navigation/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ models:
- name: ending_point
data_type: string
description: "The tab in the unit navigation bar that the learner selected to navigate to"
- name: username
data_type: String
description: "The username of the learner"
- name: name
data_type: String
description: "The full name of the learner"
- name: email
data_type: String
description: "The email address of the learner"

- name: fact_navigation_dropoff
description: "A view for analyzing the number of page visits per learner per section and subsection"
Expand Down Expand Up @@ -102,6 +111,15 @@ models:
- name: total_views
data_type: uint64
description: "The total number of times a learner viewed pages in this section or subsection on a given day"
- name: username
data_type: String
description: "The username of the learner"
- name: name
data_type: String
description: "The full name of the learner"
- name: email
data_type: String
description: "The email address of the learner"

- name: fact_navigation_completion
description: "A view for analyzing how many pages a learner has visited in a section or subsection"
Expand All @@ -115,9 +133,9 @@ models:
- name: course_key
data_type: string
description: "The course identifier"
- name: course_run
- name: course_name
data_type: string
description: "The course run for the course"
description: "The course name"
- name: course_run
data_type: string
description: "The course run for the course"
Expand All @@ -136,6 +154,15 @@ models:
- name: block_id
data_type: string
description: "The ID of the specific page visited"
- name: username
data_type: String
description: "The username of the learner"
- name: name
data_type: String
description: "The full name of the learner"
- name: email
data_type: String
description: "The email address of the learner"

- name: int_pages_per_subsection
description: "A view for analyzing the number of pages in each subsection"
Expand Down
12 changes: 10 additions & 2 deletions models/problems/fact_learner_problem_summary.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ select
coalesce(any(success), false) as success,
coalesce(any(attempts), 0) as attempts,
sum(num_hints_displayed) as num_hints_displayed,
sum(num_answers_displayed) as num_answers_displayed
sum(num_answers_displayed) as num_answers_displayed,
users.username as username,
users.name as name,
users.email as email
from results_with_hints
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
group by
org,
course_key,
Expand All @@ -59,4 +64,7 @@ group by
problem_id,
problem_name,
problem_name_with_location,
actor_id
actor_id,
username,
name,
email
25 changes: 15 additions & 10 deletions models/problems/fact_problem_engagement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ with
)

select
attempts.attempted_on,
attempts.org,
attempts.course_key,
attempts.course_run,
problems.section_with_name,
problems.subsection_with_name,
problems.item_count,
attempts.actor_id,
attempts.problem_id,
attempts.graded
attempts.attempted_on as attempted_on,
attempts.org as org,
attempts.course_key as course_key,
attempts.course_run as course_run,
problems.section_with_name as section_with_name,
problems.subsection_with_name as subsection_with_name,
problems.item_count as item_count,
attempts.actor_id as actor_id,
attempts.problem_id as problem_id,
attempts.graded as graded,
users.username as username,
users.name as name,
users.email as email
from attempted_subsection_problems attempts
join
{{ ref("int_problems_per_subsection") }} problems
Expand All @@ -34,3 +37,5 @@ join
and attempts.section_number = problems.section_number
and attempts.subsection_number = problems.subsection_number
)
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
12 changes: 10 additions & 2 deletions models/problems/fact_problem_responses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ select
responses.responses as responses,
responses.success as success,
responses.attempts as attempts,
responses.interaction_type as interaction_type
responses.interaction_type as interaction_type,
users.username as username,
users.name as name,
users.email as email
from responses
join
{{ ref("dim_course_blocks") }} blocks
on (
responses.course_key = blocks.course_key
and responses.problem_id = blocks.block_id
)
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
group by
-- multi-part questions include an extra record for the response to the first
-- part of the question. this group by clause eliminates the duplicate record
Expand All @@ -55,4 +60,7 @@ group by
success,
attempts,
graded,
interaction_type
interaction_type,
username,
name,
email
7 changes: 6 additions & 1 deletion models/problems/fact_problem_responses_extended.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ select
results.success as success,
results.attempts as attempts,
results.graded as graded,
results.interaction_type as interaction_type
results.interaction_type as interaction_type,
users.username as username,
users.name as name,
users.email as email
from problem_results results
join
{{ ref("int_problems_per_subsection") }} problems
Expand All @@ -34,3 +37,5 @@ join
and results.section_number = problems.section_number
and results.subsection_number = problems.subsection_number
)
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
Loading

0 comments on commit 1540bd5

Please sign in to comment.