From 730bec25bb5e212674bf280e5e70accc378ff903 Mon Sep 17 00:00:00 2001 From: Irtaza Akram Date: Tue, 7 Jan 2025 13:49:22 +0500 Subject: [PATCH] fix: errors --- xmodule/x_module.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/xmodule/x_module.py b/xmodule/x_module.py index 1478d6b9bd6d..3df98808169d 100644 --- a/xmodule/x_module.py +++ b/xmodule/x_module.py @@ -14,6 +14,7 @@ from opaque_keys.edx.asides import AsideDefinitionKeyV2, AsideUsageKeyV2 from opaque_keys.edx.keys import UsageKey from importlib.resources import files, as_file +from pathlib import Path from web_fragments.fragment import Fragment from webob import Response from webob.multidict import MultiDict @@ -872,11 +873,13 @@ def get_template_dirpaths(cls): """ template_dirpaths = [] template_dirname = cls.get_template_dir() - if template_dirname: - template_path = files(__name__).joinpath(template_dirname) - if template_path.is_dir(): - with as_file(template_path) as resolved_path: - template_dirpaths.append(str(resolved_path)) + package, module_path = __name__.split('.', 1) + module_dir = str(Path(module_path).parent) + file_dirs = files(package).joinpath(module_dir, template_dirname) + + if template_dirname and file_dirs.is_dir(): + with as_file(file_dirs) as path: + template_dirpaths.append(path) custom_template_dir = cls.get_custom_template_dir() if custom_template_dir: