Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions R/get_account_rubric.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#' Get Single Account Rubric from Canvas LMS API
#'
#' Fetches a single rubric by ID from a specific account in the Canvas LMS API.
#'
#' @param canvas A list containing the 'api_key' and 'base_url' for authentication.
#' @param account_id The ID of the account containing the rubric.
#' @param rubric_id The ID of the rubric to retrieve.
#'
#' @return A rubric object retrieved from the Canvas LMS API.
#' @export
#'
get_account_rubric <- function(canvas, account_id, rubric_id) {
# Construct the API endpoint URL
url <- paste0(canvas$base_url, "/api/v1/accounts/", account_id, "/rubrics/", rubric_id)

# Make the API request
response <- httr::GET(url, httr::add_headers(Authorization = paste("Bearer", canvas$api_key)))

# Check the response status code
if (httr::status_code(response) != 200) {
stop("Failed to retrieve account rubric. Please check your authentication and API endpoint.")
}

# Parse the response as JSON
rubric <- httr::content(response, "text", encoding = "UTF-8") %>%
jsonlite::fromJSON(flatten = TRUE)

# Return the rubric
return(rubric)
}
30 changes: 30 additions & 0 deletions R/get_account_rubrics.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#' Get Account Rubrics from Canvas LMS API
#'
#' Fetches a list of rubrics within a specific account from the Canvas LMS API.
#'
#' @param canvas A list containing the 'api_key' and 'base_url' for authentication.
#' @param account_id The ID of the account for which to retrieve the rubrics.
#' @param per_page Number of rubrics to retrieve per page. Default is 100.
#'
#' @return A list of rubrics retrieved from the Canvas LMS API.
#' @export
#'
get_account_rubrics <- function(canvas, account_id, per_page = 100) {
# Construct the API endpoint URL
url <- paste0(canvas$base_url, "/api/v1/accounts/", account_id, "/rubrics?per_page=", per_page)

# Make the API request
response <- httr::GET(url, httr::add_headers(Authorization = paste("Bearer", canvas$api_key)))

# Check the response status code
if (httr::status_code(response) != 200) {
stop("Failed to retrieve account rubrics. Please check your authentication and API endpoint.")
}

# Parse the response as JSON
rubrics <- httr::content(response, "text", encoding = "UTF-8") %>%
jsonlite::fromJSON(flatten = TRUE)

# Return the list of rubrics
return(rubrics)
}
30 changes: 30 additions & 0 deletions R/get_rubric.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#' Get Single Rubric from Canvas LMS API
#'
#' Fetches a single rubric by ID from a specific course in the Canvas LMS API.
#'
#' @param canvas A list containing the 'api_key' and 'base_url' for authentication.
#' @param course_id The ID of the course containing the rubric.
#' @param rubric_id The ID of the rubric to retrieve.
#'
#' @return A rubric object retrieved from the Canvas LMS API.
#' @export
#'
get_rubric <- function(canvas, course_id, rubric_id) {
# Construct the API endpoint URL
url <- paste0(canvas$base_url, "/api/v1/courses/", course_id, "/rubrics/", rubric_id)

# Make the API request
response <- httr::GET(url, httr::add_headers(Authorization = paste("Bearer", canvas$api_key)))

# Check the response status code
if (httr::status_code(response) != 200) {
stop("Failed to retrieve rubric. Please check your authentication and API endpoint.")
}

# Parse the response as JSON
rubric <- httr::content(response, "text", encoding = "UTF-8") %>%
jsonlite::fromJSON(flatten = TRUE)

# Return the rubric
return(rubric)
}
30 changes: 30 additions & 0 deletions R/get_rubrics.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#' Get Rubrics from Canvas LMS API
#'
#' Fetches a list of rubrics within a specific course from the Canvas LMS API.
#'
#' @param canvas A list containing the 'api_key' and 'base_url' for authentication.
#' @param course_id The ID of the course for which to retrieve the rubrics.
#' @param per_page Number of rubrics to retrieve per page. Default is 100.
#'
#' @return A list of rubrics retrieved from the Canvas LMS API.
#' @export
#'
get_rubrics <- function(canvas, course_id, per_page = 100) {
# Construct the API endpoint URL
url <- paste0(canvas$base_url, "/api/v1/courses/", course_id, "/rubrics?per_page=", per_page)

# Make the API request
response <- httr::GET(url, httr::add_headers(Authorization = paste("Bearer", canvas$api_key)))

# Check the response status code
if (httr::status_code(response) != 200) {
stop("Failed to retrieve rubrics. Please check your authentication and API endpoint.")
}

# Parse the response as JSON
rubrics <- httr::content(response, "text", encoding = "UTF-8") %>%
jsonlite::fromJSON(flatten = TRUE)

# Return the list of rubrics
return(rubrics)
}
14 changes: 7 additions & 7 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2326,16 +2326,16 @@
- [ ] Delete a single rubric RubricsController#destroy ;
DELETE /api/v1/courses/:course_id/rubrics/:id

- [ ] List rubrics RubricsApiController#index ;
- [x] List rubrics RubricsApiController#index ;
GET /api/v1/accounts/:account_id/rubrics
- [ ] List rubrics RubricsApiController#index ;

- [x] List rubrics RubricsApiController#index ;
GET /api/v1/courses/:course_id/rubrics
- [ ] Get a single rubric RubricsApiController#show ;

- [x] Get a single rubric RubricsApiController#show ;
GET /api/v1/accounts/:account_id/rubrics/:id
- [ ] Get a single rubric RubricsApiController#show ;

- [x] Get a single rubric RubricsApiController#show ;
GET /api/v1/courses/:course_id/rubrics/:id

- [ ] Create a single rubric assessment RubricAssessmentsController#create ;
Expand Down