From 91ee30c6a9ccf25d8e9da0dce2db2e4e8e1a9c62 Mon Sep 17 00:00:00 2001 From: Matthew Buckett Date: Wed, 15 Apr 2020 22:41:34 +0100 Subject: [PATCH] Add support for expanding the Course Integration ID When performing a LTI launch this allows the course integration ID be expanded in the custom data that is made available in an LTI launch. Closes INTEROP-6480 Closes GH-1606 flag = none test plan: - specs pass Change-Id: I5a21eab4f02f5da1f45f714d265903d5615bce6c Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/256921 Reviewed-by: Weston Dransfield QA-Review: Weston Dransfield Tested-by: Service Cloud Jenkins Product-Review: Alex Slaughter --- doc/api/tools_variable_substitutions.md | 9 +++++++++ lib/lti/variable_expander.rb | 9 +++++++++ spec/lib/lti/variable_expander_spec.rb | 7 +++++++ 3 files changed, 25 insertions(+) diff --git a/doc/api/tools_variable_substitutions.md b/doc/api/tools_variable_substitutions.md index a12fecb59bb..72175536b68 100644 --- a/doc/api/tools_variable_substitutions.md +++ b/doc/api/tools_variable_substitutions.md @@ -550,6 +550,15 @@ returns the current course sis source id. **Availability**: *when launched in a course* +``` +1234 +``` +## com.instructure.Course.integrationId +returns the current course integration id. + +**Availability**: *when launched in a course* + + ``` 1234 ``` diff --git a/lib/lti/variable_expander.rb b/lib/lti/variable_expander.rb index 3ddf267c80e..553527c016c 100644 --- a/lib/lti/variable_expander.rb +++ b/lib/lti/variable_expander.rb @@ -576,6 +576,15 @@ module Lti -> { @context.sis_source_id }, COURSE_GUARD + # returns the current course integration id. + # @example + # ``` + # 1234 + # ``` + register_expansion 'com.instructure.Course.integrationId', [], + -> { @context.integration_id }, + COURSE_GUARD + # returns the current course start date. # @example # ``` diff --git a/spec/lib/lti/variable_expander_spec.rb b/spec/lib/lti/variable_expander_spec.rb index de492c9bfc9..aef1a325313 100644 --- a/spec/lib/lti/variable_expander_spec.rb +++ b/spec/lib/lti/variable_expander_spec.rb @@ -931,6 +931,13 @@ module Lti expect(exp_hash[:test]).to eq 'course1' end + it 'has substitution for $com.instructure.Course.integrationId' do + course.integration_id = 'integration1' + exp_hash = {test: '$com.instructure.Course.integrationId'} + variable_expander.expand_variables!(exp_hash) + expect(exp_hash[:test]).to eq 'integration1' + end + it 'has substitution for $Canvas.enrollment.enrollmentState' do allow(Lti::SubstitutionsHelper).to receive(:new).and_return(substitution_helper) allow(substitution_helper).to receive(:enrollment_state).and_return('active')