diff --git a/tutoraspects/templates/openedx-assets/queries/active_last_7_days.sql b/tutoraspects/templates/openedx-assets/queries/active_last_7_days.sql index 5b6860455..294836a1a 100644 --- a/tutoraspects/templates/openedx-assets/queries/active_last_7_days.sql +++ b/tutoraspects/templates/openedx-assets/queries/active_last_7_days.sql @@ -2,10 +2,13 @@ with recent_activity as ( select course_key, COUNT(DISTINCT actor_id) as active_last_7_days from {{ ASPECTS_XAPI_DATABASE }}.navigation_events - where emission_time >= NOW() - INTERVAL 7 DAY + where + emission_time >= NOW() - INTERVAL 7 DAY + {% include 'openedx-assets/queries/common_filters.sql' %} group by course_key ) select fss.*, COALESCE(ra.active_last_7_days, 0) as active_within_last_7_days from {{ DBT_PROFILE_TARGET_DATABASE }}.fact_student_status fss left join recent_activity ra on fss.course_key = ra.course_key +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/at_risk_learner_filter.sql b/tutoraspects/templates/openedx-assets/queries/at_risk_learner_filter.sql index 09db324af..c051cbc5b 100644 --- a/tutoraspects/templates/openedx-assets/queries/at_risk_learner_filter.sql +++ b/tutoraspects/templates/openedx-assets/queries/at_risk_learner_filter.sql @@ -12,4 +12,6 @@ with select org, course_key, learners.actor_id as actor_id from {{ DBT_PROFILE_TARGET_DATABASE }}.fact_student_status learners join page_visits using (org, course_key, actor_id) -where approving_state = 'failed' and enrollment_status = 'registered' +where + approving_state = 'failed' and enrollment_status = 'registered' + {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/at_risk_problem_results.sql b/tutoraspects/templates/openedx-assets/queries/at_risk_problem_results.sql index a8bd54b33..254df792f 100644 --- a/tutoraspects/templates/openedx-assets/queries/at_risk_problem_results.sql +++ b/tutoraspects/templates/openedx-assets/queries/at_risk_problem_results.sql @@ -4,3 +4,4 @@ join ( {% include 'openedx-assets/queries/at_risk_learner_filter.sql' %} ) as at_risk_learners using (org, course_key, actor_id) +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/dim_at_risk_learners.sql b/tutoraspects/templates/openedx-assets/queries/dim_at_risk_learners.sql index 94a43a71f..db4c2e23a 100644 --- a/tutoraspects/templates/openedx-assets/queries/dim_at_risk_learners.sql +++ b/tutoraspects/templates/openedx-assets/queries/dim_at_risk_learners.sql @@ -29,3 +29,4 @@ where approving_state = 'failed' and enrollment_status = 'registered' and page_visits.last_visited < subtractDays(now(), 7) + {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/dim_course_problems.sql b/tutoraspects/templates/openedx-assets/queries/dim_course_problems.sql deleted file mode 100644 index 1d014dba5..000000000 --- a/tutoraspects/templates/openedx-assets/queries/dim_course_problems.sql +++ /dev/null @@ -1,20 +0,0 @@ -select - org, - course_name, - course_key, - course_run, - block_id as problem_id, - block_name as problem_name, - display_name_with_location as problem_name_with_location -from {{ DBT_PROFILE_TARGET_DATABASE }}.dim_course_blocks -where - problem_id like '%problem+block%' - {% raw -%} - {% if filter_values("org") != [] %} - and org in {{ filter_values("org") | where_in }} - {% endif %} - {% if filter_values("problem_name_with_location") != [] %} - and problem_name_with_location - in {{ filter_values("problem_name_with_location") | where_in }} - {% endif %} - {%- endraw %} diff --git a/tutoraspects/templates/openedx-assets/queries/dim_course_videos.sql b/tutoraspects/templates/openedx-assets/queries/dim_course_videos.sql deleted file mode 100644 index 16a12a10a..000000000 --- a/tutoraspects/templates/openedx-assets/queries/dim_course_videos.sql +++ /dev/null @@ -1,20 +0,0 @@ -select - org, - course_name, - course_key, - course_run, - block_id as video_id, - block_name as video_name, - display_name_with_location as video_name_with_location -from {{ DBT_PROFILE_TARGET_DATABASE }}.dim_course_blocks -where - video_id like '%video+block%' - {% raw -%} - {% if filter_values("org") != [] %} - and org in {{ filter_values("org") | where_in }} - {% endif %} - {% if filter_values("video_name_with_location") != [] %} - and video_name_with_location - in {{ filter_values("video_name_with_location") | where_in }} - {% endif %} - {%- endraw %} diff --git a/tutoraspects/templates/openedx-assets/queries/enrollment_status.sql b/tutoraspects/templates/openedx-assets/queries/enrollment_status.sql index 6db19984b..2b79f7bcc 100644 --- a/tutoraspects/templates/openedx-assets/queries/enrollment_status.sql +++ b/tutoraspects/templates/openedx-assets/queries/enrollment_status.sql @@ -12,3 +12,4 @@ left join {{ ASPECTS_EVENT_SINK_DATABASE }}.course_names cn on fes.org = cn.org and fes.course_key = cn.course_key +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_navigation_completion.sql b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_navigation_completion.sql index ea2894572..f7544ff45 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_navigation_completion.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_navigation_completion.sql @@ -4,3 +4,4 @@ join ( {% include 'openedx-assets/queries/at_risk_learner_filter.sql' %} ) as at_risk_learners using (org, course_key, actor_id) +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_pageview_engagement.sql b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_pageview_engagement.sql index c65b6828b..3c37ec1d7 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_pageview_engagement.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_pageview_engagement.sql @@ -4,3 +4,4 @@ join ( {% include 'openedx-assets/queries/at_risk_learner_filter.sql' %} ) as at_risk_learners using (org, course_key, actor_id) +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_problem_engagement.sql b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_problem_engagement.sql index bc1630cda..fea9d4161 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_problem_engagement.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_problem_engagement.sql @@ -1,4 +1,9 @@ -{% include 'openedx-assets/queries/fact_problem_engagement.sql' %} +with + fact_problem_engagement as ( + {% include 'openedx-assets/queries/fact_problem_engagement.sql' %} + ) +select fact_problem_engagement.* +from fact_problem_engagement pe join ( {% include 'openedx-assets/queries/at_risk_learner_filter.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_engagement.sql b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_engagement.sql index b5a9b793a..2160ab141 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_engagement.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_engagement.sql @@ -4,3 +4,4 @@ join ( {% include 'openedx-assets/queries/at_risk_learner_filter.sql' %} ) as at_risk_learners using (org, course_key, actor_id) +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_plays.sql b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_plays.sql index b22e43c4b..1cd8491fd 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_plays.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_plays.sql @@ -6,3 +6,4 @@ join ( {% include 'openedx-assets/queries/at_risk_learner_filter.sql' %} ) as at_risk_learners using (org, course_key, actor_id) +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_watches.sql b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_watches.sql index 86efff57d..477d232fe 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_watches.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_video_watches.sql @@ -6,3 +6,4 @@ join ( {% include 'openedx-assets/queries/at_risk_learner_filter.sql' %} ) as at_risk_learners using (org, course_key, actor_id) +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_watched_video_segments.sql b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_watched_video_segments.sql index df054f3a9..b74dfb745 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_at_risk_watched_video_segments.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_at_risk_watched_video_segments.sql @@ -6,3 +6,4 @@ join ( {% include 'openedx-assets/queries/at_risk_learner_filter.sql' %} ) as at_risk_learners using (org, course_key, actor_id) +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_course_grades.sql b/tutoraspects/templates/openedx-assets/queries/fact_course_grades.sql deleted file mode 100644 index 08c489444..000000000 --- a/tutoraspects/templates/openedx-assets/queries/fact_course_grades.sql +++ /dev/null @@ -1,35 +0,0 @@ -with - grades as ( - select * - from {{ DBT_PROFILE_TARGET_DATABASE }}.fact_grades - where - grade_type = 'course' - {% raw %} - {% if get_filters("course_name", remove_filter=True) == [] %} - {% elif filter_values("course_name") != [] %} - and entity_name - in {{ filter_values("course_name", remove_filter=True) | where_in }} - {% else %} and 1 = 0 - {% endif %} - {% endraw %} - {% include 'openedx-assets/queries/common_filters.sql' %} - ), - most_recent_grades as ( - select org, course_key, entity_id, actor_id, max(emission_time) as emission_time - from grades - group by org, course_key, entity_id, actor_id - ) - -select - grades.emission_time as emission_time, - grades.org as org, - grades.course_key as course_key, - grades.course_name as course_name, - grades.course_run as course_run, - grades.entity_name as entity_name, - grades.actor_id as actor_id, - grades.grade_type as grade_type, - grades.scaled_score as scaled_score, - grades.grade_bucket as grade_bucket -from grades -join most_recent_grades using (org, course_key, entity_id, actor_id, emission_time) diff --git a/tutoraspects/templates/openedx-assets/queries/fact_enrollments_by_day.sql b/tutoraspects/templates/openedx-assets/queries/fact_enrollments_by_day.sql deleted file mode 100644 index c41f9e9d2..000000000 --- a/tutoraspects/templates/openedx-assets/queries/fact_enrollments_by_day.sql +++ /dev/null @@ -1,68 +0,0 @@ -with - enrollments as ({% include 'openedx-assets/queries/fact_enrollments.sql' %}), - enrollments_ranked as ( - select - emission_time, - org, - course_key, - course_name, - course_run, - actor_id, - enrollment_mode, - enrollment_status, - rank() over ( - partition by date(emission_time), org, course_name, course_run, actor_id - order by emission_time desc - ) as event_rank - from enrollments - ), - enrollment_windows as ( - select - org, - course_key, - course_name, - course_run, - actor_id, - enrollment_status, - enrollment_mode, - emission_time as window_start_at, - lagInFrame(emission_time, 1, now() + interval '1' day) over ( - partition by org, course_name, course_run, actor_id - order by emission_time desc - ) as window_end_at - from enrollments_ranked - where event_rank = 1 - ), - enrollment_window_dates as ( - select - org, - course_key, - course_name, - course_run, - actor_id, - enrollment_status, - enrollment_mode, - date_trunc('day', window_start_at) as window_start_date, - date_trunc('day', window_end_at) as window_end_date - from enrollment_windows - ) -select - date( - fromUnixTimestamp( - arrayJoin( - range( - toUnixTimestamp(window_start_date), - toUnixTimestamp(window_end_date), - 86400 - ) - ) - ) - ) as enrollment_status_date, - org, - course_key, - course_name, - course_run, - actor_id, - enrollment_status, - enrollment_mode -from enrollment_window_dates diff --git a/tutoraspects/templates/openedx-assets/queries/fact_forum_interactions.sql b/tutoraspects/templates/openedx-assets/queries/fact_forum_interactions.sql deleted file mode 100644 index 4570c0aa0..000000000 --- a/tutoraspects/templates/openedx-assets/queries/fact_forum_interactions.sql +++ /dev/null @@ -1,3 +0,0 @@ -select * -from {{ DBT_PROFILE_TARGET_DATABASE }}.fact_forum_interactions -where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_learner_problem_course_summary.sql b/tutoraspects/templates/openedx-assets/queries/fact_learner_problem_course_summary.sql deleted file mode 100644 index 29ff1a79c..000000000 --- a/tutoraspects/templates/openedx-assets/queries/fact_learner_problem_course_summary.sql +++ /dev/null @@ -1,136 +0,0 @@ -with - problem_responses as ( - {% include 'openedx-assets/queries/int_problem_responses.sql' %} - ), - outcomes as ( - select - emission_time, - org, - course_key, - problem_id, - actor_id, - success, - first_value(success) over ( - partition by course_key, problem_id, actor_id order by success DESC - ) as was_successful - from problem_responses - ), - successful_responses as ( - select - org, - course_key, - problem_id, - actor_id, - min(emission_time) as first_success_at - from outcomes - where was_successful = true and success = true - group by org, course_key, problem_id, actor_id - ), - unsuccessful_responses as ( - select - org, - course_key, - problem_id, - actor_id, - max(emission_time) as last_response_at - from outcomes - where was_successful = false - group by org, course_key, problem_id, actor_id - ), - final_responses as ( - select org, course_key, problem_id, actor_id, first_success_at as emission_time - from successful_responses - union all - select org, course_key, problem_id, actor_id, last_response_at as emission_time - from unsuccessful_responses - ), - int_problem_results as ( - select - emission_time, - org, - course_key, - course_name, - course_run, - problem_id, - problem_name, - problem_name_with_location, - actor_id, - responses, - success, - attempts - from problem_responses - inner join - final_responses using (org, course_key, problem_id, actor_id, emission_time) - ), - summary as ( - select - org, - course_key, - course_name, - course_run, - problem_name, - problem_name_with_location, - actor_id, - success, - attempts, - 0 as num_hints_displayed, - 0 as num_answers_displayed - from int_problem_results - where - 1 = 1 - {% raw %} - {% if from_dttm %} and emission_time > '{{ from_dttm }}' {% endif %} - {% if to_dttm %} and emission_time < '{{ to_dttm }}' {% endif %} - {% endraw %} - union all - select - org, - course_key, - course_name, - course_run, - problem_name, - problem_name_with_location, - actor_id, - NULL as success, - NULL as attempts, - caseWithExpression(help_type, 'hint', 1, 0) as num_hints_displayed, - caseWithExpression(help_type, 'answer', 1, 0) as num_answers_displayed - from {{ DBT_PROFILE_TARGET_DATABASE }}.int_problem_hints - where - 1 = 1 - {% raw %} - {% if from_dttm %} and emission_time > '{{ from_dttm }}' {% endif %} - {% if to_dttm %} and emission_time < '{{ to_dttm }}' {% endif %} - {% endraw %} - {% include 'openedx-assets/queries/common_filters.sql' %} - ) - -select - org, - course_key, - course_name, - course_run, - problem_name, - problem_name_with_location, - actor_id, - 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 -from summary -where - {% raw %} - {% if get_filters("course_name", remove_filter=True) == [] %} 1 = 1 - {% elif filter_values("course_name") != [] %} - course_name in {{ filter_values("course_name") | where_in }} - {% else %} 1 = 0 - {% endif %} - {% endraw %} -group by - org, - course_key, - course_name, - course_run, - problem_name, - problem_name_with_location, - actor_id diff --git a/tutoraspects/templates/openedx-assets/queries/fact_learner_problem_summary.sql b/tutoraspects/templates/openedx-assets/queries/fact_learner_problem_summary.sql deleted file mode 100644 index e08113378..000000000 --- a/tutoraspects/templates/openedx-assets/queries/fact_learner_problem_summary.sql +++ /dev/null @@ -1,125 +0,0 @@ -with - problem_responses as ( - {% include 'openedx-assets/queries/int_problem_responses.sql' %} - ), - outcomes as ( - select - emission_time, - org, - course_key, - problem_id, - actor_id, - success, - first_value(success) over ( - partition by course_key, problem_id, actor_id order by success ASC - ) as was_successful - from problem_responses - ), - successful_responses as ( - select - org, - course_key, - problem_id, - actor_id, - min(emission_time) as first_success_at - from outcomes - where was_successful = true and success = true - group by org, course_key, problem_id, actor_id - ), - unsuccessful_responses as ( - select - org, - course_key, - problem_id, - actor_id, - max(emission_time) as last_response_at - from outcomes - where was_successful = false - group by org, course_key, problem_id, actor_id - ), - final_responses as ( - select org, course_key, problem_id, actor_id, first_success_at as emission_time - from successful_responses - union all - select org, course_key, problem_id, actor_id, last_response_at as emission_time - from unsuccessful_responses - ), - int_problem_results as ( - select - emission_time, - org, - course_key, - course_name, - course_run, - problem_id, - problem_name, - problem_name_with_location, - actor_id, - responses, - success, - attempts - from problem_responses - inner join - final_responses using (org, course_key, problem_id, actor_id, emission_time) - ), - summary_base as ( - select - org, - course_key, - course_name, - course_run, - problem_name, - problem_name_with_location, - actor_id, - success, - attempts, - 0 as num_hints_displayed, - 0 as num_answers_displayed - from int_problem_results - union all - select - org, - course_key, - course_name, - course_run, - problem_name, - problem_name_with_location, - actor_id, - NULL as success, - NULL as attempts, - caseWithExpression(help_type, 'hint', 1, 0) as num_hints_displayed, - caseWithExpression(help_type, 'answer', 1, 0) as num_answers_displayed - from {{ DBT_PROFILE_TARGET_DATABASE }}.int_problem_hints - where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} - ) - -select - org, - course_key, - course_name, - course_run, - problem_name, - problem_name_with_location, - actor_id, - 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 -from summary_base -where - {% raw %} - {% if get_filters("problem_name_with_location", remove_filter=True) == [] %} 1 = 1 - {% elif filter_values("problem_name_with_location") != [] %} - problem_name_with_location - in {{ filter_values("problem_name_with_location") | where_in }} - {% else %} 1 = 0 - {% endif %} - {% endraw %} -group by - org, - course_key, - course_name, - course_run, - problem_name, - problem_name_with_location, - actor_id diff --git a/tutoraspects/templates/openedx-assets/queries/fact_learner_summary.sql b/tutoraspects/templates/openedx-assets/queries/fact_learner_summary.sql index 398b2e3b8..ead770402 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_learner_summary.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_learner_summary.sql @@ -66,3 +66,4 @@ left join on fss.org = let.org and fss.course_key = let.course_key and fss.actor_id = let.actor_id +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_page_engagement.sql b/tutoraspects/templates/openedx-assets/queries/fact_page_engagement.sql index ae3a4b63d..ba8980542 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_page_engagement.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_page_engagement.sql @@ -50,3 +50,4 @@ join left outer join {{ DBT_PROFILE_TARGET_DATABASE }}.dim_user_pii users on toUUID(pv.actor_id) = users.external_user_id +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_problem_engagement.sql b/tutoraspects/templates/openedx-assets/queries/fact_problem_engagement.sql index ebe8d97f0..8c21465b0 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_problem_engagement.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_problem_engagement.sql @@ -51,3 +51,4 @@ join left outer join {{ DBT_PROFILE_TARGET_DATABASE }}.dim_user_pii users on toUUID(pe.actor_id) = users.external_user_id +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_problem_grades.sql b/tutoraspects/templates/openedx-assets/queries/fact_problem_grades.sql deleted file mode 100644 index 64dae4984..000000000 --- a/tutoraspects/templates/openedx-assets/queries/fact_problem_grades.sql +++ /dev/null @@ -1,42 +0,0 @@ -with - grades as ( - select * - from {{ DBT_PROFILE_TARGET_DATABASE }}.fact_grades - where - grade_type = 'problem' - - {% raw %} - {% if get_filters("problem_name_with_location", remove_filter=True) == [] %} - {% elif filter_values("problem_name_with_location") != [] %} - and entity_name_with_location - in {{ - filter_values( - "problem_name_with_location", remove_filter=True - ) | where_in - }} - {% else %} and 1 = 0 - {% endif %} - {% endraw %} - - {% include 'openedx-assets/queries/common_filters.sql' %} - ), - most_recent_grades as ( - select org, course_key, entity_id, actor_id, max(emission_time) as emission_time - from grades - group by org, course_key, entity_id, actor_id - ) - -select - grades.emission_time as emission_time, - grades.org as org, - grades.course_key as course_key, - grades.course_name as course_name, - grades.course_run as course_run, - grades.entity_name as entity_name, - grades.entity_name_with_location as entity_name_with_location, - grades.actor_id as actor_id, - grades.grade_type as grade_type, - grades.scaled_score as scaled_score, - grades.grade_bucket as grade_bucket -from grades -join most_recent_grades using (org, course_key, entity_id, actor_id, emission_time) diff --git a/tutoraspects/templates/openedx-assets/queries/fact_problem_responses.sql b/tutoraspects/templates/openedx-assets/queries/fact_problem_responses.sql deleted file mode 100644 index fe273177b..000000000 --- a/tutoraspects/templates/openedx-assets/queries/fact_problem_responses.sql +++ /dev/null @@ -1,30 +0,0 @@ -with - problem_responses as ( - {% include 'openedx-assets/queries/int_problem_responses.sql' %} - ) - -select - emission_time, - org, - course_key, - course_name, - course_run, - problem_id, - problem_name, - problem_name_with_location, - actor_id, - attempts, - success, - arrayJoin( - if(JSONArrayLength(responses) > 0, JSONExtractArrayRaw(responses), [responses]) - ) as responses -from problem_responses -where - {% raw %} - {% if get_filters("problem_name_with_location", remove_filter=True) == [] %} 1 = 1 - {% elif filter_values("problem_name_with_location") != [] %} - problem_name_with_location - in {{ filter_values("problem_name_with_location") | where_in }} - {% else %} 1 = 0 - {% endif %} - {% endraw %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_transcript_usage.sql b/tutoraspects/templates/openedx-assets/queries/fact_transcript_usage.sql deleted file mode 100644 index 57a2ccbea..000000000 --- a/tutoraspects/templates/openedx-assets/queries/fact_transcript_usage.sql +++ /dev/null @@ -1,25 +0,0 @@ -with - transcripts as ( - select * - from {{ DBT_PROFILE_TARGET_DATABASE }}.fact_transcript_usage - where - {% raw %} - {% if get_filters("course_name", remove_filter=True) == [] %} 1 = 1 - {% elif filter_values("course_name") != [] %} - course_name in {{ filter_values("course_name") | where_in }} - {% else %} 1 = 0 - {% endif %} - {% endraw %} - {% include 'openedx-assets/queries/common_filters.sql' %} - ) - -select - emission_time, - org, - course_key, - course_name, - course_run, - video_name, - video_name_with_location, - actor_id -from transcripts diff --git a/tutoraspects/templates/openedx-assets/queries/fact_video_engagement.sql b/tutoraspects/templates/openedx-assets/queries/fact_video_engagement.sql index 300d30e55..19a48674e 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_video_engagement.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_video_engagement.sql @@ -50,3 +50,4 @@ join left outer join {{ DBT_PROFILE_TARGET_DATABASE }}.dim_user_pii users on toUUID(ve.actor_id) = users.external_user_id +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/fact_watched_video_segments.sql b/tutoraspects/templates/openedx-assets/queries/fact_watched_video_segments.sql index ccb109a9c..328ab6da0 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_watched_video_segments.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_watched_video_segments.sql @@ -77,6 +77,7 @@ with segments.course_key = blocks.course_key and segments.video_id = blocks.block_id ) + where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} ) select diff --git a/tutoraspects/templates/openedx-assets/queries/hints_per_success.sql b/tutoraspects/templates/openedx-assets/queries/hints_per_success.sql deleted file mode 100644 index cf797bbfd..000000000 --- a/tutoraspects/templates/openedx-assets/queries/hints_per_success.sql +++ /dev/null @@ -1,22 +0,0 @@ -with - summary as ({% include 'openedx-assets/queries/fact_learner_problem_summary.sql' %}) - -select - org, - course_key, - course_name, - course_run, - problem_name, - problem_name_with_location, - actor_id, - sum(num_hints_displayed) + sum(num_answers_displayed) as total_hints -from summary -where success = 1 -group by - org, - course_key, - course_name, - course_run, - problem_name, - problem_name_with_location, - actor_id diff --git a/tutoraspects/templates/openedx-assets/queries/int_problem_responses.sql b/tutoraspects/templates/openedx-assets/queries/int_problem_responses.sql deleted file mode 100644 index f0e3c9e48..000000000 --- a/tutoraspects/templates/openedx-assets/queries/int_problem_responses.sql +++ /dev/null @@ -1,21 +0,0 @@ -with - problem_responses_base as ( - select * - from {{ DBT_PROFILE_TARGET_DATABASE }}.fact_problem_responses - where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} - ) - -select - emission_time, - org, - course_key, - course_name, - course_run, - problem_id, - problem_name, - problem_name_with_location, - actor_id, - attempts, - success, - responses -from problem_responses_base diff --git a/tutoraspects/templates/openedx-assets/queries/int_problem_results.sql b/tutoraspects/templates/openedx-assets/queries/int_problem_results.sql index d71e21cf8..a2f0a39b8 100644 --- a/tutoraspects/templates/openedx-assets/queries/int_problem_results.sql +++ b/tutoraspects/templates/openedx-assets/queries/int_problem_results.sql @@ -49,6 +49,7 @@ with events.interaction_type as interaction_type from {{ ASPECTS_XAPI_DATABASE }}.problem_events events join responses using (org, course_key, problem_id, actor_id, emission_time) + where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} ) select @@ -87,3 +88,4 @@ join left outer join {{ ASPECTS_EVENT_SINK_DATABASE }}.user_pii users on full_responses.actor_id = users.external_user_id::String +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/posts_per_user.sql b/tutoraspects/templates/openedx-assets/queries/posts_per_user.sql deleted file mode 100644 index 548b724b0..000000000 --- a/tutoraspects/templates/openedx-assets/queries/posts_per_user.sql +++ /dev/null @@ -1,9 +0,0 @@ -select org, course_key, course_name, course_run, actor_id, count(*) as num_posts -from {{ DBT_PROFILE_TARGET_DATABASE }}.fact_forum_interactions -where - 1 = 1 - {% raw %} - {% if from_dttm %} and emission_time > '{{ from_dttm }}' {% endif %} - {% if to_dttm %} and emission_time < '{{ to_dttm }}' {% endif %} - {% endraw %} -group by org, course_key, course_name, course_run, actor_id diff --git a/tutoraspects/templates/openedx-assets/queries/problem_coursewide_avg.sql b/tutoraspects/templates/openedx-assets/queries/problem_coursewide_avg.sql index be9fe83a3..1c61e4ccd 100644 --- a/tutoraspects/templates/openedx-assets/queries/problem_coursewide_avg.sql +++ b/tutoraspects/templates/openedx-assets/queries/problem_coursewide_avg.sql @@ -127,3 +127,4 @@ join on full_responses.org = coursewide_attempts.org and full_responses.course_key = coursewide_attempts.course_key and full_responses.problem_id = coursewide_attempts.problem_id +where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %}