Browse Source

code formatting and changelog

pull/75/head
adam j hartz 1 month ago
parent
commit
5a6cfdff85
Signed by: hz <hartz@mit.edu> GPG Key ID: 5FDD2840E179AD62
2 changed files with 17 additions and 8 deletions
  1. +2
    -0
      CHANGELOG.md
  2. +15
    -8
      catsoop/lti.py

+ 2
- 0
CHANGELOG.md View File

@@ -13,6 +13,8 @@ _Work toward next release. Currently under development._
* Added ability to avoid running children's preloads into `cs_children`, by
setting `cs_load_children = False`

* Added support for using LTI with Canvas.

**CHANGED:**

* Auto-generated `csq_name` fields increment for every question, even those


+ 15
- 8
catsoop/lti.py View File

@@ -68,9 +68,10 @@ class lti4cs(pylti.common.LTIBase):
self.consumers, url, method, environment, params
)
LOGGER.info("[lti.lti4cs.verify_request] verify_request success")
extra_fields = [ self.config.get("lti_user_id_field") ] + ['tool_consumer_info_product_family_code',
'tool_consumer_.*',
'custom_canvas_.*',
extra_fields = [self.config.get("lti_user_id_field")] + [
"tool_consumer_info_product_family_code",
"tool_consumer_.*",
"custom_canvas_.*",
]
for prop in pylti.common.LTI_PROPERTY_LIST + extra_fields:
if prop is None:
@@ -86,7 +87,11 @@ class lti4cs(pylti.common.LTIBase):
for key in params:
m = re.match(prop, key)
if m:
LOGGER.info("[lti.lti4cs.verify_request] params %s=%s", prop, params.get(key, None))
LOGGER.info(
"[lti.lti4cs.verify_request] params %s=%s",
prop,
params.get(key, None),
)
self.lti_data[key] = params[key]

self.session["lti_data"] = self.lti_data
@@ -333,10 +338,12 @@ def serve_lti(context, path_info, environment, params, dispatch_main, return_con
lti_data = session_data["lti_data"]
lup = context["cs_lti_config"].get("lti_username_prefix", "lti_")

default_user_id_field = "user_id" # used by OpenEdX
if 'canvas' in lti_data.get("tool_consumer_info_product_family_code"):
default_user_id_field = "custom_canvas_user_login_id" # used by Canvas LMS
lti_user_id_field = context["cs_lti_config"].get("lti_user_id_field", default_user_id_field) # allow config to override LTI field to use for uname
default_user_id_field = "user_id" # used by OpenEdX
if "canvas" in lti_data.get("tool_consumer_info_product_family_code"):
default_user_id_field = "custom_canvas_user_login_id" # used by Canvas LMS
lti_user_id_field = context["cs_lti_config"].get(
"lti_user_id_field", default_user_id_field
) # allow config to override LTI field to use for uname

lti_uname = lti_data[lti_user_id_field]
if not context["cs_lti_config"].get("force_username_from_id"):


Loading…
Cancel
Save