@@ -139,10 +139,10 @@ def valid_config_type_values(block):
139139 {"display_name" : _ ("Configuration on block" ), "value" : "new" }
140140 ]
141141
142- if database_config_enabled (block .location . course_key ):
142+ if database_config_enabled (block .scope_ids . usage_id . context_key ):
143143 values .append ({"display_name" : _ ("Database Configuration" ), "value" : "database" })
144144
145- if external_config_filter_enabled (block .location . course_key ):
145+ if external_config_filter_enabled (block .scope_ids . usage_id . context_key ):
146146 values .append ({"display_name" : _ ("Reusable Configuration" ), "value" : "external" })
147147
148148 return values
@@ -161,6 +161,7 @@ class LaunchTarget:
161161
162162
163163@XBlock .needs ('i18n' )
164+ @XBlock .needs ('rebind_user' )
164165@XBlock .wants ('user' )
165166@XBlock .wants ('settings' )
166167@XBlock .wants ('lti-configuration' )
@@ -695,8 +696,8 @@ def editable_fields(self):
695696 editable_fields = self .editable_field_names
696697 noneditable_fields = []
697698
698- is_database_config_enabled = database_config_enabled (self .location . course_key ) # pylint: disable=no-member
699- is_external_config_filter_enabled = external_config_filter_enabled (self .location . course_key ) # pylint: disable=no-member
699+ is_database_config_enabled = database_config_enabled (self .scope_ids . usage_id . context_key )
700+ is_external_config_filter_enabled = external_config_filter_enabled (self .scope_ids . usage_id . context_key )
700701
701702 # If neither additional config_types are enabled, do not display the "config_type" field to users, as "new" is
702703 # the only option and does not make sense without other options.
@@ -713,7 +714,7 @@ def editable_fields(self):
713714 if config_service :
714715 is_already_sharing_learner_info = self .ask_to_send_email or self .ask_to_send_username
715716 if not config_service .configuration .lti_access_to_learners_editable (
716- self .course_id ,
717+ self .scope_ids . usage_id . context_key ,
717718 is_already_sharing_learner_info ,
718719 ):
719720 noneditable_fields .extend (['ask_to_send_username' , 'ask_to_send_email' ])
@@ -745,7 +746,7 @@ def context_id(self):
745746 context_id is an opaque identifier that uniquely identifies the context (e.g., a course)
746747 that contains the link being launched.
747748 """
748- return str (self .course_id )
749+ return str (self .scope_ids . usage_id . context_key )
749750
750751 @property
751752 def role (self ):
@@ -763,7 +764,7 @@ def course(self):
763764 """
764765 Return course by course id.
765766 """
766- return self .runtime .modulestore .get_course (self .runtime . course_id )
767+ return self .runtime .modulestore .get_course (self .scope_ids . usage_id . context_key )
767768
768769 @property
769770 def lti_provider_key_secret (self ):
@@ -843,7 +844,7 @@ def get_lti_1p1_user_id(self):
843844 toggling this flag in a running course carries the risk of breaking the LTI integrations in the course. This
844845 flag should also only be enabled for new courses in which no LTI attempts have been made.
845846 """
846- if external_user_id_1p1_launches_enabled (self .location . course_key ): # pylint: disable=no-member
847+ if external_user_id_1p1_launches_enabled (self .scope_ids . usage_id . context_key ):
847848 return self .external_user_id
848849
849850 return self .anonymous_user_id
@@ -880,9 +881,7 @@ def resource_link_id(self):
880881 i4x-2-3-lti-31de800015cf4afb973356dbe81496df this part of resource_link_id:
881882 makes resource_link_id to be unique among courses inside same system.
882883 """
883- return str (urllib .parse .quote (
884- f"{ self .runtime .hostname } -{ self .location .html_id ()} " # pylint: disable=no-member
885- ))
884+ return str (urllib .parse .quote (f"{ settings .LMS_BASE } -{ self .scope_ids .usage_id .html_id ()} " ))
886885
887886 @property
888887 def lis_result_sourcedid (self ):
@@ -1223,7 +1222,7 @@ def lti_1p3_access_token(self, request, suffix=''): # pylint: disable=unused-ar
12231222 # Runtime import because this can only be run in the LMS/Studio Django
12241223 # environments. Importing the views on the top level will cause RuntimeErorr
12251224 from lti_consumer .plugin .views import access_token_endpoint # pylint: disable=import-outside-toplevel
1226- return access_token_endpoint (request , usage_id = str (self .location )) # pylint: disable=no-member
1225+ return access_token_endpoint (request , usage_id = str (self .scope_ids . usage_id ))
12271226
12281227 @XBlock .handler
12291228 def outcome_service_handler (self , request , suffix = '' ): # pylint: disable=unused-argument
@@ -1294,7 +1293,7 @@ def result_service_handler(self, request, suffix=''):
12941293 except LtiError :
12951294 return Response (status = 401 ) # Unauthorized in this case. 401 is right
12961295
1297- user = self .runtime .get_real_user (anon_id )
1296+ user = self .runtime .service ( self , 'user' ). get_user_by_anonymous_id (anon_id )
12981297 if not user : # that means we can't save to database, as we do not have real user id.
12991298 msg = _ ("[LTI]: Real user not found against anon_id: {}" ).format (anon_id )
13001299 log .info (msg )
@@ -1332,7 +1331,7 @@ def _result_service_get(self, lti_consumer, user):
13321331 Returns:
13331332 dict: response to this request as dictated by the LtiConsumer
13341333 """
1335- self .runtime .rebind_noauth_module_to_user (self , user )
1334+ self .runtime .service ( self , 'rebind_user' ). rebind_noauth_module_to_user (self , user )
13361335 args = []
13371336 if self .module_score :
13381337 args .extend ([self .module_score , self .score_comment ])
@@ -1420,7 +1419,7 @@ def set_user_module_score(self, user, score, max_score, comment=''):
14201419 else :
14211420 scaled_score = None
14221421
1423- self .runtime .rebind_noauth_module_to_user (self , user )
1422+ self .runtime .service ( self , 'rebind_user' ). rebind_noauth_module_to_user (self , user )
14241423
14251424 # have to publish for the progress page...
14261425 self .runtime .publish (
@@ -1459,8 +1458,8 @@ def get_lti_1p3_launch_data(self):
14591458 from lti_consumer .api import config_id_for_block
14601459 config_id = config_id_for_block (self )
14611460
1462- location = self .location # pylint: disable=no-member
1463- course_key = str (location .course_key )
1461+ location = self .scope_ids . usage_id
1462+ course_key = str (location .context_key )
14641463
14651464 launch_data = Lti1p3LaunchData (
14661465 user_id = self .lms_user_id ,
@@ -1482,7 +1481,7 @@ def get_context_title(self):
14821481 Return the title attribute of the context_claim for LTI 1.3 launches. This information is included in the
14831482 launch_data query or form parameter of the LTI 1.3 third-party login initiation request.
14841483 """
1485- course_key = self .location . course_key # pylint: disable=no-member
1484+ course_key = self .scope_ids . usage_id . context_key
14861485 course = compat .get_course_by_id (course_key )
14871486
14881487 return " - " .join ([
@@ -1555,7 +1554,7 @@ def _get_context_for_template(self):
15551554 return {
15561555 'launch_url' : launch_url .strip (),
15571556 'lti_1p3_launch_url' : lti_1p3_launch_url ,
1558- 'element_id' : self .location . html_id (), # pylint: disable=no-member
1557+ 'element_id' : self .scope_ids . usage_id . html_id (),
15591558 'element_class' : self .category ,
15601559 'launch_target' : self .launch_target ,
15611560 'display_name' : self .display_name ,
0 commit comments