Title: | API Wrapper for Google Classroom and Google Forms |
---|---|
Description: | This is a Google Forms and Google Classroom API Wrapper for R for managing Google Classrooms from R. The documentation for these APIs is here <https://developers.google.com/forms/api/guides> . |
Authors: | Candace Savonen [cre, aut] |
Maintainer: | Candace Savonen <[email protected]> |
License: | GPL-3 |
Version: | 0.9.1 |
Built: | 2025-02-10 04:44:59 UTC |
Source: | https://github.com/datatrail-jhu/rgoogleclassroom |
Archive a Google Classroom Course
archive_course(course_id)
archive_course(course_id)
course_id |
ID of the archived course you wish to delete |
This is a function to authorize the R package to access the Googleclassroom API. If no client.id and client.secret is provided, the package would provide predefined values.
auth_from_secret(access_token, refresh_token)
auth_from_secret(access_token, refresh_token)
access_token |
Access token can be obtained from running authorize interactively: token <-authorize(); token$credentials$access_token |
refresh_token |
Refresh token can be obtained from running authorize interactively: token <-authorize(); token$credentials$refresh_token |
OAuth token saved to the environment so the package can use the users' Google data
## Not run: token <- authorize() auth_from_secret( token$credentials$access_token, token$credentials$refresh_token ) ## End(Not run)
## Not run: token <- authorize() auth_from_secret( token$credentials$access_token, token$credentials$refresh_token ) ## End(Not run)
This is a function to authorize the R package to access the Googleclassroom API interactively.
authorize(token = NULL, cache = FALSE, ...)
authorize(token = NULL, cache = FALSE, ...)
token |
an output from |
cache |
Should the token be cached as an .httr-oauth file? |
... |
additional arguments to send to |
OAuth token saved to the environment so the package can use the users' Google data
## Not run: authorize() ## End(Not run)
## Not run: authorize() ## End(Not run)
Commit changes to a Google form
commit_to_form(form_id, google_forms_request, quiet = FALSE)
commit_to_form(form_id, google_forms_request, quiet = FALSE)
form_id |
The id of the google form to be updated |
google_forms_request |
The google slide request to be applied to the slides |
quiet |
TRUE/FALSE you'd like a progress message? |
Make a copy of an existing form
copy_form(form_id, new_name = NULL, quiet = FALSE)
copy_form(form_id, new_name = NULL, quiet = FALSE)
form_id |
The form_id that is desired to be copied. |
new_name |
What should the new file name for the copied file be? |
quiet |
TRUE or FALSE whether messages should be printed out. |
## Not run: #' # Make the form form_info <- copy_form(form_id = "https://docs.google.com/forms/d/someformidhere/edit", new_name = "copied form") ## End(Not run)
## Not run: #' # Make the form form_info <- copy_form(form_id = "https://docs.google.com/forms/d/someformidhere/edit", new_name = "copied form") ## End(Not run)
Create a new course
create_course( owner_id = get_owner_id()$id, name = "New course", load_url = TRUE )
create_course( owner_id = get_owner_id()$id, name = "New course", load_url = TRUE )
owner_id |
The ownerId to use to create the course. Will attempt to retrieve ownerId based on credentials with get_owner_id() |
name |
Name of the new course. Required. |
load_url |
Load URL into an HTML Browser |
List of metadata of newly created course.
## Not run: owner_id <- get_owner_id() course_df <- create_course(name = "Computer Science 101") ## End(Not run)
## Not run: owner_id <- get_owner_id() course_df <- create_course(name = "Computer Science 101") ## End(Not run)
Create a new coursework
create_coursework( course_id = NULL, topic_id = NULL, publish = FALSE, title = NULL, work_type = "ASSIGNMENT", due_date = NULL, description = NULL, link = NULL )
create_coursework( course_id = NULL, topic_id = NULL, publish = FALSE, title = NULL, work_type = "ASSIGNMENT", due_date = NULL, description = NULL, link = NULL )
course_id |
Course id of where to make the new coursework. Can find from end of URL e.g. "https://classroom.google.com/c/COURSE_ID_IS_HERE" |
topic_id |
topic ID to be looked for. |
publish |
TRUE/FALSE, automatically publish the coursework upon posting? Default is to be posted as a draft (students will not see it until you click Post). |
title |
Name of new coursework. Required. |
work_type |
Currently only supported work type is ASSIGNMENT. |
due_date |
Required Due date for new coursework, must be given in year-month-day format. |
description |
Description of new coursework. Is a string |
link |
A url to an associated resource for the coursework being made. |
## Not run: topic_id <- get_topic_list("604042323237")$topic$topicId[1] course_id <- get_course_list()$courses$id[1] create_coursework(course_id, topic_id, title = "a new quiz", due_date = "2025-12-1", description = "blah blah", link = "https://www.datatrail.org/" ) ## End(Not run)
## Not run: topic_id <- get_topic_list("604042323237")$topic$topicId[1] course_id <- get_course_list()$courses$id[1] create_coursework(course_id, topic_id, title = "a new quiz", due_date = "2025-12-1", description = "blah blah", link = "https://www.datatrail.org/" ) ## End(Not run)
Create a new form
create_form(title = NULL, document_title = "new_form", description = "")
create_form(title = NULL, document_title = "new_form", description = "")
title |
The title for the new form. Required as a string. |
document_title |
The title for the form file that will be stored in Google Drive |
description |
The description for the new form as a string. |
## Not run: #' # Make the form form_info <- create_form( title = "A great quiz", description = "This quiz is tricky" ) ## End(Not run)
## Not run: #' # Make the form form_info <- create_form( title = "A great quiz", description = "This quiz is tricky" ) ## End(Not run)
Create a new material
create_material( course_id = NULL, topic_id = NULL, publish = FALSE, title = NULL, description = NULL, link = NULL, load_url = TRUE )
create_material( course_id = NULL, topic_id = NULL, publish = FALSE, title = NULL, description = NULL, link = NULL, load_url = TRUE )
course_id |
Course id of where to make the new materials. Can find from end of URL e.g. "https://classroom.google.com/c/COURSE_ID_IS_HERE" |
topic_id |
topic ID to be looked for. |
publish |
TRUE/FALSE, automatically publish the coursework upon posting? Default is to be posted as a draft (students will not see it until you click Post). |
title |
Name of new material |
description |
A description for the new material |
link |
A URL to go with the associated material |
load_url |
Load URL into an HTML Browser |
List of metadata of newly created material.
## Not run: course_id <- get_course_list()$courses$id[3] topic_id <- get_topic_list(course_id)$topic$topicId[1] create_material(course_id, topic_id, title = "new material") ## End(Not run)
## Not run: course_id <- get_course_list()$courses$id[3] topic_id <- get_topic_list(course_id)$topic$topicId[1] create_material(course_id, topic_id, title = "new material") ## End(Not run)
Create a multiple choice question
create_multiple_choice_question( form_id = NULL, commit_to_form = TRUE, required = FALSE, question = NULL, choice_vector = NULL, shuffle_opt = FALSE, correct_answer = NULL, google_forms_request = NULL, point_value = 1, quiet = FALSE, location = 0 )
create_multiple_choice_question( form_id = NULL, commit_to_form = TRUE, required = FALSE, question = NULL, choice_vector = NULL, shuffle_opt = FALSE, correct_answer = NULL, google_forms_request = NULL, point_value = 1, quiet = FALSE, location = 0 )
form_id |
The id of the google form to be updated |
commit_to_form |
Whether or not the request should be committed. If need to build the request further, you will want to say FALSE. Default is TRUE |
required |
TRUE or FALSE is this a required question? Default is not required. |
question |
a string that is what the question should say |
choice_vector |
a character vector of the choices that should be given for this question |
shuffle_opt |
TRUE or FALSE options should be shuffled? default is FALSE |
correct_answer |
The index that corresponds to the correct answer in the 'choice_vector' supplied |
google_forms_request |
A google forms request object. If not supplied, it will be created new. |
point_value |
An integer representing how many points |
quiet |
TRUE/FALSE you'd like a progress message? |
location |
Where should the new question be added |
## Not run: create_multiple_choice_question( form_id = "12345", question = "What answer do you want?", choice_vector = c("A", "B", "C", "D"), correct_answer = 3, shuffle_opt = TRUE ) ## End(Not run)
## Not run: create_multiple_choice_question( form_id = "12345", question = "What answer do you want?", choice_vector = c("A", "B", "C", "D"), correct_answer = 3, shuffle_opt = TRUE ) ## End(Not run)
Create a quiz at a course
create_quiz( course_id = NULL, quiz_title = NULL, quiz_description = NULL, topic_id = NULL, coursework_title = "none", work_type = "ASSIGNMENT", due_date = NULL, assignment_description = "" )
create_quiz( course_id = NULL, quiz_title = NULL, quiz_description = NULL, topic_id = NULL, coursework_title = "none", work_type = "ASSIGNMENT", due_date = NULL, assignment_description = "" )
course_id |
A course id where the quiz should be created |
quiz_title |
A string indicating the title for the quiz |
quiz_description |
A description for the quiz that will be made |
topic_id |
Optional - a topic Id where the quiz will be posted |
coursework_title |
a string that will be what the coursework title |
work_type |
Currently only supported work type is ASSIGNMENT. |
due_date |
A due date for this quiz, in year-month-day format |
assignment_description |
The description that will be given for the assignment |
## Not run: course_id <- get_course_list()$courses$id[1] topic_id <- get_topic_list(course_id)$topic$topicId[1] create_quiz(course_id, quiz_title = "new quiz", quiz_description = "This is a great quiz", topic_id = topic_id, due_date = "2025-12-1" ) ## End(Not run)
## Not run: course_id <- get_course_list()$courses$id[1] topic_id <- get_topic_list(course_id)$topic$topicId[1] create_quiz(course_id, quiz_title = "new quiz", quiz_description = "This is a great quiz", topic_id = topic_id, due_date = "2025-12-1" ) ## End(Not run)
This function makes a google request object that will be able to be posted with a batch request and and added to a Google form to edit it.
create_text_question( form_id = NULL, commit_to_form = TRUE, required = FALSE, question = NULL, correct_answer = NULL, google_forms_request = NULL, point_value = 1, location = 0, quiet = FALSE )
create_text_question( form_id = NULL, commit_to_form = TRUE, required = FALSE, question = NULL, correct_answer = NULL, google_forms_request = NULL, point_value = 1, location = 0, quiet = FALSE )
form_id |
The id of the google form to be updated |
commit_to_form |
Whether or not the request should be committed. If need to build the request further, you will want to say FALSE. Default is TRUE |
required |
TRUE or FALSE is this a required question? Default is not required. |
question |
a string that is what the question should say |
correct_answer |
A string that matches exactly what would be considered a correct |
google_forms_request |
A google forms request object. If not supplied, it will be created new. |
point_value |
An integer representing how many points |
location |
Where should the new question be added |
quiet |
TRUE/FALSE you'd like a progress message? |
## Not run: create_text_question( form_id = "12345", question = "Put text here that is for filling in the blank", point_value = 1 ) ## End(Not run)
## Not run: create_text_question( form_id = "12345", question = "Put text here that is for filling in the blank", point_value = 1 ) ## End(Not run)
Create a new topic
create_topic(course_id = NULL, name = NULL)
create_topic(course_id = NULL, name = NULL)
course_id |
Course id of where to make the new topic. Can find from end of URL e.g. "https://classroom.google.com/c/COURSE_ID_IS_HERE" |
name |
Name of new topic. Required. |
Handle and parse a due_date
date_handler(due_date)
date_handler(due_date)
due_date |
A string that is a date in format of year-month-day |
## Not run: date_handler("2025-12-1") ## End(Not run)
## Not run: date_handler("2025-12-1") ## End(Not run)
Delete a Google Classroom Course
delete_course(course_id)
delete_course(course_id)
course_id |
ID of the archived course you wish to delete |
Delete a Google Classroom Coursework
delete_coursework(course_id, coursework_id)
delete_coursework(course_id, coursework_id)
course_id |
Course id of where to make the new coursework. Can find from end of URL e.g. "https://classroom.google.com/c/COURSE_ID_IS_HERE" |
coursework_id |
ID of the archived course you wish to delete |
Get list of courses
get_course_list(owner_id = get_owner_id()$id)
get_course_list(owner_id = get_owner_id()$id)
owner_id |
owner_id to retrieve course listings from |
Data frame of course metadata.
## Not run: owner_id <- get_owner_id() course_df <- get_course_list(owner_id) ## End(Not run)
## Not run: owner_id <- get_owner_id() course_df <- get_course_list(owner_id) ## End(Not run)
Get Google Classroom Course Properties
get_course_properties(course_id)
get_course_properties(course_id)
course_id |
ID of the course you wish to retrieve information from |
Get list of courseworks for a course
get_coursework_list(course_id)
get_coursework_list(course_id)
course_id |
ID of the course to retrieve the courseworks from |
## Not run: course_id <- get_course_list()$courses$id[1] get_coursework_list(course_id) ## End(Not run)
## Not run: course_id <- get_course_list()$courses$id[1] get_coursework_list(course_id) ## End(Not run)
Get Google Classroom Course Properties
get_coursework_properties(course_id, coursework_id)
get_coursework_properties(course_id, coursework_id)
course_id |
ID of the course you wish to retrieve information about a particular coursework |
coursework_id |
ID of the coursework you wish to retrieve information about |
Get list of files from a Google Shared Drive
get_drive_file_list(drive_id)
get_drive_file_list(drive_id)
drive_id |
ID of the drive to retrieve a list of files from |
Generate endpoint for the Google classroom API
get_endpoint( type_of_endpoint = "classroom.endpoint.user", course_id = NULL, topic_id = NULL, coursework_id = NULL, materials_id = NULL, form_id = NULL )
get_endpoint( type_of_endpoint = "classroom.endpoint.user", course_id = NULL, topic_id = NULL, coursework_id = NULL, materials_id = NULL, form_id = NULL )
type_of_endpoint |
Type of endpoint to convert to url |
course_id |
(Optional) ID of the google course to be affected/retrieved |
topic_id |
(Optional) ID of the topic to be affected/retrieved |
coursework_id |
(Optional) ID of the coursework to be affected/retrieved |
materials_id |
(Optional) ID of the material to be affected/retrieved |
form_id |
(Optional) ID of the form to be affected/retrieved |
A url that is the endpoint for the API call
Get Google Form Properties
get_form_properties(form_id = NULL, form_url = NULL)
get_form_properties(form_id = NULL, form_url = NULL)
form_id |
Google form Id |
form_url |
Google form url |
## Not run: # Make the form form_info <- create_form(title = "A great quiz", description = "This quiz is tricky") # Get info about the form form_info <- get_form_properties(form_id = form_info$formId) ## End(Not run)
## Not run: # Make the form form_info <- create_form(title = "A great quiz", description = "This quiz is tricky") # Get info about the form form_info <- get_form_properties(form_id = form_info$formId) ## End(Not run)
Get form responses
get_form_responses(form_id = NULL, form_url = NULL)
get_form_responses(form_id = NULL, form_url = NULL)
form_id |
The id of the google form to be updated |
form_url |
Google form url |
## Not run: form_url <- "https://docs.google.com/forms/d/1woWtLVviIhrwb-NYEjVMO_IV2-62vOhaS4N0/edit#responses" get_form_responses(form_url = form_url) ## End(Not run)
## Not run: form_url <- "https://docs.google.com/forms/d/1woWtLVviIhrwb-NYEjVMO_IV2-62vOhaS4N0/edit#responses" get_form_responses(form_url = form_url) ## End(Not run)
Get list of forms used in a course as quizzes
get_linked_quizzes_list(course_id)
get_linked_quizzes_list(course_id)
course_id |
ID of the course to retrieve the linked quizzes from |
## Not run: course_id <- get_course_list()$courses$id[1] quiz_list <- get_linked_quizzes_list(course_id) ## End(Not run)
## Not run: course_id <- get_course_list()$courses$id[1] quiz_list <- get_linked_quizzes_list(course_id) ## End(Not run)
Get list of materials for a course
get_materials_list(course_id)
get_materials_list(course_id)
course_id |
ID of the course |
Data frame of materials
## Not run: course_id <- get_course_list()$courses$id[1] materials_df <- get_materials_list(course_id) ## End(Not run)
## Not run: course_id <- get_course_list()$courses$id[1] materials_df <- get_materials_list(course_id) ## End(Not run)
Get Google Classroom Materials properties
get_materials_properties(course_id, materials_id)
get_materials_properties(course_id, materials_id)
course_id |
ID of the course |
materials_id |
The material id you wish to retrieve |
Data frame of material properties
## Not run: course_id <- get_course_list()$courses$id[3] materials_id <- get_materials_list(course_id)$material_id$courseWorkMaterial$id[1] get_materials_properties(course_id, materials_id) ## End(Not run)
## Not run: course_id <- get_course_list()$courses$id[3] materials_id <- get_materials_list(course_id)$material_id$courseWorkMaterial$id[1] get_materials_properties(course_id, materials_id) ## End(Not run)
Get ownerId based on credentials
get_owner_id()
get_owner_id()
Get list of topics for a course
get_topic_list(course_id)
get_topic_list(course_id)
course_id |
ID of the course you wish to retrieve a topic list from |
## Not run: course_id <- get_course_list()$courses$id[1] get_topic_list(course_id) ## End(Not run)
## Not run: course_id <- get_course_list()$courses$id[1] get_topic_list(course_id) ## End(Not run)
Get Google Classroom Topic Properties
get_topic_properties(course_id, topic_id)
get_topic_properties(course_id, topic_id)
course_id |
ID of the course |
topic_id |
topic ID to be looked for. |
Check if the object is a google forms request object
is.google_forms_request(x)
is.google_forms_request(x)
x |
A google_forms_request object created from the rgoogleclassroom package |
Turn a form into a quiz
make_form_quiz(form_id)
make_form_quiz(form_id)
form_id |
The id of the google form to be updated into a Quiz |
## Not run: # Make the form form_info <- create_form(title = quiz_title) # Now make it a quiz make_form_quiz(form_id = form_info$formId) ## End(Not run)
## Not run: # Make the form form_info <- create_form(title = quiz_title) # Now make it a quiz make_form_quiz(form_id = form_info$formId) ## End(Not run)
Get file path to an example quiz
markdown_quiz_path()
markdown_quiz_path()
A file path to a markua markdown quiz example you can use for testing
## Not run: # Find quiz path quiz_path <- markdown_quiz_path() ## End(Not run)
## Not run: # Find quiz path quiz_path <- markdown_quiz_path() ## End(Not run)
Takes a file path to a Markua formatted quiz and runs the steps to convert it to a Google Form Request and sends It to be a Google form quiz.
ottr_quiz_to_google( quiz_path = NULL, course_id = NULL, quiz_title = NULL, topic_id = NULL, coursework_title = NULL, form_id = NULL, due_date = NULL, make_new_quiz = FALSE, copy_from_template_quiz = TRUE, new_name = NULL, assignment_description = "", quiz_description = "", output_path = NULL, quiet = FALSE )
ottr_quiz_to_google( quiz_path = NULL, course_id = NULL, quiz_title = NULL, topic_id = NULL, coursework_title = NULL, form_id = NULL, due_date = NULL, make_new_quiz = FALSE, copy_from_template_quiz = TRUE, new_name = NULL, assignment_description = "", quiz_description = "", output_path = NULL, quiet = FALSE )
quiz_path |
file path to a markdown Markua quiz |
course_id |
An id for the course where this is to be published and linked. |
quiz_title |
The title for the quiz. If not supplied, it will attempt to be grabbed from the Markua doc |
topic_id |
topic ID that the quiz should be added under. |
coursework_title |
the title for the coursework to be created |
form_id |
form id where this quiz is to be published. Alternatively, if you want a new quiz to be made, you should set make_new_quiz = TRUE and leave this NULL. |
due_date |
A due date for this quiz, in year-month-day format |
make_new_quiz |
This can only be used if form_id is not specified. This will make a new quiz |
copy_from_template_quiz |
TRUE or FALSE the form supplied should be copied over and used as a template. |
new_name |
To be passed to 'copy_form' if 'copy_from_template_quiz' is TRUE. What the new file name should be called |
assignment_description |
The description that will be given for the assignment |
quiz_description |
The description that will be given for the quiz |
output_path |
Optional file path to save the question formatted data to |
quiet |
TRUE/FALSE you'd like a progress message? |
## Not run: # Using quiz example quiz_path <- markdown_quiz_path() ottr_quiz_to_google( markdown_quiz_path(), course_id = "606463350924", make_new_quiz = TRUE, due_date = "2025-12-1" ) ## End(Not run)
## Not run: # Using quiz example quiz_path <- markdown_quiz_path() ottr_quiz_to_google( markdown_quiz_path(), course_id = "606463350924", make_new_quiz = TRUE, due_date = "2025-12-1" ) ## End(Not run)
Publish a Google Classroom CourseWork
publish_coursework(course_id, coursework_id)
publish_coursework(course_id, coursework_id)
course_id |
ID of the archived course you wish to delete |
coursework_id |
coursework ID of the coursework you wish to publish |
Handle and parse a time
time_handler(due_time = lubridate::hms("23:59:59"))
time_handler(due_time = lubridate::hms("23:59:59"))
due_time |
A string that is a date in format of year-month-day. Default is midnight. |
## Not run: time_handler("21:30:59") ## End(Not run)
## Not run: time_handler("21:30:59") ## End(Not run)
Takes a Markua formatted quiz and translates it to something that can be sent to Google Forms API.
translate_questions_api(quiz_path, output_path = NULL)
translate_questions_api(quiz_path, output_path = NULL)
quiz_path |
The file path to a Markua formatted quiz to be translated to Google Forms API format |
output_path |
Optional file path to save the formatted data to a JSON file |
A list of the output from [ottrpal::check_question] with messages/warnings regarding each question and each check.
## Not run: # Using quiz example quiz_path <- markdown_quiz_path() parsed_questions <- translate_questions_api(quiz_path) ## End(Not run)
## Not run: # Using quiz example quiz_path <- markdown_quiz_path() parsed_questions <- translate_questions_api(quiz_path) ## End(Not run)
Create a multiple choice question
update_form_settings( form_id = NULL, title = NULL, description = NULL, google_forms_request = NULL, quiet = FALSE )
update_form_settings( form_id = NULL, title = NULL, description = NULL, google_forms_request = NULL, quiet = FALSE )
form_id |
The id of the google form to be updated |
title |
An updated title |
description |
An updated description |
google_forms_request |
A google forms request object. If not supplied, it will be created new. |
quiet |
TRUE/FALSE you'd like a progress message? |
## Not run: update_form_settings( form_id = "12345", new_title = NULL, new_description = NULL ) ## End(Not run)
## Not run: update_form_settings( form_id = "12345", new_title = NULL, new_description = NULL ) ## End(Not run)