cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
wbreitbach
Community Participant

CSS for hiding "Delete Course" and "Cross-listing" buttons from faculty?

We used the following code snippets to hide the Delete Course and Cross-listing buttons from faculty. However, the code also hides the buttons from system admins. We would like the buttons to show for systems admins and not faculty. Any thoughts on how we might accomplish this?

#right-side .crosslist_link {

        display: none;

}

a.btn.button-sidebar-wide.delete_course_link {

display: none !important;

}

Thanks for any advice you can provide.

7 Replies
kona
Community Coach
Community Coach

I can't help with the coding, but I can say that our CSM was able to apply to do this for our Institution, we didn't have to do it ourselves.

cherdt
Community Member

You could accomplish something like this with Javascript, using Canvas's ENV variable:

var hideDelete = true;

for (role in ENV.current_user_roles) {

    if (ENV.current_user_roles[role] === 'admin') {

        hideDelete = false;

    }

}

if (hideDelete) {

    $('.delete_course_link').hide();

}

(The above can be improved upon--for example, first checking to see if the delete button exists on the page before checking the user's admin status.)

bneporadny
Community Champion

Will,

The only way I can find to accomplish this without removing modifying their permissions is using JavaScript. Below is something quick i whipped up.  This should do what you are looking for but I would definitely do some testing in your test environment before adding to live to ensure it works for your institution.

$(document).ready(function () {

       var urlFifthLoc = document.URL.split('/')[5];

       var isTeacher = false;

  

   //Checks to see if user is a teacher

        var roles = ENV['current_user_roles'];

        var arrayLength = roles.length;

        for (var i = 0; i < arrayLength; i++) {   

       if(roles[i] === 'teacher'){

            isTeacher = true;

         }   

  }

  if(isTeacher === true)

  {

       if( urlFifthLoc === 'settings'){

            var el = document.getElementsByClassName("btn button-sidebar-wide delete_course_link");

            if (el.length > 0) {

                 el[0].style.display = "none";

       }

  }

  if( urlFifthLoc === 'sections'){

       var el = document.getElementsByClassName("btn button-sidebar-wide crosslist_link");

       if (el.length > 0) {

            el[0].style.display = "none";

           }

       }    

  }

});

wbreitbach
Community Participant

Thank you so much for the help. We will give it a try. Smiley Happy

Sorry for the delayed reply. We appreciate the support.

wbreitbach
Community Participant

What a fabulous community!!!.

Thank you. We will give it a try.

joel_mills
Community Participant

Can you also post the appropriate code snippet for hiding the moderate tool option in Assignments?

We have disabled the tool in the permissions so staff cannot use it, but it still appears as a selectable option when creating an assignment.

Thanks

Robbie_Grant
Community Coach
Community Coach

 @wbreitbach ,

We are giving the Canvas Admins area a little bit of love (especially questions that are really, really old) and just want to check in with you.  This will also bring this question new attention. 

 

Were you able to find an answer to your question? I am going to go ahead and mark this question as answered because there hasn't been any more activity in a while so I assume that you have the information that you need. If you still have a question about this or if you have information that you would like to share with the community, by all means, please do come back and leave a comment.  Also, if this question has been answered by one of the previous replies, please feel free to mark that answer as correct.

 

Robbie