From 2c3f7a5c702f07f8efd890c288d0198cd7aca75d Mon Sep 17 00:00:00 2001 From: Muhammad Farhan Date: Mon, 1 Jul 2024 20:04:44 +0500 Subject: [PATCH] refactor: Resolve LTI-AGS grading issue --- lti_consumer/lti_xblock.py | 5 ++--- lti_consumer/plugin/compat.py | 10 ++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lti_consumer/lti_xblock.py b/lti_consumer/lti_xblock.py index e62baff5..8e64fa48 100644 --- a/lti_consumer/lti_xblock.py +++ b/lti_consumer/lti_xblock.py @@ -161,7 +161,6 @@ class LaunchTarget: @XBlock.needs('i18n') -@XBlock.needs('rebind_user') @XBlock.wants('user') @XBlock.wants('settings') @XBlock.wants('lti-configuration') @@ -1365,7 +1364,7 @@ def _result_service_get(self, lti_consumer, user): Returns: dict: response to this request as dictated by the LtiConsumer """ - self.runtime.service(self, 'rebind_user').rebind_noauth_module_to_user(self, user) + self.runtime.rebind_noauth_module_to_user(self, user) args = [] if self.module_score: args.extend([self.module_score, self.score_comment]) @@ -1453,7 +1452,7 @@ def set_user_module_score(self, user, score, max_score, comment=''): else: scaled_score = None - self.runtime.service(self, 'rebind_user').rebind_noauth_module_to_user(self, user) + self.runtime.rebind_noauth_module_to_user(self, user) # have to publish for the progress page... self.runtime.publish( diff --git a/lti_consumer/plugin/compat.py b/lti_consumer/plugin/compat.py index 0e94cdb1..1350dae5 100644 --- a/lti_consumer/plugin/compat.py +++ b/lti_consumer/plugin/compat.py @@ -100,7 +100,7 @@ def load_block_as_user(location): # pragma: nocover """ # pylint: disable=import-error,import-outside-toplevel from crum import get_current_user, get_current_request - from lms.djangoapps.courseware.block_render import get_block_for_descriptor_internal + from lms.djangoapps.courseware.module_render import get_module_for_descriptor_internal from openedx.core.lib.xblock_utils import request_token # Retrieve descriptor from modulestore @@ -114,12 +114,13 @@ def load_block_as_user(location): # pragma: nocover return descriptor # If not load this block to bind it onto the user - get_block_for_descriptor_internal( + get_module_for_descriptor_internal( user=user, descriptor=descriptor, student_data=None, course_id=location.course_key, track_function=None, + xqueue_callback_url_prefix="", request_token=request_token(request), ) return descriptor @@ -138,19 +139,20 @@ def _load_block_as_anonymous_user(location, descriptor): # pragma: nocover # pylint: disable=import-error,import-outside-toplevel from crum import impersonate from django.contrib.auth.models import AnonymousUser - from lms.djangoapps.courseware.block_render import get_block_for_descriptor_internal + from lms.djangoapps.courseware.module_render import get_module_for_descriptor_internal # ensure `crum.get_current_user` returns AnonymousUser. It returns None when outside # of request scope which causes error during block loading. user = AnonymousUser() with impersonate(user): # Load block, attaching it to AnonymousUser - get_block_for_descriptor_internal( + get_module_for_descriptor_internal( user=user, descriptor=descriptor, student_data=None, course_id=location.course_key, track_function=None, + xqueue_callback_url_prefix="", request_token="", )