6.1 Course Resources
Script Managers
To manage and run userscripts we recommend using either the Firefox or Chrome browsers and using these browser extensions
Example
As an example, we briefly illustrate a relatively simple userscript that determines the type and count of all the files in a Canvas site. While this functionality may have limited practical use, we use it to show process of installing a script manager (Tampermonkey) in a browser (Chrome), installing a script (Canvas-Files-Get_Files.user.js), and running it in a Canvas course. The script is programmed only to run on the "Files" page of a Canvas site and generates a button on the page to activate the data collection. Once the button is pressed, the script uses the Canvas Files API (application programming interface) to ask for a list of all the files uploaded to the current Canvas site. The site counts them by file type and pops up a panel displaying the results.
The userscript, Canvas-Files-Get_Files.user.js, can be downloaded from this link.
Canvas-Files-Get_Files.user.js Links to an external site.
Here are links to two screencasts that show the steps needed to install Tampermonkey in Chrome, install the Canvas-Files-Get_Files.user.js userscript, and run it on the Canvas Files page. In the second module, we have instructions for installing Greasemonkey with Firefox.Part 1: Installing Tampermonkey and Running a Userscript Links to an external site.
Part 2: Using the Chrome Developer Console to View Userscript Output Links to an external site.
- R project website:Download and Install R Links to an external site.
- Instructions:How to download and install R
Links to an external site.
- R packages that are used in this course:
- install.packages("circlize") #Tools for building a chord diagram
- install.packages("igraph") #Tools for building a network diagram
- install.packages("plyr") # Tools for Splitting, Applying and Combining Data
- install.packages("ggplot2") #Powerful graphics tools for creating elegant and complex plots
- install.packages("tm") # Tools for text mining
These videos provide an introduction to using pivot tables in a spreadsheet. Excel is used in the videos, but Google Sheets also provides pivot table functionality.
Use of Ruby is recommended for individuals who are comfortable with using a plain text editor on their computer and running programs from the command line.
Installing Ruby
Macs come with Ruby. Windows users will need to install Ruby. Both Mac and Windows users will need to install the Canvas API gem, a library that allows easy access to the Canvas API.
- Instructions: How to install Ruby on windows
Links to an external site.
- Ruby Official Website: How to install Ruby on different OS Links to an external site.
- Canvas API rubygem Links to an external site.
gem install canvas-api
To require the library in your project:
require 'canvas-api'
Editing Ruby Scripts
- Open a text editor such as TextEdit on a Mac or NotePad on Windows.
- Copy and paste the complete script in the text editor.
- Replace the host with the Canvas url of your institution.
- Fill in your API access token. Please refer to how do I obtain an API access token Links to an external site. to generate an API access token for your account.
- Save the file as 'filename.rb'.
Running Ruby Scripts
- To run the ruby script, open the Terminal app on your Mac or a command prompt on your Windows windows computer.
- Locate the directory for 'filename.rb' by changing directories (folders) using the cd command.
- On the command line, type 'ruby filename.rb' and presss Return or Enter.