Skip to content

Commit

Permalink
LTI-382: simplified code into one single loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jfederico committed Jun 19, 2024
1 parent 6b54576 commit 05562ed
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions lib/bbb_lti_broker/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,24 @@ def standarized_message(message_json)
end

custom_params = message['unknown_params']['https://purl.imsglobal.org/spec/lti/claim/custom'] || {}
# for following the format used by LTI 1.1 apps.
custom_params.each do |key, value|
# for following the format used by LTI 1.1 apps.
message["custom_#{key}"] = value
# for following a standard format used by our own apps.
prefixed_key = key.start_with?('custom_') ? key : "custom_#{key}"
message['custom_params'][prefixed_key] = value
end
# for following a standard format used by our own apps.
message['custom_params'] = keys_with_prefix(custom_params, 'custom_')
# message['custom_params'] = keys_with_prefix(custom_params, 'custom_')

ext_params = message['unknown_params']['https://purl.imsglobal.org/spec/lti/claim/ext'] || {}
# for following the format used by LTI 1.1 apps.
ext_params.each do |key, value|
# for following the format used by LTI 1.1 apps.
message["ext_#{key}"] = value
# for following a standard format used by our own apps.
prefixed_key = key.start_with?('ext_') ? key : "ext_#{key}"
message['ext_params'][prefixed_key] = value
end
# for following a standard format used by our own apps.
message['ext_params'] = keys_with_prefix(ext_params, 'ext_')
# message['ext_params'] = keys_with_prefix(ext_params, 'ext_')
end

curated_message = custom_overrides(message)
Expand Down Expand Up @@ -186,15 +190,4 @@ def safe_custom_override_params
['user_image']
end
end

def keys_with_prefix(keys, prefix)
prefixed_keys = {}

keys.each do |key, value|
prefixed_key = key.start_with?('custom_') ? key : "#{prefix}#{key}"
prefixed_keys[prefixed_key] = value
end

prefixed_keys
end
end

0 comments on commit 05562ed

Please sign in to comment.