Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add include to submissions.R #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all 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
19 changes: 17 additions & 2 deletions R/submissions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#' @param course_id A valid canvas course id
#' @param type Either "quizzes" or "assignments"
#' @param type_id A valid quiz or assignment id
#' @param include A character vector. Options are submission_history, submission_comments, rubric_assessment, assignment, visibility, course, user, group, or read_status.
#' @name submissions
NULL

Expand All @@ -16,11 +17,18 @@ NULL
#' @examples
#' \dontrun{get_submissions(27, "quizzes", 2915)}
#' \dontrun{get_submissions(27, "assignments", 254)}
get_submissions <- function(course_id, type, type_id) {
get_submissions <- function(course_id, type, type_id, include=NULL) {
if (!type %in% c("quizzes", "assignments"))
stop("type must be 'quizzes' or 'assignments'")
url <- make_canvas_url('courses', course_id, type, type_id,
'submissions')
if(!is.null(include)){
iopt<-c("submission_history", "submission_comments", "rubric_assessment", "assignment", "visibility", "course", "user", "group", "read_status")
if(!all(include%in%iopt)) stop(sprintf("include must be any of: %s",paste0(iopt,collapse=", ")))
inc<-paste0("include[]=",include)
inc<-paste0(inc,collapse="&")
url<-paste(url,inc,sep="?")
}
args <- list(access_token = check_token(),
per_page = 100)
process_response(url, args) %>%
Expand All @@ -36,11 +44,18 @@ get_submissions <- function(course_id, type, type_id) {
#' @md
#' @examples
#' \dontrun{get_submission_single(1350207, "assignments", 5681164, 4928217)}
get_submission_single <- function(course_id, type, type_id, user_id) {
get_submission_single <- function(course_id, type, type_id, user_id, include=NULL) {
if (!type %in% c("quizzes", "assignments"))
stop("type must be 'quizzes' or 'assignments'")
url <- make_canvas_url('courses', course_id, type, type_id,
'submissions', user_id)
if(!is.null(include)){
iopt<-c("submission_history", "submission_comments", "rubric_assessment", "assignment", "visibility", "course", "user", "group", "read_status")
if(!all(include%in%iopt)) stop(sprintf("include must be any of: %s",paste0(iopt,collapse=", ")))
inc<-paste0("include[]=",include)
inc<-paste0(inc,collapse="&")
url<-paste(url,inc,sep="?")
}
args <- list(access_token = check_token(),
per_page = 100)
resp <- canvas_query(url, args, "GET")
Expand Down