diff --git a/changelog.d/20240625_104737_kyle_patch_1.md b/changelog.d/20240625_104737_kyle_patch_1.md new file mode 100644 index 0000000..9695ab1 --- /dev/null +++ b/changelog.d/20240625_104737_kyle_patch_1.md @@ -0,0 +1 @@ +- [Bugfix] Fix a bug where the scorm block would fail to load with an error message `No module named 'importlib_resources'` (by @kdmccormick) diff --git a/openedxscorm/__about__.py b/openedxscorm/__about__.py index 28cc149..93eb58c 100644 --- a/openedxscorm/__about__.py +++ b/openedxscorm/__about__.py @@ -1 +1 @@ -__version__ = "18.0.1" +__version__ = "18.0.2" diff --git a/openedxscorm/scormxblock.py b/openedxscorm/scormxblock.py index f94a085..a306ebb 100644 --- a/openedxscorm/scormxblock.py +++ b/openedxscorm/scormxblock.py @@ -15,15 +15,22 @@ from django.utils import timezone from django.utils.module_loading import import_string from webob import Response -import importlib_resources from six import string_types - from web_fragments.fragment import Fragment from xblock.core import XBlock from xblock.completable import CompletableXBlockMixin from xblock.exceptions import JsonHandlerError from xblock.fields import Scope, String, Float, Boolean, Dict, DateTime, Integer +try: + # Older Open edX releases (Redwood and earlier) install a backported version of + # importlib.resources: https://pypi.org/project/importlib-resources/ + import importlib_resources +except ModuleNotFoundError: + # Starting with Sumac, Open edX drops importlib-resources in favor of the standard library: + # https://docs.python.org/3/library/importlib.resources.html#module-importlib.resources + from importlib import resources as importlib_resources + try: try: from common.djangoapps.student.models import CourseEnrollment