rcanvas
is a bouquet of functions to query your institution's instance of the Canvas LMS.
rcanvas
is not on CRAN, but can be installed via:
devtools::install_github("daranzolin/rcanvas")
library(rcanvas)
Some prep work is required before use. You must first stash two items in your .Renviron
file: (1) your third-party access token, available through your Canvas LMS account settings; and (2) your institution's particular domain. (e.g. "https://<your_domain>.instructure.com/"
) Name your token CANVAS_API_TOKEN
, and your domain CANVAS_DOMAIN
. For help on setting up your .Renviron
(and all things R) see Jenny Bryan's Stat545 page.
The process for getting your Canvas API token:
Canvas -> Account -> Settings -> Approved Integrations -> Add new token
We provide two helper functions to make this process easier.
set_canvas_token("YOUR_TOKEN_HERE")
set_canvas_domain("https://canvas.yourdomain.edu")
The following functions are implemented:
add_enrollments
: Enroll users into a course (or multiple courses)add_group_users
: Add users to designated groupsadd_groups
: Create groupscomment_submission
: comment on submitted contentcreate_course_folder
: create a folder within a coursecreate_canvas_course
: create a new coursecreate_course_content_migration
: migrate content from one course to anothercreate_course_assignment
: create an assignment within a courseget_announcements
: Get announcements for a courseget_course_analytics_data
: Get course analytics data for a courseget_course_gradebook
: Get the gradebook for a courseget_course_items
: Get various course items, e.g. files, modules, pages, quizzes, etc.get_course_list
: List the courses you have permission to viewget_course_user_groups
: Get users in a course and their groupget_discussion_id
: Get the id for a specified discussionget_discussions_context
: Get the context for a specified discussionget_group_categories
: Get the categories for a specified groupget_group_category
: Get a single group categoryget_group_users
: Get users which belong to a groupget_groups_context
: Get the list of active groups in the given context that are visible to the userget_groups_self
: Get the groups which the current user (you) belongs toget_submission_single
: Get a single submissionget_submissions
: Get submissions for a given course and assignmentget_user_items
: Get various user items, e.g. missing submissions, page_views, details, etc.grade_submission
: Grade a submissionsearch_courses
: Search all public coursesupdate_discussion_id
: Update a discussion by IDupload_course_file
: Upload a file to a course
### Get all courses:
get_course_list()
get_course_list(include = c("teachers", "total_students"))
### Get course analytics data:
get_course_analytics_data(course_id = 20, type = "activity")
### Get course items:
get_course_items(course_id = 20, item = "users", include = "email")
### Get user items
get_user_items(user_id = 365, item = "details")
get_user_items(365, "missing_submissions")
### Get a course gradebook
get_course_gradebook(course_id = 20)
### Get submissions
get_submissions(course_id = 27, type = "assignments", type_id = 2248)
get_submissions(27, "quizzes", 168)
### Comment and grade submnissions
comment_submission(course_id = 27, assignment_id = 2248,
user_id = 4227, comm = "Test comment!")
grade_submission(course_id = 27, assignment_id = 2248,
user_id = 4227, grade = 95)
### Get announcements and discussions
get_announcements(course_id = 27)
get_announcements(course_id = 27, start_date = "2017-02-01")
get_discussions_context(4371405, object_type = "courses")
- Additional functions
- More precise querying
- More tests
- Vignette