Deleting a course from Open edX

Most of you might be wondering how to delete a course from the Open edX once its created!

Recently we at Blend-ed also had this issue. We couldn’t find any buttons that helped us do this either from the Studio or the LMS.

While going through some of the documentations we had in the Overhang.io discussions, I came across a tutor command. But when tested, it didn’t work well but later realised that it was due to the new tutor commands

Thus we found out this command (olive and above):

tutor <local or k8s based on your deployment> exec cms ./manage.py cms --setting=tutor.production delete_course <course_id>

For versions before Olive

tutor <local or k8s> run cms ./manage.py cms --setting=tutor.production delete_course <course_id>

6 Likes

One tip extra: if you can delete courses shown in the Studio app, you can help with the following command:

tutor <dev, local or k8s> exec cms ./manage.py cms --setting=tutor. Development delete_course 'COURSE_ID_TO_DELETE'

Where:

  • COURSE_ID_TO_DELETE, is the course to delete, you can find the course ID in the URL of the course. The course ID is the part of the URL that comes after course-v1:.
    If the URL of your course is https://your-domain/courses/course-v1:ORGANIZATION+COURSE_NUMBER+COURSE_RUN/, then the course ID is ORGANIZATION+COURSE_NUMBER+COURSE_RUN.
    For example, from the example URL https://your-domain/courses/course-v1:edX+DemoX+Demo_Course/ the course ID is 'course-v1:edX+DemoX+Demo_Course'

Then execute the following command:

tutor <dev, local or k8s> exec cms ./manage.py cms --setting=tutor.development delete_course 'course-v1:edX+DemoX+Demo_Course'

Response to answers:

Are you sure you want to delete course course-v1:edX+DemoX+Demo_Course? [y/N] y
Are you sure? This action cannot be undone! [y/N] y

When finish the course deletion, show the following message:

Deleted course course-v1:edX+DemoX+Demo_Course

This tip is very helpful when you need to delete some courses that you don’t need any more from the Studio app. For more details about some examples to use this command, check the following link https://github.com/openedx/edx-platform/blob/115833c323e5f0e32e9456aafcb43353cb6d97e5/cms/djangoapps/contentstore/management/commands/delete_course.py#L22

2 Likes