-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Allow adding custom LTI parameters via LTI_CUSTOM_PARAMS django setting #323
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |||||||||||||||||||||||||||||||||||||||||
| from lms.djangoapps.lti_provider.outcomes import store_outcome_parameters | ||||||||||||||||||||||||||||||||||||||||||
| from lms.djangoapps.lti_provider.signature_validator import SignatureValidator | ||||||||||||||||||||||||||||||||||||||||||
| from lms.djangoapps.lti_provider.users import authenticate_lti_user | ||||||||||||||||||||||||||||||||||||||||||
| from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers | ||||||||||||||||||||||||||||||||||||||||||
| from openedx.core.lib.url_utils import unquote_slashes | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| log = logging.getLogger("edx.lti_provider") | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -59,6 +60,7 @@ def lti_launch(request, course_id, usage_id): | |||||||||||||||||||||||||||||||||||||||||
| if not params: | ||||||||||||||||||||||||||||||||||||||||||
| return HttpResponseBadRequest() | ||||||||||||||||||||||||||||||||||||||||||
| params.update(get_optional_parameters(request.POST)) | ||||||||||||||||||||||||||||||||||||||||||
| params.update(get_custom_parameters(request.POST)) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Get the consumer information from either the instance GUID or the consumer | ||||||||||||||||||||||||||||||||||||||||||
| # key | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -145,6 +147,22 @@ def get_optional_parameters(dictionary): | |||||||||||||||||||||||||||||||||||||||||
| return {key: dictionary[key] for key in OPTIONAL_PARAMETERS if key in dictionary} | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| def get_custom_parameters(params: dict[str]) -> dict[str]: | ||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||
| Extract all optional LTI parameters from a dictionary. This method does not | ||||||||||||||||||||||||||||||||||||||||||
| fail if any parameters are missing. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| :param params: A dictionary containing zero or more parameters. | ||||||||||||||||||||||||||||||||||||||||||
| :return: A new dictionary containing all optional parameters from the | ||||||||||||||||||||||||||||||||||||||||||
| original dictionary, or an empty dictionary if no optional parameters | ||||||||||||||||||||||||||||||||||||||||||
| were present. | ||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+150
to
+159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type hint for
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
| custom_params = configuration_helpers.get_value("LTI_CUSTOM_PARAMS", settings.LTI_CUSTOM_PARAMS) | ||||||||||||||||||||||||||||||||||||||||||
| if not custom_params: | ||||||||||||||||||||||||||||||||||||||||||
| return {} | ||||||||||||||||||||||||||||||||||||||||||
| return {key: params[key] for key in custom_params if key in params} | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| def render_courseware(request, usage_key): | ||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||
| Render the content requested for the LTI launch. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <p> | ||
| <h2><%- title %></h2> | ||
| <table class="stat_table"><tr> | ||
| <%_.forEach(header, function (h) {%> | ||
| <th><%- h %></th> | ||
| <%})%> | ||
| </tr> | ||
| <%_.forEach(data, function (row) {%> | ||
| <tr> | ||
| <%_.forEach(row, function (value) {%> | ||
| <td><%- value %></td> | ||
| <%})%> | ||
| </tr> | ||
| <%})%> | ||
| </table> | ||
| </p> | ||
|
Comment on lines
+1
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The HTML structure is invalid because an |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dictionary construction for the assertion is a bit verbose. Since you're using the
|operator for dictionary union on line 132, you could use it here as well to make the code more concise and readable.