User Script to Bulk Publish Courses

Code-with-Ski
Community Coach
Community Coach
9
1777

I have developed a user script that will allow an Account Admin to bulk publish courses from the admin account course search page.  Using the course search before opening the bulk publish dialog will help narrow down the unpublished courses that can be loaded in to review for publishing.  This will also work on the course search of sub-accounts if there is a need to narrow the courses to a specific sub-account.

To use the user script, you will need to use a tool for loading user scripts (such as TamperMonkey Chrome Web Store Listing) or add it as a part of the theme in your Canvas environment (if you are an Account Admin).  If using a tool for loading user scripts, be sure to update the @match web address (as needed) on line 7 in the header comment.  Users using the Canvas hosted domain name shouldn't need to make any adjustments.  The Bulk Publish Courses Raw Source Code will need to be installed for use with your tool for user scripts or added to your JavaScript Canvas theme file.

This user script is part of the Code with Ski User Scripts Repository.  It is recommended to review and test the code before using it.  Be sure to check with your school administration/IT staff before using any user scripts in case they have security and/or review guidelines that must be followed before use.

How to Use

Begin by going to the admin account with the courses you desire to bulk update.  Use the course search to narrow down the courses as appropriate, such as a select term and/or searching for a keyword/phrase in the course name.  Click "Bulk Publish" when you have used the search to narrow down the results as desired.  *If you close the dialog and update the search, you can click bulk publish to open the dialog again and load the courses again based on the revised course search.

admin account course search, click bulk update buttonadmin account course search, click bulk update button

 

Click "Load Unpublished Courses" to add rows to the table for each unpublished course that meets the current course search criteria.

click load unpublished courses buttonclick load unpublished courses button

 

All the loaded in results will be selected to publish by default.  You can use the checkbox at the top of the table to check all and/or uncheck all options, or you can use the checkbox on an individual row to control if that specific course should be included or not.  Any unchecked course rows will not be included in the bulk update.

use the checkboxes in the table to adjust courses included to be updateduse the checkboxes in the table to adjust courses included to be updated

After you have updated the selected courses as desired, click the "Publish" button and confirm that you want to perform the bulk publish. The loading messages will be updated as courses are published one at a time.  Avoid reloading or leaving the page as it will stop the process, and you will need to repeat the process for any courses that weren't updated.  Please note this process will take longer to complete the more courses there are to publish.

click publish and confirm to begin the processclick publish and confirm to begin the process

 

After the process completes, all the successfully published courses will be removed from the table.  Any courses that weren't able to be published will remain in the table along with any that weren't selected to be published.  The loading messages will reflect error messages for any courses that were not able to be updated.

completed update processcompleted update process 

If you refresh the course search page you should see the updated state of the courses.

Change Log

Version 1.1.0

  • Added ability to download loading messages
  • Updated file name to include ".user" so it can be automatically detected by TamperMonkey as a user script

 

9 Comments
James
Community Champion

James ( @Code-with-Ski ), I just discovered a bunch of the stuff you've been writing. I haven't used any of it, but the write-ups look like the solutions are top notch and you're really good at responding to people.

You remind me of me pre-COVID when I had time to work on things, except that you actually know what you're doing.

I added a link to here in a comment from my How to list teachers who have published/unpublished courses post. Hopefully people will find it easier to use than my older solutions.

James

Code-with-Ski
Community Coach
Community Coach
Author

@James 

Thank you! If you have any suggestions for making improvements to the documentation or any of the things I have built when you do try them out, please let me know. 

You have great documentation for all the enhancements you have built, and I believe you know what you are doing too from what I have seen.  I have learned a lot from reviewing the Canvancements and Google App scripts you have built and shared over the years.  They helped me see the possibilities of what can be created through JavaScript customizations and the Canvas API to enhance the user experience.  I also continue to learn from you as I read your comments in the Community and appreciate all you have shared!

wchang
Community Explorer

@Code-with-Ski 

Thank you so much for the GUI! It is definitely more user friendly than the Python script I made for my school.

 @James & @Code-with-Ski

Thank you both for your generosity in sharing the knowledge. 

Code-with-Ski
Community Coach
Community Coach
Author

@wchang You're welcome!  I'm glad to hear you have found it useful 😀

Code-with-Ski
Community Coach
Community Coach
Author

Version 1.1.0

  • Added ability to download loading messages
  • Updated file name to include ".user" so it can be automatically detected by TamperMonkey as a user script

 

Justin_Reynolds
Community Participant

Hi @Code-with-Ski!

Is it ok to modify your JS?  I'm looking to add functionality that will allow me to see the start and/or end dates of the courses.  Ideally, I want to make the columns sortable so I can check only certain courses for specific start dates.  I'm very new with JS.  Can you point me to where your code looks for the published state?  My thought is if I start there, I might be able to figure out a way to pull in the start and end dates as well. 

Thanks,
Justin

Code-with-Ski
Community Coach
Community Coach
Author

@Justin_Reynolds 

Yes, you are welcome to modify the JavaScript code as you see fit to meet your needs!

In version 1.1.0, you can refer to the following line numbers in the code:

  • Line 431 is where I am adding a table cell for the workflow state (published state) of the course to a row in the results. 
    • This is in the addRow function
    • You could add more cells for the start and end date of the course.
      • Keep in mind that the start and end date are only expected for a course when the participation is set to Course rather than Term. 
      • You may want to add a column for "restrict_enrollments_to_course_dates" to check that participation is set to Course (true).
      • If you are using Term for participation too, you will need to determine how you want to handle that for determining when to publish and how to get the start/end date of the term (if needed)
  • Line 300 in the createCoursesTable function is where I had the table header for the workflow state.  You will want to add additional headers for any additional columns you plan to add to each row.

I don't currently have sorting in this version, but it may be something I can add in the future along with your ideas for start and end date.  In the meantime, you could reference this guide for an example of How to Sort a Table.  Alternatively, you could consider sorting the courses as you would desire before they are added as rows.  This would be in loadCourses and you would want to sort courses after line 391 and before the for loop that adds each row at line 394.

Justin_Reynolds
Community Participant

@Code-with-Ski Thanks so much!

zaelises
Community Member

Just wanted to say this is fantastic! I'm the Canvas admin of our institution and I have no formal IT education -- stuff like this are truly helpful, & open new doors to up-skilling!