Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export(delete_course_section)
export(delete_page)
export(download_course_file)
export(edit_section)
export(get_account_rubric)
export(get_account_rubrics)
export(extract_next_url)
export(get_accounts)
export(get_all_courses)
Expand Down Expand Up @@ -52,6 +54,8 @@ export(get_module_items)
export(get_modules)
export(get_page_content)
export(get_roles)
export(get_rubric)
export(get_rubrics)
export(get_section_information)
export(get_section_students)
export(get_student_summaries)
Expand Down
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
14 changes: 8 additions & 6 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1067,15 +1067,17 @@ reference:
# - deactivate_role
# - activate_role
# - update_role
# title: Rubrics
# desc: >
# Manage rubrics.
# contents:
- title: Rubrics
desc: >
Manage rubrics.
contents:
- get_rubrics
- get_rubric
- get_account_rubrics
- get_account_rubric
# - create_rubric
# - update_rubric
# - delete_rubric
# - list_rubrics
# - get_single_rubric
#
# title: RubricAssessments
# desc: >
Expand Down
21 changes: 21 additions & 0 deletions man/get_account_rubric.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions man/get_account_rubrics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions man/get_rubric.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions man/get_rubrics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.