From bce18293c68b6b4001d3b86fdceb2eca74b2afd6 Mon Sep 17 00:00:00 2001 From: Daniel Valenzuela Date: Thu, 30 Jan 2025 15:39:37 -0300 Subject: [PATCH] fix: make it work in library v2 --- openassessment/xblock/openassessmentblock.py | 4 +++- openassessment/xblock/studio_mixin.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openassessment/xblock/openassessmentblock.py b/openassessment/xblock/openassessmentblock.py index f3ee3a39be..14af9aedc2 100644 --- a/openassessment/xblock/openassessmentblock.py +++ b/openassessment/xblock/openassessmentblock.py @@ -347,7 +347,9 @@ def api_data(self): @property def course_id(self): - return str(self.xmodule_runtime.course_id) # pylint: disable=no-member + if hasattr(self, "xmodule_runtime"): + return str(self.xmodule_runtime.course_id) # pylint: disable=no-member + return None @cached_property def course(self): diff --git a/openassessment/xblock/studio_mixin.py b/openassessment/xblock/studio_mixin.py index f848c19e53..3e74c1e6c7 100644 --- a/openassessment/xblock/studio_mixin.py +++ b/openassessment/xblock/studio_mixin.py @@ -11,6 +11,7 @@ from web_fragments.fragment import Fragment from xblock.core import XBlock from xblock.fields import List, Scope +from opaque_keys.edx.locator import LibraryLocatorV2 from django.template.loader import get_template from django.utils.translation import gettext_lazy @@ -454,7 +455,7 @@ def get_base_url_path_for_course_assets(self, course_key): """ Returns base url path for course assets """ - if course_key is None: + if (course_key is None) or isinstance(course_key, LibraryLocatorV2): return None placeholder_id = uuid4().hex @@ -478,6 +479,8 @@ def get_teamsets(self, course_id): """ Wrapper around get_team_configuration that returns team names only for display """ + if isinstance(course_id, LibraryLocatorV2): + return None team_configuration = self.get_team_configuration(course_id) if not team_configuration: return None