Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LTI-382: simplified code into one single loop #254

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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