How to add a filter in Open edX tutor

Dear community,

I’m running Open edX tutor Quince (17.0.2) in docker. Can someone please tell me how to create a plugin to add a filter to the “OPEN_EDX_FILTERS_CONFIG” variable.

Here’s my filter:

“org.openedx.learning.instructor.dashboard.render.started.v1”: {
“fail_silently”: False,
“pipeline”: [
“platform_plugin_forum_email_notifier.extensions.filters.AddInstructorNotifierTab”,
]
},

Thanks in advance.

best regards,
rax

Hi @rax, you should create a new plugin using the cookiecutter-tutor-plugin and then create a new patch with the name openedx-lms-common-settings. You should add this filter to the variable like so:

OPEN_EDX_FILTERS_CONFIG[“org.openedx.learning.instructor.dashboard.render.started.v1”] = {
“fail_silently”: False,
“pipeline”: [“platform_plugin_forum_email_notifier.extensions.filters.AddInstructorNotifierTab”,]
}

If you want to add this setting to your CMS as well, you should create a patch openedx-cms-common-settings as well and add it there too.

Let me know if this works.

Hello @Danyal_Faheem

Thanks for your replay. I’ve created a plugin

from tutor import hooks

hooks.Filters.ENV_PATCHES.add_items([
(
“openedx-lms-common-settings”,
“”"
OPEN_EDX_FILTERS_CONFIG[“org.openedx.learning.instructor.dashboard.render.started.v1”] = {
“fail_silently”: False,
“pipeline”: [“platform_plugin_forum_email_notifier.extensions.filters.AddInstructorNotifierTab”,]
}
“”"
)
])

But after running tutor local enable myplugin and tutor local launch, it shows me a syntax error message:

:heavy_check_mark: Container tutor_local-permissions-1 Started 0.3s
2024/02/28 10:06:02 Ready: tcp://mysql:3306.
2024/02/28 10:06:02 Ready: tcp://mongodb:27017.
Loading settings lms.envs.tutor.production
Traceback (most recent call last):
File “./manage.py”, line 102, in
startup = importlib.import_module(edx_args.startup)
File “/opt/pyenv/versions/3.8.18/lib/python3.8/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1014, in _gcd_import
File “”, line 991, in _find_and_load
File “”, line 975, in _find_and_load_unlocked
File “”, line 671, in _load_unlocked
File “”, line 843, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/openedx/edx-platform/lms/startup.py”, line 10, in
settings.INSTALLED_APPS # pylint: disable=pointless-statement
File “/openedx/venv/lib/python3.8/site-packages/django/conf/init.py”, line 102, in getattr
self._setup(name)
File “/openedx/venv/lib/python3.8/site-packages/django/conf/init.py”, line 89, in _setup
self._wrapped = Settings(settings_module)
File “/openedx/venv/lib/python3.8/site-packages/django/conf/init.py”, line 217, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File “/opt/pyenv/versions/3.8.18/lib/python3.8/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1014, in _gcd_import
File “”, line 991, in _find_and_load
File “”, line 975, in _find_and_load_unlocked
File “”, line 671, in _load_unlocked
File “”, line 839, in exec_module
File “”, line 976, in get_code
File “”, line 906, in source_to_code
File “”, line 219, in _call_with_frames_removed
File “/openedx/edx-platform/lms/envs/tutor/production.py”, line 310
OPEN_EDX_FILTERS_CONFIG[“org.openedx.learning.instructor.dashboard.render.started.v1”] = {
^
SyntaxError: invalid character in identifier
Error: Command failed with status 1: docker compose -f /root/.local/share/tutor/env/local/docker-compose.yml -f /root/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor_local -f /root/.local/share/tutor/env/local/docker-compose.jobs.yml run --rm lms-job sh -e -c dockerize -wait tcp://mysql:3306 -timeout 20s
dockerize -wait tcp://mongodb:27017 -timeout 20s

Hi @rax, I tested this myself and it seems there is a mixup with the "". When I copied code from this forum as well, the "" converted into “” and those were throwing the same error as you mentioned.

Moreover, if you haven’t defined the OPEN_EDX_FILTERS_CONFIG variable earlier, you should use it this way or it will throw an undefined variable error.

hooks.Filters.ENV_PATCHES.add_items([
(
"openedx-lms-common-settings",
"""
OPEN_EDX_FILTERS_CONFIG = {
    "org.openedx.learning.instructor.dashboard.render.started.v1": {
        "fail_silently": False,
        "pipeline": ["platform_plugin_forum_email_notifier.extensions.filters.AddInstructorNotifierTab",]
    }
}
"""
)
])

Hello @Danyal_Faheem

Sorry for the late response. I was facing an error 500 after enabling the plugin when trying to access the Instructor panel. I changed the patch “openedx-lms-common-settings” to “openedx-common-settings” and now it works:

from tutor import hooks

hooks.Filters.ENV_PATCHES.add_items([
(
“openedx-common-settings”,
“”"
OPEN_EDX_FILTERS_CONFIG = {
“org.openedx.learning.instructor.dashboard.render.started.v1”: {
“fail_silently”: False,
“pipeline”: [“platform_plugin_forum_email_notifier.extensions.filters.AddInstructorNotifierTab”,]
}
}
“”"
)
])

Thanks a lot for your help. Also thank you for the work of adding a navigation menu to the SCORM xblock.

bests,
rax

1 Like