Module: AJIMS::LTI::LaunchParams
- Included in:
- ToolConsumer, ToolProvider
- Defined in:
- lib/ajims/lti/launch_params.rb
Overview
Mixin module for managing LTI Launch Data
Launch data documentation: www.imsglobal.org/lti/v1p1pd/ltiIMGv1p1pd.html#_Toc309649684
Constant Summary collapse
- LAUNCH_DATA_PARAMETERS =
List of the standard launch parameters for an LTI launch
%w{ context_id context_label context_title context_type launch_presentation_css_url launch_presentation_document_target launch_presentation_height launch_presentation_locale launch_presentation_return_url launch_presentation_width lis_course_offering_sourcedid lis_course_section_sourcedid lis_outcome_service_url lis_person_contact_email_primary lis_person_name_family lis_person_name_full lis_person_name_given lis_person_sourcedid lis_result_sourcedid lti_message_type lti_version oauth_callback oauth_consumer_key oauth_nonce oauth_signature oauth_signature_method oauth_timestamp oauth_version resource_link_description resource_link_id resource_link_title roles tool_consumer_info_product_family_code tool_consumer_info_version tool_consumer_instance_contact_email tool_consumer_instance_description tool_consumer_instance_guid tool_consumer_instance_name tool_consumer_instance_url user_id user_image }
Instance Attribute Summary collapse
-
#custom_params ⇒ Object
Hash of custom parameters, the keys will be prepended with “custom_” at launch.
-
#ext_params ⇒ Object
Hash of extension parameters, the keys will be prepended with “ext_” at launch.
-
#non_spec_params ⇒ Object
Hash of parameters to add to the launch.
Instance Method Summary collapse
- #get_custom_param(key) ⇒ Object
- #get_ext_param(key) ⇒ Object
- #get_non_spec_param(key) ⇒ Object
-
#process_params(params) ⇒ Object
Populates the launch data from a Hash.
-
#roles=(roles_list) ⇒ Object
Set the roles for the current launch.
- #set_custom_param(key, val) ⇒ Object
- #set_ext_param(key, val) ⇒ Object
- #set_non_spec_param(key, val) ⇒ Object
-
#to_params ⇒ Object
Create a new Hash with all launch data.
Instance Attribute Details
#custom_params ⇒ Object
Hash of custom parameters, the keys will be prepended with “custom_” at launch
56 57 58 |
# File 'lib/ajims/lti/launch_params.rb', line 56 def custom_params @custom_params end |
#ext_params ⇒ Object
Hash of extension parameters, the keys will be prepended with “ext_” at launch
59 60 61 |
# File 'lib/ajims/lti/launch_params.rb', line 59 def ext_params @ext_params end |
#non_spec_params ⇒ Object
Hash of parameters to add to the launch. These keys will not be prepended with any value at launch
63 64 65 |
# File 'lib/ajims/lti/launch_params.rb', line 63 def non_spec_params @non_spec_params end |
Instance Method Details
#get_custom_param(key) ⇒ Object
103 104 105 |
# File 'lib/ajims/lti/launch_params.rb', line 103 def get_custom_param(key) @custom_params[key] end |
#get_ext_param(key) ⇒ Object
119 120 121 |
# File 'lib/ajims/lti/launch_params.rb', line 119 def get_ext_param(key) @ext_params[key] end |
#get_non_spec_param(key) ⇒ Object
111 112 113 |
# File 'lib/ajims/lti/launch_params.rb', line 111 def get_non_spec_param(key) @non_spec_params[key] end |
#process_params(params) ⇒ Object
Populates the launch data from a Hash
Only keys in LAUNCH_DATA_PARAMETERS and that start with ‘custom_’ or ‘ext_’ will be pulled from the provided Hash
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/ajims/lti/launch_params.rb', line 136 def process_params(params) params.each_pair do |key, val| if LAUNCH_DATA_PARAMETERS.member?(key) self.send("#{key}=", val) elsif key =~ /custom_(.*)/ @custom_params[$1] = val elsif key =~ /ext_(.*)/ @ext_params[$1] = val end end end |
#roles=(roles_list) ⇒ Object
Set the roles for the current launch
Full list of roles can be found here: www.imsglobal.org/LTI/v1p1pd/ltiIMGv1p1pd.html#_Toc309649700
LIS roles include:
-
Student
-
Faculty
-
Member
-
Learner
-
Instructor
-
Mentor
-
Staff
-
Alumni
-
ProspectiveStudent
-
Guest
-
Other
-
Administrator
-
Observer
-
None
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ajims/lti/launch_params.rb', line 87 def roles=(roles_list) if roles_list if roles_list.is_a?(Array) @roles = roles_list else @roles = roles_list.split(",").map(&:downcase) end else @roles = nil end end |
#set_custom_param(key, val) ⇒ Object
99 100 101 |
# File 'lib/ajims/lti/launch_params.rb', line 99 def set_custom_param(key, val) @custom_params[key] = val end |
#set_ext_param(key, val) ⇒ Object
115 116 117 |
# File 'lib/ajims/lti/launch_params.rb', line 115 def set_ext_param(key, val) @ext_params[key] = val end |
#set_non_spec_param(key, val) ⇒ Object
107 108 109 |
# File 'lib/ajims/lti/launch_params.rb', line 107 def set_non_spec_param(key, val) @non_spec_params[key] = val end |
#to_params ⇒ Object
Create a new Hash with all launch data. Custom/Extension keys will have the appropriate value prepended to the keys and the roles are set as a comma separated String
126 127 128 129 130 |
# File 'lib/ajims/lti/launch_params.rb', line 126 def to_params params = launch_data_hash.merge(add_key_prefix(@custom_params, 'custom')).merge(add_key_prefix(@ext_params, 'ext')).merge(@non_spec_params) params["roles"] = @roles.join(",") if @roles params end |