How to set ENABLE_COURSEWARE_SEARCH flag in configuration

Hi. I am new to tutor and I am trying to set the ENABLE_COURSEWARE_SEARCH flag to false.

Things I have tried so far:

  1. Setting the following value in ~/.local/share/tutor/config.yml:
    FEATURES:
      ENABLE_COURSEWARE_SEARCH: false
  1. Setting the following value in ~/.local/share/tutor/env/apps/openedx/settings/lms/common.py:

    FEATURES["ENABLE_COURSEWARE_SEARCH"] = False

For both, I then run tutor config save.
However, the ~/.local/share/tutor/env/apps/openedx/config/lms.env.json file that is generated, still has the following:

 "FEATURES": {
    "ENABLE_COURSEWARE_SEARCH": true
}

Any ideas?

Hi @PavlosIsaris! Your changes to any file in env/ are overwritten whenever you run tutor config save. See the docs: https://docs.tutor.overhang.io/intro.html#how-does-tutor-work

To modify the settings, you should create a small plugin. See the docs on how to create such a plugin: https://docs.tutor.overhang.io/plugins/gettingstarted.html#yaml-file

In your case, your plugin will look like this:

name: disablecoursewaresearch
version: 0.1.0
patches:
  openedx-common-settings: |
    # disable courseware search
    FEATURES["ENABLE_COURSEWARE_SEARCH"] = False

@regis thanks for your quick response!
I created the plugin with the contents you suggested, and it works as expected.

I find it funny though to have to create a plugin for changing the configuration of a framework. It is not something common…

Do I need to run tutor config save, every time I update the contents of the plugin?

You should remember that there are close to 700 settings in edx-platform alone, and that’s not even counting ecommerce, discovery and the other applications. This is the reason why I did not create a tutor setting for every Open edX setting. The good thing with plugins is that it’s easy to enable and disable them. For instance, some settings require that half a dozen other settings should be defined, too. For those cases, you definitely don’t want to have to have to remember the dependencies. Plugins make it easy to bundle dependent settings together.

(Actually, now that you mention it, I realise that it’s possible to write a tutor plugin that would add custom settings to the LMS or the CMS. But I don’t think that would be a good idea.)

Yes. This updates the tutor environment.

Thanks, @regis And what about setting a value that is nested?
For example, as I understand, I should stop making changes to lms.env.json, because it will be re-generated when I run tutor config save.

But I would like to set the 3rd party OAuth2 providers to my app as stated here

Should I add the following lines to .yml file of my plugin?

 openedx-common-settings: |
    FEATURES["ENABLE_THIRD_PARTY_AUTH"] = True
    SOCIAL_AUTH_OAUTH_SECRETS["facebook"] = 'XXXXXX'
    SOCIAL_AUTH_OAUTH_SECRETS["linkedin-oauth2"] = 'YYYYYY'

Because I get an error NameError: name 'SOCIAL_AUTH_OAUTH_SECRETS' is not defined.

Should I use another way of setting these values?

SOCIAL_AUTH_OAUTH_SECRETS is a setting that exists only in the LMS in production mode, so you should not add it to the common settings. So you should an extra patch in your plugin:

 openedx-lms-production-settings: |
    SOCIAL_AUTH_OAUTH_SECRETS["facebook"] = 'XXXXXX'
    SOCIAL_AUTH_OAUTH_SECRETS["linkedin-oauth2"] = 'YYYYYY'

Thank you again, @regis.
I tried to add it as you said, but I still get the error NameError: name 'SOCIAL_AUTH_OAUTH_SECRETS' is not defined

Is this process referred to in any part of the documentation?
Since I am new to the platform I should probably study the documentation more so that I know which settings I can change by which patch area…

For example, I may need to change email settings, etc.

@regis the Social sign in is still not showing. This is the content of my plugin’s settings yml file:

patches:
  openedx-common-settings: |
    FEATURES["ENABLE_COURSEWARE_SEARCH"] = False
    FEATURES["ENABLE_COURSE_DISCOVERY"] = False
    FEATURES["ENABLE_DASHBOARD_SEARCH"] = False
    EMAIL_HOST = 'smtp.mailtrap.io'
    EMAIL_HOST_USER = '123'
    EMAIL_HOST_PASSWORD = '123'
    EMAIL_PORT = '123'

  openedx-lms-common-settings: |
    FEATURES["ENABLE_THIRD_PARTY_AUTH"] = True
    SOCIAL_AUTH_OAUTH_SECRETS = {
      "facebook": "XXXXXX",
      "linkedin-oauth2": "yyyyyy"
    }

Please note that I changed the openedx-lms-production-settings to openedx-lms-common-settings, since I want the social sign in to work also in development mode.

Well, not really. There are many patch statement in the tutor templates and it’s difficult to document them one by one: https://docs.tutor.overhang.io/plugins/api.html#patches
Basically, you need to figure out which settings need to be modified (from the Open edX docs) and then find the relevant patch to add to your plugin. I don’t know how to improve this process, but I’m open to suggestions.

Others have tried to achieve the same result (but I haven’t). I suggest you take a look at their findings: https://discuss.overhang.io/search?q=ENABLE_THIRD_PARTY_AUTH

I see. Well, let’s say that I would like to set the email configuration for my installation.
I should probably set the values at the .yml file of my plugin. I have tried the following:

version: 0.1.0
patches:
  openedx-common-settings: |
    EMAIL_HOST = 'smtp.mailtrap.io'
    EMAIL_HOST_USER = '123'
    EMAIL_HOST_PASSWORD = '123'
    EMAIL_PORT = '123'

But the changes are not reflected into lms.env.json.
Then, I tried to add the email values in openedx-lms-common-settings:

  openedx-lms-common-settings: |
    EMAIL_HOST = 'smtp.mailtrap.io'
    EMAIL_HOST_USER = '123'
    EMAIL_HOST_PASSWORD = '123'
    EMAIL_PORT = '123'

But that did not work, either, since after running tutor config save, the values are not reflected in lms.snv.json…
How can I know where I should add these values?

The following configuration in the config.yml worked for me to send validation emails.

SMTP_HOST: mail.example.com
SMTP_PASSWORD: xxxx
SMTP_PORT: 587
SMTP_USERNAME: noreply-example@example.com
SMTP_USE_TLS: true

1 Like

I enabled the course verification, and I’m getting the next error when I upload photos

aes_key_str = settings.VERIFY_STUDENT["SOFTWARE_SECURE"]["FACE_IMAGE_AES_KEY"]
lms_1               | KeyError: 'SOFTWARE_SECURE'

@regis should I add something to the config.yml?

1 Like

I don’t think this is the real solution since config.yml gets regenerated every time you run “tutor local quickstart” thus destroying the change. You need to set things in a plugin somewhere, so that they get auto-added to the config.yml every time. But I agree the syntax for how exactly to do this is unclear and I’m still fighting with it myself.