Skip to content

Commit

Permalink
fixup! feat!: Upgrade schema to use new Ralph 4.0 event column
Browse files Browse the repository at this point in the history
  • Loading branch information
bmtcril committed Jan 18, 2024
1 parent 193b71c commit 84f1c1a
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions models/base/xapi_events_all_parsed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}

0 comments on commit 84f1c1a

Please sign in to comment.