# When Deleting a course from Open edX , what effect on role(staff role, instructor role) have and why is it nessary or not?

**URL:** <https://discuss.openedx.org/t/when-deleting-a-course-from-open-edx-what-effect-on-role-staff-role-instructor-role-have-and-why-is-it-nessary-or-not/12774>\
**Category:** Authoring\
**Tags:** how-to\
**Created:** [April 14, 2024, 5:50am UTC](https://discuss.openedx.org/t/when-deleting-a-course-from-open-edx-what-effect-on-role-staff-role-instructor-role-have-and-why-is-it-nessary-or-not/12774 "2024-04-14T05:50:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vivek](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/vivek/32/6825_2.png) [@vivek](https://discuss.openedx.org/u/vivek)\
**Post date:** [April 14, 2024, 5:50am UTC](https://discuss.openedx.org/t/when-deleting-a-course-from-open-edx-what-effect-on-role-staff-role-instructor-role-have-and-why-is-it-nessary-or-not/12774/1 "2024-04-14T05:50:56Z")

</div>

hi,  
i tried to mimic management Command `tutor dev run cms ./manage.py cms delete_course <course_key>` for deleting course  
, i go through this file Command File [delete\_course.py](https://github.com/openedx/edx-platform/blob/master/cms/djangoapps/contentstore/management/commands/delete_course.py)  
and then i made changes in `CourseContext` Model for custom delete method here Like:

```auto
def delete(self, *args, **kwargs):
        # Delete related Sectors instances
        try:
            course_key = self.learning_context.context_key
            module_store = modulestore()
            with module_store.bulk_operations(course_key):
                module_store.delete_course(course_key, ModuleStoreEnum.UserID.mgmt_command)
            contentstore().delete_all_course_assets(course_key)
            # staff_role = CourseStaffRole(course_key)
            # staff_role.remove_users(*staff_role.users_with_role())
            # instructor_role = CourseInstructorRole(course_key)
            # instructor_role.remove_users(*instructor_role.users_with_role())
        except:
            pass
        super().delete(*args, **kwargs)

```

but as you commented lines are for removing all instructor and staff users from the given course  
as these are the functions used in `delete_course.py` from `cms/djangoapps/contentstore/utils.py`

```auto
def remove_all_instructors(course_key):
    """
    Removes all instructor and staff users from the given course.
    """
    staff_role = CourseStaffRole(course_key)
    staff_role.remove_users(*staff_role.users_with_role())
    instructor_role = CourseInstructorRole(course_key)
    instructor_role.remove_users(*instructor_role.users_with_role())

def delete_course(course_key, user_id, keep_instructors=False):
    """
    Delete course from module store and if specified remove user and
    groups permissions from course.
    """
    _delete_course_from_modulestore(course_key, user_id)

    if not keep_instructors:
        _remove_instructors(course_key)

def _delete_course_from_modulestore(course_key, user_id):
    """
    Delete course from MongoDB. Deleting course will fire a signal which will result into
    deletion of the courseware associated with a course_key.
    """
    module_store = modulestore()

    with module_store.bulk_operations(course_key):
        module_store.delete_course(course_key, user_id)

```

, what i have written working , but when i uncomment those four line gives me circular import error.  
now i want to ask , how to Removes all instructor and staff users from the given course or if i do not remove this what impact does it have ??

---

<div class="post-metadata">

**Author:** ![annesulpico](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/annesulpico/32/6497_2.png) [@annesulpico](https://discuss.openedx.org/u/annesulpico)\
**Post date:** [April 16, 2024, 10:24am UTC](https://discuss.openedx.org/t/when-deleting-a-course-from-open-edx-what-effect-on-role-staff-role-instructor-role-have-and-why-is-it-nessary-or-not/12774/2 "2024-04-16T10:24:03Z")

</div>

Hi @vivek! I hope you are well.

To answer your question regarding how to remove all instructor and staff users from a course, I can suggest two options.

**1. Via Instructor Tab**

A user with course staff access will find an **Instructor** tab located in the top menu of the course page.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/openedx/original/2X/f/f98938eb79ef629af1f316471645663955d82a69.png)

Under Instructor tab, select **Membership**.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/openedx/original/2X/e/e5ea016c676805f9e32bb69b3a9bdec363607ca6.png)

Then, scroll down to **Course Team Management** and you will be able to remove all course instructors/staff by clicking **Revoke Access**.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/openedx/original/2X/e/e0c38b16499ffab72dea70640101e3fe7f36251a.png)

**2. Via Django Admin**

You can add or remove course team members through the Course Access Roles table in Django admin.

https://YOUR\_LMS\_URL/admin/student/courseaccessrole

You can look up all the course team members in this table using the course ID, and then remove their access as needed. Below is an example:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/openedx/original/2X/4/4cd6de1f9f18c799a66914231e3d4313c7045437.png)

I hope you find this information helpful! 😊
