Giter Site home page Giter Site logo

brush's Introduction

README

Overview

bRush is an R client to interface with the Instructure Canvas LMS.

For most functions, bRush returns a data frame. Combining bRush with a magrittr pipes makes it quick and easy to subset pesky unknown ID numbers (e.g., account -> course -> assignment) for the supplied known name.

As a client for R, bRush makes assumptions on behalf of the user that they are interested in as much data from the requests as possible. Requests are recursively processed until all results for a requests have been acheived (if there are 926 courses, bRush will make the call 93 times gathering 10 results each time, and 6 the last). Additonal, any "include" options are set to true by default.

Canvas API Documentation is available here: https://canvas.instructure.com/doc/api/index.html

Installation

bRush is not available on CRAN and can be installed directly from GitHub using the devtools package (which is available on CRAN).

devtools::install_github("erikpal/bRush")

Setup and use of API Token

To use this package, create an access token in Canvas by going to Account > Settings > Approved Integrations > + New Access Token. I recommend not setting an expiration date.

Place the token in a file called .Renviron as such:

CanvasApiKey = 7~ABcD123efG45hIJ78KLMno9PQrstuVwXyZ10

This method follows the best practice for developing API packages as documented here: https://cran.r-project.org/web/packages/httr/vignettes/api-packages.html

Alternatively, you may place the token in a text file called token.txt to be loaded from the working directory at the time needed.

You may store multiple keys for multiple servers, and override the default name of "CanvasApiKey" by passing this arugument when making requests:

env_var_name = "NameOfApiKey"

The token management options are designed to give you flexibility in moving across installations. Note that keys created in production will be copied over to test and beta environments at their next scheduled copy, which makes it easier to work with a single key.

Setup and use of server urls

The loadURL function will load urls provided in .Renviron file as well. By default, the variables CanvasUrlTest, CanvasUrlProd, and CanvasUrlBeta shown below let you use the "test", "beta", or "production" as shortcuts for you development and production enviroments. CanvasUrlTest is the default for all functions. Any variable name can be specified, and you may also pass an actual url instead of using environment variables (e.g, server = "https://otheruniv.test.instructure.com").

Example Usage

Example One: Get my course ID and make an assigment in that course

library(bRush)

mycourses <- getMyCourses()
courseid <- mycourses$id[mycourses$name == "Introduction to R"]
createAssignment(courseid, "Week One Homework")

Example Two: Get a subaccount ID and then get stats for it within a term (term id 1234 supplied)

library(bRush)

accounts <- getAccounts()
accountid <- accounts$id[accounts$name == "Science Department"]
stats <- getAnalytics(accountid, type = "statistics", term = 1234)

Example Three: Use with dplyr for quick access

library(bRush)
library(magrittr)

accountid <- getAccounts() %>% filter(name == "Science Department") %>% .[["id"]]

Status of Project

I make use of this package to automate tasks and generate usage reports. Functions are developed as tasks present themselves. I hope that sharing this, others will find value and perhaps contribute functions for their purposes to the package.

brush's People

Contributors

erikpal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

tormodb snanalyst

brush's Issues

Uploading files

Thanks for this fantastic package!

I am not sure if this is an easy fix or not, but when I try to upload files I am getting the following error:

Error in curl::curl_fetch_memory(url, handle = handle) : HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

Is that due to an API change at canvas you think?

rcanvas

I thought I would also direct your attention to another package rcanvas (currently looking for a new maintainer) that has some similar functionality. Perhaps these two projects could join forces to become a canvas superpower?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.