Bulk Remove Students Tool (Updated 2/16/22)

chadscott
Community Contributor
49
17296

I created a new userscript for removing students from courses in bulk. This will be particularly useful when managing clubs/activity and remediation manually created courses that aren’t set to conclude. For instance, I can see us using this heavily to manage NHS/NJHS, Class of "2018" courses, LOTE clubs, and anything else that has rolling members.

 

To setup the script –

  1. Install Tampermonkey (if you don’t have it already)
  2. Install the script by going to the following link
    1. Click the “install” button that pops up in Tampermonkey
  3. Change the "@include" on line 7 to match your institutions Canvas URL setup
    // @include https://*.instructure.com/courses/*/users‍‍
  4. It is currently setup to only be visible to admin as our teachers don't have enrollment privileges
    1. If you are a teacher with enrollment privileges (you can add/remove people), then change Line 22 to include "teacher" as a role.
      var buttonRoles = ["teacher", "admin", "root_admin"];‍‍‍

 

To use the script –

  1. Open Chrome
  2. Navigate to the people tab in a course and it should pop up near the top.
    295748_removestudentbttnpng.PNG

 

Features 

  1. Lists student name, section, enrollment date, and last activity date in a sortable table.
    310612_Capture.PNG
  2. Select All checkbox or select individual students

 

Limitations –

  1. This currently only works for students. I figure we don’t usually have more than a handful of teachers in a course, so that can usually be managed by hand.

 

Let me know what you think and if have feature ideas or improvements, let me know!

 

*EDIT 2/16/22 - Added pagination to load all students at once and async chunking of removal requests to prevent rate limitation errors. I also added loading icons to make user aware script is running.

*EDIT 4/22/19 - Added Section column*

 

Cheers,

Chad

49 Comments
lstickdo
Community Participant

This is wonderful! Thanks so much! Lisa

Boekenoogen
Community Contributor

This is a very nice tool. I hope to modify it to add and remove teachers.

lstickdo
Community Participant

If the script is modified to add/remove teachers, can you share it with all of us? That would be a great extra feature.

Lisa

Boekenoogen
Community Contributor

You bet! Smiley Happy

chadscott
Community Contributor

Just make sure to make a fork off of my GitHub Smiley Happy

maguire
Community Champion

When developing some tools for migrating grades for students from another system to Canvas, I found it useful to be able to remove all of the users from a course (except for myself) and to be able to remove assignments and custom columns from the gradebook. Therefore, I wrote two python script to do this. See Remove users and remove assignments & custom columns: Chip sandbox 

Unlike @ @chadscott  's tool, my script does not let you manually selected users, but rather gets rid of all users (except for the user running the program). So the purpose is quite different, but sometimes it is useful to remove all of the users in a course - in order to start over.

I should also note that I used this when experimenting in the test environment so that there are no permanent records generated.

de_millington
Community Contributor

I like Chad's idea. I have one question and one recommendation/suggestion to add.

First the recommendation/suggestion. Could this be adapted for Admins to make quick selections across courses?

The question. The removal feature for Teachers in the People section that was once available for manually added users appears to have disappeared. Is anyone aware of any changes that may have led to this?

d_price
Community Explorer

Hi Chad

I've modified the script so it only works with Observers, interested in making it work with a number of roles.  I'm no API developer but I know a bit about programming.  I'm finding it only deletes about 10 to 20 observers at a time, wondered if you had any idea why that would be?

Never used GitHub but happy to share with you or follow instructions on how to add it Smiley Happy

Thanks

David

Boekenoogen
Community Contributor

I was able to change the Bulk Remove Students Tool to Bulk Remove Teachers Tool. IT works on the same principles that if you have more than one Teacher in a shell, you can bulk remove them. Here is a link to the file on our Google Drive. Bulk Teacher Remove Tool. If you are having trouble downloading it, please let me know.

John Bokenoogen, PhD

Director of Academic Technology

University of Oklahoma

chadscott
Community Contributor

Hi David,

I recently noticed that myself. I guess I never tried removing more than a handful at a time during testing. I think it might be hitting up against the API call throttle...I'll have to investigate this summer and come up with a fix. I think others have talked about this issue and I'll just need to find their blog post about it and implement the work-around.

James
Community Champion

The throttle may be an issue, but if you're calling from within a browser, you can only have about 6 concurrent requests at a time unless people have tweaked their settings. I would look at the network traffic in the browser's developer tools where you can see the response headers and tell if the x-rate-limit-remaining is getting close to 0. If you're making calls synchronously (I doubt it since you're using JavaScript), then you'll basically never hit the threshold. If it's a super-long-running script, then you may be hitting the execution limit (about 5 minutes with Chrome). Again, that doesn't seem likely.

anthony_sales1
Community Member

Brilliant Tool - will save so much time Smiley Happy

cmulligan
Community Member

Why would I not get the checkboxes to the left of the students name?  Everything else looks good and matches above.

