Hello everyone,
I am trying to setup a default list of advanced modules in order to save course creators the hustle of setting the list themselves manually every time they create a course.
I have taken a look to the following relevant topics:
Yet none of them have posted anything about the plugin that will achieve this or at least how it should be structured.
I have managed to create the following plugin:
from tutor import hooks
# --- 1. Set default ADVANCED_PROBLEM_TYPES ---
ADVANCED_MODULES = [
"edx_sga",
"lti",
"scorm",
"library_content",
"annotatable",
"poll",
"survey",
"h5pxblock",
"pdf"
]
advanced_problem_types = "\n".join(
f" {{'component': '{component}', 'boilerplate_name': None}}," for component in ADVANCED_MODULES
)
hooks.Filters.ENV_PATCHES.add_item(
(
"openedx-cms-common-settings",
f"""
ADVANCED_PROBLEM_TYPES = [
{advanced_problem_types}
]
"""
)
)
# --- 2. Add extra pip requirements ---
EXTRA_PIP_REQUIREMENTS = [
"h5p-xblock",
"git+https://github.com/blazejwiecha/xblock-pdf.git"
]
pip_lines = "\n".join(f"RUN pip install {req}" for req in EXTRA_PIP_REQUIREMENTS)
hooks.Filters.ENV_PATCHES.add_item(
(
"openedx-dockerfile-post-python-requirements",
pip_lines
)
)
Upon rebuilding the openedx image, I can verify the insertion of the patched setting in the relevant files (assuming common.py should not include the patched setting):
app@43dfbb27f64c:~/edx-platform/cms/envs$ grep -rnw './' -e 'ADVANCED_PROBLEM_TYPES' -A 10
./common.py:2050:ADVANCED_PROBLEM_TYPES = [
./common.py-2051- {
./common.py-2052- 'component': 'drag-and-drop-v2',
./common.py-2053- 'boilerplate_name': None
./common.py-2054- },
./common.py-2055- {
./common.py-2056- 'component': 'staffgradedxblock',
./common.py-2057- 'boilerplate_name': None
./common.py-2058- }
./common.py-2059-]
./common.py-2060-
grep: ./__pycache__/common.cpython-311.pyc: binary file matches
--
./tutor/production.py:285:ADVANCED_PROBLEM_TYPES = [
./tutor/production.py-286- {'component': 'edx_sga', 'boilerplate_name': None},
./tutor/production.py-287- {'component': 'lti', 'boilerplate_name': None},
./tutor/production.py-288- {'component': 'scorm', 'boilerplate_name': None},
./tutor/production.py-289- {'component': 'library_content', 'boilerplate_name': None},
./tutor/production.py-290- {'component': 'annotatable', 'boilerplate_name': None},
./tutor/production.py-291- {'component': 'poll', 'boilerplate_name': None},
./tutor/production.py-292- {'component': 'survey', 'boilerplate_name': None},
./tutor/production.py-293- {'component': 'h5pxblock', 'boilerplate_name': None},
./tutor/production.py-294- {'component': 'pdf', 'boilerplate_name': None},
./tutor/production.py-295-]
--
./tutor/development.py:285:ADVANCED_PROBLEM_TYPES = [
./tutor/development.py-286- {'component': 'edx_sga', 'boilerplate_name': None},
./tutor/development.py-287- {'component': 'lti', 'boilerplate_name': None},
./tutor/development.py-288- {'component': 'scorm', 'boilerplate_name': None},
./tutor/development.py-289- {'component': 'library_content', 'boilerplate_name': None},
./tutor/development.py-290- {'component': 'annotatable', 'boilerplate_name': None},
./tutor/development.py-291- {'component': 'poll', 'boilerplate_name': None},
./tutor/development.py-292- {'component': 'survey', 'boilerplate_name': None},
./tutor/development.py-293- {'component': 'h5pxblock', 'boilerplate_name': None},
./tutor/development.py-294- {'component': 'pdf', 'boilerplate_name': None},
./tutor/development.py-295-]
Yet whenever I create a new course the "Advanced’ option in the insert component area does not show up and the advanced module list in the advanced settings is empty.
Any help on achieving this would be greatly appreciated.
tutor, version 19.0.2