Canvancements - Canvas Enhancements

kona
Community Coach
Community Coach
54
80865

Sometimes it's hard to find resources in the Canvas Community and often awesome things are overlooked due to the sheer volume of information. To make it easier for people, the following is a comprehensive list of Canvancements (Canvas Enhancements) @James has developed for Canvas. James would never sing his own praises, but I have no problem doing so on his behalf. Enjoy! :smileycool:

List of Canvancements

Additional Documentation and Resources

Retired Canvancements

Questions about any of these resources should be added to that specific resources document or blog.

November 21, 2017: Greasemonkey 4 / Firefox 57 note

It appears that there is a bug with Firefox 57 that is keeping Greasemonkey 4 from working. It basically keeps any script from Github from installing, updating, or running and you can't create local scripts either. Github is where all of the source code for the Canvancements are stored. There is a way to temporarily disable a security protocol in Firefox that is provided in the bug report, but my recommendation at this point is to use Chrome or Safari or to install Tampermonkey for Firefox. Firefox will not be fixing this issue in Firefox 57 as it's not a security bug, Greasemonkey 3 no longer works after upgrading to Firefox 57, and it would completely change the way Greasemonkey injects and detects user scripts to fix (meaning I don't expect them to fix it).

Further investigation shows that existing Greasemonkey scripts may try to execute as I'm getting error messages that don't appear when Greasemonkey is disabled. Since they are loaded as content scripts, they get access to a cleaned version of the DOM and cannot see external JavaScript libraries like jQuery or variables like ENV or INST that Canvas provides as a page script. Early paranoia suggests that Greasemonkey may not be a viable solution once you upgrade to Firefox 57+. Although I've been moving towards avoiding jQuery (for no real reason at the time, but now I'm glad I did), I still use it when making AJAX calls to fetch data from Canvas.

October 1, 2019: Safari 13 note

Apple has changed the way extensions work and Safari 13 no longer supports user scripts. The initial release of Safari 13 allowed you to keep Tampermonkey installed if you already had it installed, but after I upgraded to Safari 13.0.1, it gave notice that Tampermonkey was being disabled and it was gone, although it sounds like the files may still be on the drive. See the Tampermonkey as 'Safari App Extension' thread for additional information and updates.

For the time being, if you upgrade your OS and need to use a user script, then I suggest using Chrome or Firefox.

October 20, 2019: Safari 13 update

Tampermonkey has been rewritten to work with Safari 13. Now Mac users can use Safari. The developer did decide to charge $1.99 for reasons explained in the announcement post. To install Tampermonkey for Safari, go to the App Store and search for Tampermonkey (here's a direct link to the Tampermonkey in the Apple Store). After purchasing it, you open Safari, go to Preferences, choose Extensions, and enable it. I had to restart Safari before it worked, but your experience may be different.

54 Comments
James
Community Champion

@JosefinaTejedaF 

I updated the links here on this page, but it may be impossible to update the links within the original posts themselves. The new Community software has a limit on how large a post can be that wasn't there in the software that was used when it was written. It appears that many of my posts exceeded that limit and it won't let me edit them.

Most other people won't have that issue, but few people have time to go back through their old posts and update them.

That leave us with searching for the title, as you suggested. I don't particularly find the search here useful and sometimes people don't know what to search for. One way people can help is to add a reply with a corrected link (if someone hasn't already done so).

patfm
Community Explorer

@James 

I am hoping this gets seen by Canvancement experts!  I am never sure how best to post to specific interest groups. 

Our problem:

We have been trying to provide a way for our Calculus instructors to contact their students' advisors when they fail to meet a cutoff grade for a quiz or test.  The "Message Students Who ..." gradebook feature gets close but not quite there.   You can show all the students who fail the criteria and also show their paired Oberver-Advisor and then just message the Observer-Advisors, however there is no built-in way to include the list of students who are showing and placing them in the body of the message.  Copy and paste does not work in chrome and Firefox has an ability to 'snapshot' but you only get what is showing in the message window, so you have scroll and do multiple 'snapshots' and then attach them to the message if the list of students goes beyond the message window.  In Chrome you have to do a print to PDF to save snapshots of the window and multiple prints to PDF if the list scrolls.  

Is it feasible by using Javascript to capture the full list of students whether visible or not in  the "Message Students who..." feature of the gradebook.  Ideally, we would want to add the list to the message, but a download that could then be attached would be better than the methods mentioned above. 

James
Community Champion

@patfm 

It would be simpler to pull the submission information from the API (either REST or GraphQL) than trying to capture the Message Students Who output. This could even be automated if you liked, so that it's not dependent on the instructors going through and doing something.

Grabbing any information from a modal dialog can be challenging (not impossible) as you have to add a mutation observer to watch for the modal to appear and then for the content to appear in that dialog. This particular dialog does not use human friendly class names, which makes it harder (not impossible) to find the information and potentially subject to higher maintenance as you discover you didn't quite have it right or that Canvas changed something.

Worse, and now we're getting into the area of impossible, Canvas doesn't store the user ID in the DOM, which is what the userScript has access to. If all you need is a list of student names to ship somewhere, then it might be doable. However, if you want to actually send a message that includes their student ID numbers (either Canvas or SIS) rather than just their name, then you need to look up that information. If you have two students with the same name, then there's no way to get that information given what's on the screen and available to the userscript.

Compounding the issue more is that Canvas doesn't store the full student name in the pill if the name is long. It is there as part of an aria label attribute, but it's preceded by the word "Remove" (if your language is English). That word is probably not "remove" in other languages, so now you have to add multi-language support or make a script that works in English let other people modify the code for their language. I suppose that you could look for the start of the pill text in the aria label and get around that. Possible, but not ideal.

The assignment name isn't in the Compose Message dialog either. You would have to search the gradebook for which column had focus.

On the other hand, you could quickly download the same information that Canvas downloads and make that decision using the same logic that it uses. This is available in a couple of different ways, but the Submissions records are what drive the gradebook. If you download the submissions records (the gradebook already does this), then you could search for whatever criterion you want and you would have all of the IDs and grades and names available. But if you add that to a userscript and want to generate the IDs, you would need to redownload the submissions, adding to the delay.

patfm
Community Explorer

Thanks @JamesG for the reply on this topic.  We will look into using submissions API.  Since the criteria for communication with the advisor/observers is determined by the instructors, there would have to be some 'trigger' on the part of the instructor to start the process. Not sure how we would connect the message to advisors to the process that needs to pull the student info.  Any thoughts on this would be appreciated.