qnguyen
Community Contributor

Thanks it worked well

atshelp
Community Member

I got as far as seeing the "Manage Course Enrollments" button on the people page.

 

The button is there, but when I click it, nothing happens.  It's just like a dead button.

I've tried both Chrome and Firefox.

Any idea what may be happening?

Thanks!

 

c_carrillo1
Community Participant

When I click the button in Chrome or Firefox, it either does nothing, or sometimes the list of students gets added to the bottom of the current page, without the pop-up or the controls to allow checking boxes or removing.  I'm not sure what to do about that.  A new version of the script or any ideas are welcome.  Thanks.

 

jbeecher
Community Explorer

Will this delete students permanently? Or conclude them so I could access them again if needed?

Yenti
Community Novice

@chadscott , I have the same issues with other users who commented last. I see the Manage Course Enrollments but when I clicked it, nothing happens. Do you have a newer version of the scripts? Appreciate the help. 

Oops never mind, I didn't realize the institution URL I need to copy-paste is on the PEOPLE PAGE itself. It works GREAT! Thank you!

c_carrillo1
Community Participant

It's so frustrating, I just cannot get this to work in either Chrome or Firefox, even if I disable all other extensions and made sure pop-ups are enabled.  The "Manage Course Enrollments" button appears on the People tab, but when I click it, nothing happens (no pop-up).  

Does anyone have any idea how to get this script working?  It seems to have a lot of potential.

Thank you for your help,.

 

c_carrillo1
Community Participant

Would one of you be willing to post if this tool is working for you?  I've been trying to get it to work for months in multiple browsers and clicking the button still does nothing.

jbeecher
Community Explorer

It's not working for me, either. 

c_carrillo1
Community Participant

Sorry it's not working but glad to see it's not just me.  I had decided I must be crazy.  

Is there anyone on this thread who can help us get this working?

 
ken_i_mayer
Community Participant

It is working perfectly for me in Chrome with TamperMonkey. Did you follow the instructions to edit the script with your site in the "@include"? Have you inspected to see if any errors are showing up in the console?


I have created another version to delete "completed" /(concluded) enrollments. We need to purge our language placement exams, and the completed students were gluttering the gradebook.

c_carrillo1
Community Participant

I've made a video showing the exact issue I'm having with the script.

Link to video:  https://www.screencast.com/t/YAwv0dUfo

If you have a chance please take a look.  Maybe the solution is something obvious that I have missed.  I have already allowed pop-ups from the site, so I don't think that's it.

Chrome version: 91.0.4472.114 (Official Build) (64-bit)
Thanks!

michael5
Community Contributor

THANK YOU so much for this - it's saved me so much time. 🙂 

Chris_Hofer
Community Coach
Community Coach

@c_carrillo1 ...

I am experiencing the same thing you've shown in your screencast.

@chadscott ... any way to get this fixed/corrected?

chadscott
Community Contributor

@Chris_Hofer and @c_carrillo1  I'm sorry for the delay in response - It's been rough and I've had to put this tool on the back burner because it needs some work. I plan on redoing this to paginate correctly and fix the exceeding limit issue. Virtual learning has just tabled most of my projects. 

I'm not able to reproduce the issue - Can you open the developer panel (F12) and capture the errors that are coming up?

Thanks,
Chad Scott
Katy ISD

c_carrillo1
Community Participant

These are the messages I see in the console when I click the Manage Course Enrollments button:

TypeError: $(...).dialog is not a function
at HTMLButtonElement.openDialog (userscript.html?name=Canvas%20Student%20Course%20Enrollment%20Manager.user.js&id=f663adf0-5e57-4d92-a93f-76388f67a374:263)
condition-matcher.ts:136 Problems with selector: "."

Here's a screenshot video: https://www.screencast.com/t/IDKFsB0iqBn

Please let me know what else I can capture.  Thanks.

 

 
JamesSekcienski
Community Contributor

@c_carrillo1  Could you show a screenshot of your code so that we know what the code looks like at line 263, which is the source of the error? 

If it is the part where is is $(this).dialog('destroy').remove(), you could try replacing the keyword this with the id and use $('#events_dialog').dialog('destroy').remove() instead

c_carrillo1
Community Participant

Here is a screenshot of the Tampermonkey script showing line 263 and context:

Link: https://www.screencast.com/t/9dhujsSPa8Ah

I tried changing line 267 to "$('#events_dialog').dialog('destroy').remove()".  It did not seem to make any difference in terms of behavior.

Thank you for your help.

 
 
xcotto1
Community Participant

Hi @all

I notice the same behavior with the tool. Looking thru the usercript, I've added this line of code after 422 row.

$.noConflict(true);

Then I reloaded the page and it worked!, I guess there is a conflict with Canvas Jquery libraries and this userscript.  @chadscott 

 

One side note, even with this fix when I click the remove student button it doesn't  remove any of them....

