The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December. Read our blog post for more info about this change.
I am the Canvas admin at my institution. I have had two recent incidents where teachers abruptly deleted their courses from Canvas. How do I remove the "delete course" permission from the teacher role?
Solved! Go to Solution.
I'm no good at javascript, but pretty good with CSS. Here's how I solved it in our CSS overrides file:
/* hide the "Permanently Delete this Course" button to prevent teachers from deleting courses */
#right-side a:nth-of-type(5n).delete_course_link {
display:none;
}
Thanks to those who helped.
@delester ,
You can use javascript to remove that button from the Teacher view. This can be done using the Custom Java Script area in the Admin interface.
Robbie
But be advised that there are ways to get around that if they try hard enough.
Yes, but in the 2+ years using it none of the faculty at my Institution have gotten around it! ![]()
Check out the "Branding" >> "JavaScript" folder here: kajigga/canvas-contrib · GitHub. Lots of "tweaks" you can do in JavaScript.
Why have to use JavaScript to remove an option that would seem to be a permissions choice? I can stop an instructor from changing their course name via the GUI, but I can't prevent them from deleting their course. Does "Permanently Delete" mean permanently delete, or can it be restored by the Admin? Or, if we have automated SIS Imports scripts running, would they just re-enable the course, if it is still in the script?
If I have to do this with JavaScript, will future Canvas upgrades incorporate this modification, or would I need to put this in a list to keep checking that it is still working?
@bgibson , just a few minutes ago, cms_hickss posted this convenient compilation of feature ideas that are currently open for voting, all of which pertain to "More Granular Permissions" : more granular permissions (Idea voting closing soon)
Please vote!
Bill Gibson - I don't think much is permanent. You can restore a deleted course by clicking on Admin Tools in your admin dashboard. https://yourdomain.instructure.com/accounts/1/admin_tools
I too think the delete course should be a permission. I also think the un-delete button should be a link in teachers navigation instead of a URL trick.
"Note: Deleting a course is a permission enabled by your admin. If you do not see this button, you do not have permission to delete your course." [ How do I permanently delete my course? ]
I don't think it is a "conservative or liberal" issue. If you provide a button for your users, and label it as, "Hey Stupid! Don't press this button or the World will end," eventually, you will have someone call you up, or email you, letting you know they pressed the button by mistake. And, they will admit, "Yes, they read the button."
I check my custom CSS/JS in beta after each release because they are just that...custom. I agree that the GUI should have controls through permissions to restrict/allow, but since that's not an option I go with some quick JS to hide buttons with serious implications. All comes down to how conservative or liberal your institution is with controls.
I'm no good at javascript, but pretty good with CSS. Here's how I solved it in our CSS overrides file:
/* hide the "Permanently Delete this Course" button to prevent teachers from deleting courses */
#right-side a:nth-of-type(5n).delete_course_link {
display:none;
}
Thanks to those who helped.
If you want to use JS and set it so that admins can view, you can use:
$(document).ready(function(){
if($.inArray('admin',ENV['current_user_roles']) == -1) {
$("a.btn.button-sidebar-wide.delete_course_link").hide();
}
})
This will get you started and allow you to hide other functions from teachers, TA's, etc. Using CSS is good, but it will also take it from you as the admin.
Shane
Thanks, Shane, that's very helpful. Yes CSS takes it away from me as an admin, but it is easy to comment out temporarily if I need to delete a course. Still, I'm going to try your JS solution.
Below is the code that I wrote to hide a number of things from faculty such as: the start and end date so they don't go changing the dates after we set them, breaking tools like Dropout Detective; hiding the conclude button, so they don't conclude courses where students still have incompletes to finish; hiding the public course setting after many instructors have made their course public in the intent to publish it for their students.
I know the code that Shane posted was only one line (inside of the if statement), but I've found that it is a good practice to have your javascript check which page the user is viewing before running. This way anything inside won't need to run at all when the user isn't on the page where the changes are needed and the code will run a little faster. Shane's code is not only running on every page, but it is also running for students, every time they look at any page. I run the role setup code at the start of my js file so that I have access to the role variable wherever I need it.
/* role setup */
var leng = ENV['current_user_roles'].length - 1
var role = ENV['current_user_roles'][leng];
if ((window.location.href.indexOf("details") > 0 || window.location.href.indexOf("settings") > 0) && role == "teacher") {
$("a.btn.button-sidebar-wide.delete_course_link").hide();
$("#course_start_at").parent().hide();
$("#course_conclude_at").parent().hide();
$("#course_visibility").hide();
$("a:contains('Conclude this Course')").hide();
}
Very nice! Yea..what he said... :smileylaugh:
Hi! We used your code to hide the following from the teacher role:
Manually add sections, conclude the course, reset course content, view the course status, and delete this course.
We really appreciate having these options as we do need teachers to able to cross list their sections together manually, but we didn't want them to do all these thing!
We did have an odd thing pop up this term, though. A teacher in a course added some sections manually, which messes up our enrollments, and confuses the students as they have 2 sections named the same thing, but only one is the genuine section from our SIS.
In our research as to how this was happening, we found that the teachers who could manually add sections had an observer role in another course. If we changed their role in the other course, the buttons was hidden from them. When we changed their role in that other course back to observer, they could see the buttons (all except delete this course). Who would have thought that the observer role, which has no access to settings, would impact how our code work when that same person was in the teacher role? Anyway, we added observer to the list to hide these buttons from and now we are good to go! Just thought I would note that for others using this fantastic work around! Hoping that Canvas will on day make all these granular permissions we can select from the teacher role!
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.