From 6db1239e49c51ca7869540b4d398e4a8abfb05d0 Mon Sep 17 00:00:00 2001 From: Rory Sawyer Date: Thu, 19 Oct 2023 12:52:16 -0400 Subject: [PATCH] feat: support multi-part problem responses --- macros/get_problem_id.sql | 2 +- models/problems/fact_problem_responses.sql | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/macros/get_problem_id.sql b/macros/get_problem_id.sql index bebd0158..362a2253 100644 --- a/macros/get_problem_id.sql +++ b/macros/get_problem_id.sql @@ -3,5 +3,5 @@ -- either the problem id is at the end of the object ID -- or is followed by '/answer' or '/hint' {% macro get_problem_id(object_id) %} - regexpExtract(object_id, 'xblock/([\w\d-@\+:]*)', 1) + regexpExtract(object_id, 'xblock/([\w\d-\+:]*@problem\+block@[\w\d][^_]*)(_\d_\d)?', 1) {% endmacro %} diff --git a/models/problems/fact_problem_responses.sql b/models/problems/fact_problem_responses.sql index 89d347a0..832d71dc 100644 --- a/models/problems/fact_problem_responses.sql +++ b/models/problems/fact_problem_responses.sql @@ -32,3 +32,18 @@ from join {{ ref('dim_course_blocks')}} blocks on (responses.course_key = blocks.course_key and responses.problem_id = blocks.block_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 + emission_time, + org, + course_key, + course_name, + course_run, + problem_id, + problem_name, + problem_name_with_location, + actor_id, + responses, + success, + attempts