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')