Skip to content

Commit

Permalink
chore: replace importlib with loader.load_unicode of Xblock
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBhatti committed Sep 10, 2024
1 parent c25e00b commit af0237b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions concept/concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@

import importlib.resources
from xblock.core import XBlock
from xblock.fields import Integer, Scope, String
from xblock.fields import Scope, String
from xblock.fragment import Fragment

try:
from xblock.utils.resources import ResourceLoader
except ModuleNotFoundError:
from xblockutils.resources import ResourceLoader

import requests


loader = ResourceLoader(__name__)


class ConceptXBlock(XBlock):
"""
This XBlock allows concept tagging in a course.
Expand Down Expand Up @@ -43,8 +51,9 @@ def relay_handler(self, request, suffix):

def resource_string(self, path):
"""Handy helper for getting resources from our kit."""
data = importlib.resources.files(__package__).joinpath(path)
return data.read_text(encoding="utf-8")
data = loader.load_unicode(path)
print(data)
return data

def student_view(self, context=None):
"""
Expand Down

0 comments on commit af0237b

Please sign in to comment.