Best,

Xavier

c_carrillo1
Community Participant

@xcotto1 thanks, but could you be a little more specific about where you added that line?  I tried adding it after line 422 (right in the middle of a for-loop), but it didn't change anything for me.

Here's where I added it:  https://www.screencast.com/t/puUhKtxnz

It sounds like maybe your fix didn't work anyway, though, as you noted the students were not removed when you actually tried to use the tool...

xcotto1
Community Participant

Hi @c_carrillo1 

Sure, Make sure is added above this line

 

})();

here is where I've added the code.

 

remove_tool-no-conflict.PNG

 

Looks like you have more code lines than I do. Are you using the latest version? Source code: https://github.com/sukotsuchido/CanvasUserScripts/blob/master/Canvas%20Remove%20Student%20Tool.user....

Let me know if it works for you.

-Xavier

c_carrillo1
Community Participant

@xcotto1 Oh I see!  You meant add as line 442 not line 422 🙂

I added your line and it's working for me now!!!  It is even removing students correctly!

Thank you so much for this fix!

 

 

 

 

chadscott
Community Contributor

@xcotto1 Good job 🙂 I'll keep this in my pocket. I'll update here when I can get some time to do a rework - I've learned quite a bit since starting writing scripts and  need to go back and redo the majority of the ones I've made to make them more efficient and add some features.

Thanks,
Chad Scott
Katy ISD

xcotto1
Community Participant

Thanks to you @chadscott for creating these wonderful scripts!, trust me it is a huge time saver 😎

-Xavier

agdeyoe
Community Explorer

Any way I can replace the variable for student name and replace with student email? We have graduation years in our email structure and want to use that to delete all of the graduating seniors and be able to add all the freshman students to a given class, as an example. 

 

Also, if you have problems running it, try in a different window if you have two screens, mine worked poorly until I moved the window in Chrome over to my non-main display. Not sure why, but if it works for someone else, there's that.

qnguyen
Community Contributor

HI everyone,

Does anyone know why in a sudden the script can't take more than 100 students at a time any more. I would had to remove some before I can do the batch remove again. Beside that, sometime I had to refresh the page in order to run the script.

Thanks

chadscott
Community Contributor

@qnguyen and others, I wanted to bump the post - I've updated the script on github to solve a few lingering issues that I've finally had some time to figure out.

The script will now load all students at once. I've also added async chunking to the delete requests to avoid rate limit errors.

Since some of this requires some waiting, I've added a nice loading icon so the user knows the script is working.

Cheers,

Chad Scott

chadscott
Community Contributor

I've added the noConflict(true) back to the bottom of the script and bumped the version to 2.11 on github.

Cheers,
Chad Scott

c_carrillo1
Community Participant

This fixed everything for me.  It's working!

stijn_van_achte
Community Explorer

wauw, just wauw, 🙂 a life saver 🙂

u0480404
Community Novice

Is it possible to bulk remove students from one specific section only?

ProfessorBeyrer
Community Coach
Community Coach

Yes, @u0480404 . The dialog is sortable by section, so that makes it easier to select students from one section only.

Ron_Bowman
Community Champion

@chadscott -

Thanks for another great script.  Although I can't use it(I am an instructor, and doubt that my teacher role will give me permissions), I still look at the scripts.

ONe thing I don't like are all the warning signs that show up in the scripts(just me, I know the work).  But since you wrote about always learning about improving your scripts, I found the following on stack overflow relating to most of the warnings involving the $ use.  So I thought I would pass it along.

At the header part of the script, add one line as shown below to remove the warnings on the $

// ==/UserScript==
/* eslint-env jquery */   <==== add this line

here is the stack overflow post:

https://stackoverflow.com/questions/39510736/eslint-dollar-is-not-defined-no-undef

Ron

Also, I forgot to mention that (as you may already know) include is being deprecated and that match should be used instead.  I did check my ability to use the script and I could bulk delete students if I wanted, but for my role, I have no need to do that.

Ron_Bowman
Community Champion

@chadscott 

Thanks again for a great script.  I just looked into it again today, and I wanted to change the color of the button, and it was not working from what I had seen in other scripts.  I finally found out why.

on line 40, you have

el.classList.add('Button','button-primary','element_toggler');

which gives me a gray button (which may have been your intention), but If I change button-primary to Button--primary I get the blue color box selection.  I wanted the button to be green, so I used Button--success.

So to get the primary blue color, button has to be capitalized and the double hyphen is needed.

Ron

govreacladmin
Community Participant

Just used it and it worked great!!!!!

ilovell
Community Contributor

The script worked perfectly for what I needed to do! Thanks!

nicole_reilly
Community Member

Hello!!

I just did this but It would not let me edit line 7. Also, I selected some students to be removed and it ended up removing ALL the people from the course, including teachers!! Not sure what I need to do, appreciate any feedback, thanks!