R/link_canvas.R

Defines functions link_canvas

Documented in link_canvas

#' Link to a Canvas course
#'
#' Establish a connection with the Canvas Instructure LMS API. Doing so allows
#' for automatic updates to the Canvas course. This only needs to be performed once.
#'
#' @param token_path Path to where the Canvas API token number is stored. This
#' should be stored in a file of type '.txt'. The Canvas token can be obtained in
#' Settings > Approved Integrations > New Access Token.
#' @param course_id Canvas course number as an integer.
#' @param API_URL URL for Canvas API
#'
#' @export
link_canvas <- function(token_path, course_id, API_URL) {
  token <- as.character(utils::read.table(file = token_path))
  if (!dir.exists("meta/")) dir.create("meta/")
  utils::write.table(token_path, file = "meta/token_path.txt", row.names = FALSE,
                     col.names = FALSE)
  utils::write.table(course_id, file = "meta/course_id.txt", row.names = FALSE,
                     col.names = FALSE)
  utils::write.table(API_URL, file = "meta/API_URL.txt", row.names = FALSE,
                     col.names = FALSE)
}
nikola-sur/teachr documentation built on April 21, 2022, 4:50 a.m.