From 276658083abcfbbb8d508ea4783791b96f8c52cf Mon Sep 17 00:00:00 2001 From: Sara Burns Date: Wed, 29 Jan 2025 15:31:27 -0500 Subject: [PATCH] fix: restore model and rename --- .../problems/dim_learner_response_attempt.sql | 2 +- .../fact_learner_response_attempts.sql | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 models/problems/fact_learner_response_attempts.sql diff --git a/models/problems/dim_learner_response_attempt.sql b/models/problems/dim_learner_response_attempt.sql index 55248b61..b163a3cd 100644 --- a/models/problems/dim_learner_response_attempt.sql +++ b/models/problems/dim_learner_response_attempt.sql @@ -16,7 +16,7 @@ with responses as ( - select emission_time, org, course_key, object_id, problem_id, actor_id, success + select emission_time, org, course_key, object_id, problem_id, actor_id, success, responses, attempts, interaction_type from {{ ref("problem_events") }} where verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated' ), diff --git a/models/problems/fact_learner_response_attempts.sql b/models/problems/fact_learner_response_attempts.sql new file mode 100644 index 00000000..da2c4432 --- /dev/null +++ b/models/problems/fact_learner_response_attempts.sql @@ -0,0 +1,49 @@ +-- select one record per (learner, problem, course, org) tuple +-- contains either the first successful attempt +-- or the most recent unsuccessful attempt +-- find the timestamp of the earliest successful response +-- this will be used to pick the xAPI event corresponding to that submission +with + full_responses as ( + select + events.emission_time as emission_time, + events.org as org, + events.course_key as course_key, + events.problem_id as problem_id, + events.object_id as object_id, + events.actor_id as actor_id, + events.responses as responses, + events.success as success, + events.attempts as attempts, + events.interaction_type as interaction_type + from {{ ref("problem_events") }} events + join + {{ ref("dim_learner_response_attempt") }} using ( + org, course_key, problem_id, actor_id, emission_time + ) + ) + +select + full_responses.emission_time as emission_time, + full_responses.org as org, + full_responses.course_key as course_key, + blocks.course_name as course_name, + blocks.course_run as course_run, + full_responses.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, + blocks.problem_link as problem_link, + full_responses.actor_id as actor_id, + full_responses.responses as responses, + full_responses.success as success, + full_responses.attempts as attempts, + full_responses.interaction_type as interaction_type, + blocks.graded +from full_responses +join + {{ ref("dim_course_blocks") }} blocks + on ( + full_responses.course_key = blocks.course_key + and full_responses.problem_id = blocks.block_id + )