Prevent staff to create courses for different organizations

I want to assign staff users to one or more organizations. Thanks to this thread, I can access to courses which belongs to specific organization(s) as staff. But, when I want to create a course, those staffs still can create courses for any organization. Is there a way to prevent this and allow course creation for only selected organization(s). Thanks in advance!

Hi @mcan :slight_smile:

You need to enable the FEATURES['ENABLE_CREATOR_GROUP'] flag (instructions for how to enable feature flags in Tutor are here: How to set ENABLE_COURSEWARE_SEARCH flag in configuration - #2 by regis - Tutor - Overhang.IO).

Once thatā€™s done, youā€™ll be able to log in to the Studio Django Admin (https://your-studio-url.org/admin) and add Course Creator users linked to specific Organizations. ref Maple release Notes: Instructor Experiences

EDIT: Originally had the LMS Django Admin links above, but the Course Creators must be accessed from Studio.

Thank you for your answer @jill , but I have an issue. I am using tutor 15.3.5 on development mode and I guess the forum link you shared seems a bit old since documentation links are not available anymore. Therefore, I created a tutor plugin myself

from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item(
    (
        "openedx-cms-common-settings",
        "FEATURES['ENABLE_CREATOR_GROUP'] = True"
    )
)

I enabled this plugin and tried to go <tutor_page>/admin/course_creators/coursecreator/ but I got Page not found error. I looked cor course creation in admin page but could not found anything related. I tried with changing cms with lms and removing it but did not work. I am missing anything else?

@mcan Ahhā€¦ Apologies for those broken links, but also: I misled you on the URL for accessing the Course Creators! Itā€™s available in the Studio Django Admin, not the LMS:

http://studio.local.overhang.io:8001/admin/course_creators/coursecreator/

(That is my tutor dev URL, yours may have a different hostname/port. Iā€™ll fix it on my original post too.)

If the above still isnā€™t working, then you might need to modify your plugin. According to the examples in the latest Tutor docs, you can add to the FEATURES like this:

from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item(
    (
        "common-env-features",
        """
"ENABLE_CREATOR_GROUP": true
"""
    )
)

Or with the modern way of patching plugins, by creating a file at <tutoryour_plugin>/patches/common-env-features which contains:

ENABLE_CREATOR_GROUP: true

To check whether your plugin worked and the setting has actually been applied, you can use the shell:

(tutor) $  tutor dev dc exec cms ./manage.py cms shell

from django.conf import settings
settings.FEATURES.get("ENABLE_CREATOR_GROUP")
# True

@jill Okay, I can see course_creator page even without any plugin, but it seems I cannot add anything to it. I am pasting my plugin below

from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item(
    (
      "common-env-features",
      """
        'ENABLE_CREATOR_GROUP': true
      """
    )
)

When I enable this plugin I start to get error.

lms_1 | raise ParserError(ā€œwhile parsing a block mappingā€, self.marks[-1],
lms_1 | yaml.parser.ParserError: while parsing a block mapping
lms_1 | in ā€œ/openedx/config/lms.env.ymlā€, line 1, column 1
lms_1 | expected , but found ā€˜ā€™
lms_1 | in ā€œ/openedx/config/lms.env.ymlā€, line 12, column 3
tutor_dev_lms_1 exited with code 1

Same error also happens for dev_cms, dev_lms_worker and dev_cms_worker containers as well. I guess there is a sytnax error. maybe @regis knows if there is a problem with plugin? I also could not found any setting named ENABLE_CREATOR_GROUP in feature toggles page

@mcan Hereā€™s my plugin (which youā€™re welcome to copy, fork, whatever you need): GitHub - pomegranited/tutor-contrib-enable-feature-flag: Demonstrates how to add a feature flag to Tutor

It uses the new method for adding patches, under the pluginā€™s patches dir: feat: enables ENABLE_CREATOR_GROUP flag Ā· pomegranited/tutor-contrib-enable-feature-flag@295de35 Ā· GitHub

I also could not found any setting named ENABLE_CREATOR_GROUP in feature toggles page

I guess those docs are out of dateā€¦ these docs show it:

https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/open-release-maple.master/feature_flags/feature_flag_index.html

2 Likes

@jill I am grateful for the plugin. I installed it using pip and enabled it and restarted tutor. Then I opened <studio_page>/admin/course_creators/coursecreator/ But page just looks like this.


I canā€™t add course creator, just like before I enable your plugin. So, I checked if plugin is working, and used the codes you mentioned below.

And It returned False. I checked the env folder with grep -r ā€œENABLE_CREATOR_GROUPā€ and found

env/apps/openedx/config/cms.env.yml:  ENABLE_CREATOR_GROUP: true
env/apps/openedx/config/lms.env.yml:  ENABLE_CREATOR_GROUP: true

So, it seems plugin is changing the flag but somehow it is not applied to docker images. I tried to restart and tutor images build --no-cache openedx but nothing changed.

Thank you a lot for all your help.

Well, I found out what is the issue. I entered into cms_1 docker then navigated to ~/edx-platform/cms/envs, and run grep -r ā€œENABLE_CREATOR_GROUPā€ command. Result was,

devstack.py:FEATURES['ENABLE_CREATOR_GROUP'] = False
common.py:    'ENABLE_CREATOR_GROUP': True,
test.py:FEATURES['ENABLE_CREATOR_GROUP'] = False

I realized what was happening. setting in devstack.py is overriding it. I donā€™t know if there is a way to disable it. Therefore, I installed and enabled plugin in my production server. Then I re-run python codes to check ENABLE_CREATOR_GROUP and it was true. This means, they force some of feature settings to be false. @jill But, I still canā€™t add course creators inside /admin/course_creators/coursecreator/

Uckā€¦ thatā€™s annoying, Iā€™m so sorry this is so difficult! It really shouldnā€™t be.

From what I can see of this PR which added this feature flag, that dev was done in the old devstack, not Tutor, and they manually override the devstack flag instead of making it properly env-configurable everywhere.

Fixing this requires a PR against edx-platformā€¦ I will poke around and raise an issue to get this fixed; stay tuned.

This is really convoluted and bizarre, but also from reading that PR, users need to request course creator access, which creates rows in the CourseCreator table that need an admin user to approve them. These approval requests get emailed to yet another FEATURES setting: FEATURES['STUDIO_REQUEST_EMAIL']. Iā€™ve added this to my plugin: GitHub - pomegranited/tutor-contrib-enable-feature-flag: Demonstrates how to add a feature flag to Tutor

If you sign into your production Studio as a non-staff, non-superuser, do you see an option to request course creator access?

1 Like

Ok, Iā€™m learning a lot hereā€¦

We shouldnā€™t be running tutor dev unless weā€™re actually doing development on Tutor itself (ref, though note: this may change too, cf Tutor Enhancement Proposal (TEP) for a quicker development workflow)

  • tutor dev runs openedx with development settings (i.e., cms/env/devstack.py).
  • tutor local uses the production settings, and so allows us to override FEATURES using Tutorā€™s configurable environment variables.

So even though this devstack issue is confusing, I donā€™t think a PR to fix it would be accepted. We just need to use tutor local when doing local openedx dev. However:

@mcan , if this is still not working for you in tutor local / production, please let me know?

1 Like

@jill It all makes sense now. I thought local is for production server and dev is for local development. The plugin you gave me works and I managed to add user as course creator. And combining this with previous knowledge I managed to assign a user to a specific organization as course creator and staff/instructor for organizationā€™s previously created courses. Thank you for your help.

1 Like

So glad we got there in the end!
Thanks for persevering, and good luck!

Just stumbling into this old thread now. Glad you folks were able to find a plugin that solves the issue. :slightly_smiling_face:

I do want to clarify that tutor dev is indeed intended for Open edX development, just like devstack. It had some issues that made many folks prefer devstack, but we have been steadily working through those. Check out Tutorā€™s Open edX dev guide for the latest.

Itā€™s also perfectly OK to use tutor local for development, but it is missing some things that are good to have in dev mode, like ipdb, automatic code reloading, and uncompressed static assets artifacts.

Regarding ENABLE_CREATOR_GROUP: I believe this was set to False for development mode because we wanted it to be easy for devstack users to create test courses without having to explicitly add their test users to the course creator group. In retrospect, this causes a confusing difference in behavior between dev and prod! It would probably be better if the flag were True everywhere, and if devstack handled it by adding users to the course creator group as a provisioning step.