Skip to content

Commit

Permalink
fix: make it work in library v2
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVZ96 committed Jan 30, 2025
1 parent 9671892 commit bce1829
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion openassessment/xblock/openassessmentblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 352 in openassessment/xblock/openassessmentblock.py

View check run for this annotation

Codecov / codecov/patch

openassessment/xblock/openassessmentblock.py#L352

Added line #L352 was not covered by tests

@cached_property
def course(self):
Expand Down
5 changes: 4 additions & 1 deletion openassessment/xblock/studio_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Check warning on line 483 in openassessment/xblock/studio_mixin.py

View check run for this annotation

Codecov / codecov/patch

openassessment/xblock/studio_mixin.py#L483

Added line #L483 was not covered by tests
team_configuration = self.get_team_configuration(course_id)
if not team_configuration:
return None
Expand Down

0 comments on commit bce1829

Please sign in to comment.