Skip to content

Commit

Permalink
fix: use resource_loader
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahQureshee committed Sep 9, 2024
1 parent 354f836 commit 30c4ebf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions invideoquiz/invideoquiz.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,36 @@
import json
import os

import importlib.resources

from xblock.core import XBlock
from xblock.fields import Scope
from xblock.fields import String
from xblock.validation import ValidationMessage

try:
from web_fragments.fragment import Fragment
except ImportError:
# For backward compatibility with quince and earlier.
from xblock.fragment import Fragment
from xblock.validation import ValidationMessage

try:
from xblock.utils.studio_editable import StudioEditableXBlockMixin
from xblock.utils.resources import ResourceLoader
except ModuleNotFoundError:
# For backward compatibility with releases older than Quince.
from xblockutils.studio_editable import StudioEditableXBlockMixin
from xblockutils.resources import ResourceLoader


from .utils import _

resource_loader = ResourceLoader(__name__)

def get_resource_string(path):
"""
Retrieve string contents for the file path
"""
path = os.path.join('public', path)
resource_string = importlib.resources.files(__package__).joinpath(path)
return resource_string.read_text(encoding='utf8')
return resource_loader.load_unicode(path)


class InVideoQuizXBlock(StudioEditableXBlockMixin, XBlock):
Expand Down

0 comments on commit 30c4ebf

Please sign in to comment.