daranzolin / rcanvas

R Client for Canvas LMS API
Other
90 stars 43 forks source link

get sections from course #28

Open nelis73 opened 6 years ago

nelis73 commented 6 years ago

Hi,

Users may want to split up outcomes for sections (instead of groups). Perhaps something like the following could be added? (which seem to work.) These are just get functions, but I can imagine that people also may want to use create functions...

get_sections <- function(course_id){ url <- paste0(rcanvas:::canvas_url(), paste("courses", course_id, "sections", sep = "/")) args <- list(per_page = 100) include <- rcanvas:::iter_args_list(NULL, "include[]") args <- c(args, include) rcanvas:::process_response(url, args) }

get_section_users <- function (section_id){ url <- paste0(rcanvas:::canvas_url(), paste( "sections", section_id, "enrollments", sep = "/")) args <- list(per_page = 100) include <- rcanvas:::iter_args_list(NULL, "include[]") args <- c(args, include) rcanvas:::process_response(url, args) }

daranzolin commented 5 years ago

@nelis73 I agree--I think there's admittedly some disharmony in rcanvas with how we/I named functions and controlled how users interact with different end points. Should we have an explicitly named function get_section_students? or a more generic get_course_items where you can pass "enrollments" and filter students, teachers, TAs, etc. If we started over, I think we'd do it a little different.

I think the 'sections' end points are relatively new--they weren't there when I was working with rcanvas earlier. Thanks for letting me know!