From 84f1c1a4e73096329f4a8030a704aa25f252afe7 Mon Sep 17 00:00:00 2001 From: Brian Mesick Date: Thu, 18 Jan 2024 08:59:49 -0500 Subject: [PATCH] fixup! feat!: Upgrade schema to use new Ralph 4.0 event column --- models/base/xapi_events_all_parsed.sql | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/models/base/xapi_events_all_parsed.sql b/models/base/xapi_events_all_parsed.sql index c1cd1d0b..9947f815 100644 --- a/models/base/xapi_events_all_parsed.sql +++ b/models/base/xapi_events_all_parsed.sql @@ -9,35 +9,34 @@ SELECT event_id as event_id, - event::String as event, - JSON_VALUE(event, '$.verb.id') as verb_id, + JSON_VALUE(event::String, '$.verb.id') as verb_id, COALESCE( - NULLIF(JSON_VALUE(event, '$.actor.account.name'), ''), - NULLIF(JSON_VALUE(event, '$.actor.mbox'), ''), - JSON_VALUE(event, '$.actor.mbox_sha1sum') + NULLIF(JSON_VALUE(event::String, '$.actor.account.name'), ''), + NULLIF(JSON_VALUE(event::String, '$.actor.mbox'), ''), + JSON_VALUE(event::String, '$.actor.mbox_sha1sum') ) as actor_id, - JSON_VALUE(event, '$.object.id') as object_id, + JSON_VALUE(event::String, '$.object.id') as object_id, -- If the contextActivities parent is a course, use that. It can be a "course" -- type, or a "cmi.interaction" type for multiple question problem submissions. -- Otherwise use the object id for the course id. multiIf( -- If the contextActivities parent is a course, use that JSON_VALUE( - event, + event::String, '$.context.contextActivities.parent[0].definition.type' ) = 'http://adlnet.gov/expapi/activities/course', - JSON_VALUE(event, '$.context.contextActivities.parent[0].id'), + JSON_VALUE(event::String, '$.context.contextActivities.parent[0].id'), -- Else if the contextActivities parent is a GroupActivity, it's a multi -- question problem and we use the grouping id JSON_VALUE( - event, + event::String, '$.context.contextActivities.parent[0].objectType' ) in ('Activity', 'GroupActivity'), - JSON_VALUE(event, '$.context.contextActivities.grouping[0].id'), + JSON_VALUE(event::String, '$.context.contextActivities.grouping[0].id'), -- Otherwise use the object id - JSON_VALUE(event, '$.object.id') + JSON_VALUE(event::String, '$.object.id') ) as course_id, coalesce(get_org_from_course_url(course_id), '') as org, emission_time as emission_time, - event as event + event::String as event FROM {{ source('xapi', 'xapi_events_all') }}