|
59 | 59 | import datetime
|
60 | 60 | import hashlib
|
61 | 61 | import logging
|
| 62 | +import markupsafe |
62 | 63 | import textwrap
|
63 | 64 | from xml.sax.saxutils import escape
|
64 | 65 | from unittest import mock
|
|
81 | 82 | from xblockutils.resources import ResourceLoader
|
82 | 83 | from xblockutils.studio_editable import StudioEditableXBlockMixin
|
83 | 84 |
|
84 |
| -from openedx.core.djangolib.markup import HTML, Text |
85 | 85 | from .lti_2_util import LTI20BlockMixin, LTIError
|
86 | 86 |
|
87 |
| -from common.djangoapps.xblock_django.constants import ( |
88 |
| - ATTR_KEY_ANONYMOUS_USER_ID, |
89 |
| - ATTR_KEY_USER_ROLE, |
90 |
| -) |
| 87 | +# The anonymous user ID for the user in the course. |
| 88 | +ATTR_KEY_ANONYMOUS_USER_ID = 'edx-platform.anonymous_user_id' |
| 89 | +# The user's role in the course ('staff', 'instructor', or 'student'). |
| 90 | +ATTR_KEY_USER_ROLE = 'edx-platform.user_role' |
91 | 91 |
|
92 | 92 | resource_loader = ResourceLoader(__name__)
|
93 | 93 |
|
@@ -228,47 +228,47 @@ class LTIBlock(
|
228 | 228 |
|
229 | 229 | lti_id = String(
|
230 | 230 | display_name=_("LTI ID"),
|
231 |
| - help=Text(_( |
| 231 | + help=markupsafe.escape(_( |
232 | 232 | "Enter the LTI ID for the external LTI provider. "
|
233 | 233 | "This value must be the same LTI ID that you entered in the "
|
234 | 234 | "LTI Passports setting on the Advanced Settings page."
|
235 | 235 | "{break_tag}See {docs_anchor_open}the edX LTI documentation{anchor_close} for more details on this setting."
|
236 | 236 | )).format(
|
237 |
| - break_tag=HTML(BREAK_TAG), |
238 |
| - docs_anchor_open=HTML(DOCS_ANCHOR_TAG_OPEN), |
239 |
| - anchor_close=HTML("</a>") |
| 237 | + break_tag=markupsafe.Markup(BREAK_TAG), |
| 238 | + docs_anchor_open=markupsafe.Markup(DOCS_ANCHOR_TAG_OPEN), |
| 239 | + anchor_close=markupsafe.Markup("</a>") |
240 | 240 | ),
|
241 | 241 | default='',
|
242 | 242 | scope=Scope.settings
|
243 | 243 | )
|
244 | 244 |
|
245 | 245 | launch_url = String(
|
246 | 246 | display_name=_("LTI URL"),
|
247 |
| - help=Text(_( |
| 247 | + help=markupsafe.escape(_( |
248 | 248 | "Enter the URL of the external tool that this component launches. "
|
249 | 249 | "This setting is only used when Hide External Tool is set to False."
|
250 | 250 | "{break_tag}See {docs_anchor_open}the edX LTI documentation{anchor_close} for more details on this setting."
|
251 | 251 | )).format(
|
252 |
| - break_tag=HTML(BREAK_TAG), |
253 |
| - docs_anchor_open=HTML(DOCS_ANCHOR_TAG_OPEN), |
254 |
| - anchor_close=HTML("</a>") |
| 252 | + break_tag=markupsafe.Markup(BREAK_TAG), |
| 253 | + docs_anchor_open=markupsafe.Markup(DOCS_ANCHOR_TAG_OPEN), |
| 254 | + anchor_close=markupsafe.Markup("</a>") |
255 | 255 | ),
|
256 | 256 | default='http://www.example.com',
|
257 | 257 | scope=Scope.settings)
|
258 |
| - |
| 258 | + |
259 | 259 | custom_parameters = List(
|
260 | 260 | display_name=_("Custom Parameters"),
|
261 |
| - help=Text(_( |
| 261 | + help=markupsafe.escape(_( |
262 | 262 | "Add the key/value pair for any custom parameters, such as the page your e-book should open to or "
|
263 | 263 | "the background color for this component."
|
264 | 264 | "{break_tag}See {docs_anchor_open}the edX LTI documentation{anchor_close} for more details on this setting."
|
265 | 265 | )).format(
|
266 |
| - break_tag=HTML(BREAK_TAG), |
267 |
| - docs_anchor_open=HTML(DOCS_ANCHOR_TAG_OPEN), |
268 |
| - anchor_close=HTML("</a>") |
| 266 | + break_tag=markupsafe.Markup(BREAK_TAG), |
| 267 | + docs_anchor_open=markupsafe.Markup(DOCS_ANCHOR_TAG_OPEN), |
| 268 | + anchor_close=markupsafe.Markup("</a>") |
269 | 269 | ),
|
270 | 270 | scope=Scope.settings)
|
271 |
| - |
| 271 | + |
272 | 272 | open_in_a_new_page = Boolean(
|
273 | 273 | display_name=_("Open in New Page"),
|
274 | 274 | help=_(
|
@@ -333,7 +333,7 @@ class LTIBlock(
|
333 | 333 | default=False,
|
334 | 334 | scope=Scope.settings
|
335 | 335 | )
|
336 |
| - |
| 336 | + |
337 | 337 | ask_to_send_email = Boolean(
|
338 | 338 | display_name=_("Request user's email"),
|
339 | 339 | # Translators: This is used to request the user's email for a third party service.
|
@@ -367,7 +367,7 @@ class LTIBlock(
|
367 | 367 | default=True,
|
368 | 368 | scope=Scope.settings
|
369 | 369 | )
|
370 |
| - |
| 370 | + |
371 | 371 | editable_fields = (
|
372 | 372 | "accept_grades_past_due", "button_text", "custom_parameters", "display_name",
|
373 | 373 | "hide_launch", "description", "lti_id", "launch_url", "open_in_a_new_page",
|
@@ -959,12 +959,12 @@ def verify_oauth_body_sign(self, request, content_type='application/x-www-form-u
|
959 | 959 |
|
960 | 960 | if (not signature.verify_hmac_sha1(mock_request_lti_1, client_secret) and not
|
961 | 961 | signature.verify_hmac_sha1(mock_request_lti_2, client_secret)):
|
962 |
| - log.error("OAuth signature verification failed, for " |
963 |
| - "headers:{} url:{} method:{}".format( |
964 |
| - oauth_headers, |
965 |
| - self.get_outcome_service_url(), |
966 |
| - str(request.method) |
967 |
| - )) |
| 962 | + log.error( |
| 963 | + "OAuth signature verification failed, for " |
| 964 | + "headers:{} url:{} method:{}".format( |
| 965 | + oauth_headers, self.get_outcome_service_url(), str(request.method) |
| 966 | + ) |
| 967 | + ) |
968 | 968 | raise LTIError("OAuth signature verification has failed.")
|
969 | 969 |
|
970 | 970 | def get_client_key_secret(self):
|
@@ -996,4 +996,3 @@ def is_past_due(self):
|
996 | 996 | else:
|
997 | 997 | close_date = due_date
|
998 | 998 | return close_date is not None and datetime.datetime.now(UTC) > close_date
|
999 |
| - |
0 commit comments