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>
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:
is there any way to delete course from admin panel , like it is not good running a command in server to delete a course ? , i mean from Ui (there is no option for delete course) side i did’t find anything .
i check this management Command tutor dev run cms ./manage.py cms delete_course <course_key>
, i go through this file Command File delete_course.py
and then i made changes in CourseContext Model for custom delete method here Like:
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
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 ??