| Title: | Quiz For Canvas Learning Management System |
|---|---|
| Description: | Create, manipulate and get classic quizzes directly via Canvas learning management system's API. |
| Authors: | Emi Tanaka [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-1455-259X>) |
| Maintainer: | Emi Tanaka <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.0.9000 |
| Built: | 2026-07-05 08:34:16 UTC |
| Source: | https://github.com/emitanaka/canvasquiz |
Add questions from a question bank to a quiz
add_question_from_bank( quiz_id, bank_id, title = NULL, n = 1L, points = 1L, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )add_question_from_bank( quiz_id, bank_id, title = NULL, n = 1L, points = 1L, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
quiz_id |
The id of the quiz to add questions to. |
bank_id |
The id of the question bank to pull questions from. |
title |
(Optional) The title of the quiz group to create for these questions. If |
n |
The number of questions to randomly select from the question bank. Defaults to |
points |
The number of points each question added from the bank should be worth. Defaults to |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
The API response from adding the questions.
Answer for an essay question
answer_essay()answer_essay()
Other answer-functions:
answer_matching(),
answer_mcq(),
answer_multiple(),
answer_none(),
answer_num(),
answer_single(),
answer_text(),
answer_true_false(),
answer_upload_file()
Answer for a fill-in-multiple-blanks question
answer_fill_in_multiple_blanks(answers, blank_ids)answer_fill_in_multiple_blanks(answers, blank_ids)
Answer for a matching question
answer_matching(left, right, extra_choices = "")answer_matching(left, right, extra_choices = "")
left |
Character vector of the left-hand side items to be matched. |
right |
Character vector of the right-hand side items to be matched. Must be the same length as |
extra_choices |
Character vector of extra choices that can be used as incorrect matches. Optional. |
Other answer-functions:
answer_essay(),
answer_mcq(),
answer_multiple(),
answer_none(),
answer_num(),
answer_single(),
answer_text(),
answer_true_false(),
answer_upload_file()
Answer for a multiple choice question
answer_mcq(correct, choices, multiple = length(correct) > 1)answer_mcq(correct, choices, multiple = length(correct) > 1)
correct |
Character vector of correct answer(s). Should be one element for single-answer multiple choice questions and can be multiple elements for multiple-answer multiple choice questions. |
choices |
Character vector of answer choices. |
multiple |
Logical. Whether the question allows multiple correct answers. Defaults to |
Other answer-functions:
answer_essay(),
answer_matching(),
answer_multiple(),
answer_none(),
answer_num(),
answer_single(),
answer_text(),
answer_true_false(),
answer_upload_file()
This function allows you to create a question with multiple parts, such as multiple dropdowns or fill-in-the-blank questions with multiple blanks. Each part is created with a separate answer object (e.g. created by dropdown() or fill_in_the_blank()) and then combined into a single question with this function.
answer_multiple(...)answer_multiple(...)
... |
Multiple dropdown answer objects created by |
The question text should include square-bracketed text corresponding to the id of each answer part to indicate where in the question text each part should be displayed. For example, if you have two dropdown answer parts with ids "blank1" and "blank2", your question text might look like "The capital of France is [blank1] and the capital of Spain is [blank2]."
All answer parts must be of the same type (e.g. all dropdowns or all fill-in-the-blank). The function will throw an error if you try to combine different types of answer parts or if the question text includes blank ids that do not correspond to any answer part ids.
For fill-in-the-blank questions, the answer may be marked incorrect even if it is technically correct. This seems to be the result of encoding. If you manually edit and resave the questions, this seems to fix the issue.
Other answer-functions:
answer_essay(),
answer_matching(),
answer_mcq(),
answer_none(),
answer_num(),
answer_single(),
answer_text(),
answer_true_false(),
answer_upload_file()
A text-only question with no answers
answer_none()answer_none()
Other answer-functions:
answer_essay(),
answer_matching(),
answer_mcq(),
answer_multiple(),
answer_num(),
answer_single(),
answer_text(),
answer_true_false(),
answer_upload_file()
A numerical answer question with an exact answer
answer_num(value, tol = 0) answer_num_precision(value, precision = 0L) answer_num_range(lower, upper = lower)answer_num(value, tol = 0) answer_num_precision(value, precision = 0L) answer_num_range(lower, upper = lower)
value |
The correct numerical answer. |
tol |
The acceptable error margin for the answer. Defaults to 0 for an exact answer. |
precision |
The number of decimal places the answer must be correct to. |
lower |
The lower bound of the acceptable answer range. |
upper |
The upper bound of the acceptable answer range. |
Other answer-functions:
answer_essay(),
answer_matching(),
answer_mcq(),
answer_multiple(),
answer_none(),
answer_single(),
answer_text(),
answer_true_false(),
answer_upload_file()
This function is a wrapper that creates the appropriate answer object based on the input. It can handle multiple choice questions, true/false questions, short answer questions, numerical questions (with exact answers, precision-based answers, or range-based answers), and matching questions. The function will automatically determine the type of question based on the format of the input and create the corresponding answer object using the appropriate helper functions.
answer_single(x, y = NULL, tol = 0, precision = 0)answer_single(x, y = NULL, tol = 0, precision = 0)
x |
The correct answer(s) for the question. See details for the expected format based on the type of question. |
y |
Additional parameter for certain question types. See details for the expected format based on the type of question. |
tol |
The acceptable error margin for the answer. Defaults to 0 for an exact answer. |
precision |
The number of decimal places the answer must be correct to. |
The function uses the following logic to determine the type of question:
If x is a logical value and y is NULL, it creates a true/false question using answer_true_false().
If x is a single numeric value and y is NULL, it creates a numerical question with an exact answer using answer_num(). If tol is greater than 0, it creates a numerical question with an error margin. If precision is greater than 0, it creates a numerical question with a specified precision.
If x is a numeric vector of length 2, it creates a numerical question with a range-based answer using answer_num_range(). Alternatively, if x is a single numeric value and y is a single numeric value, it also creates a numerical question with a range-based answer using answer_num_range(), where x is the lower bound and y is the upper bound.
If x is a named character vector, it creates a matching question using answer_matching(). Any extra choices for the matching question can be provided in y.
If x and y are character vectors, it creates a multiple choice question using answer_mcq().
If the input format does not match any of the above cases, the function throws an error indicating that the answer format is unsupported.
Other answer-functions:
answer_essay(),
answer_matching(),
answer_mcq(),
answer_multiple(),
answer_none(),
answer_num(),
answer_text(),
answer_true_false(),
answer_upload_file()
A short answer question
answer_text(correct)answer_text(correct)
correct |
The correct answer text. |
Other answer-functions:
answer_essay(),
answer_matching(),
answer_mcq(),
answer_multiple(),
answer_none(),
answer_num(),
answer_single(),
answer_true_false(),
answer_upload_file()
True or False Question
answer_true_false(correct = TRUE)answer_true_false(correct = TRUE)
correct |
Logical. Whether the correct answer is |
Other answer-functions:
answer_essay(),
answer_matching(),
answer_mcq(),
answer_multiple(),
answer_none(),
answer_num(),
answer_single(),
answer_text(),
answer_upload_file()
A file upload question
answer_upload_file()answer_upload_file()
Other answer-functions:
answer_essay(),
answer_matching(),
answer_mcq(),
answer_multiple(),
answer_none(),
answer_num(),
answer_single(),
answer_text(),
answer_true_false()
A quiz attempt options
attempt_options( n = 1, time = NULL, due = NULL, lock = NULL, unlock = NULL, results = opt_show(at = due), answer = opt_show(at = due), score = c("highest", "latest"), access_code = NULL, ip_filter = NULL )attempt_options( n = 1, time = NULL, due = NULL, lock = NULL, unlock = NULL, results = opt_show(at = due), answer = opt_show(at = due), score = c("highest", "latest"), access_code = NULL, ip_filter = NULL )
n |
The number of allowed attempts. Set to |
time |
Time limit for each attempt in minutes. Set to |
due |
POSIXct. Due date and time for the quiz. |
lock |
POSIXct. Lock date and time for the quiz. |
unlock |
POSIXct. Unlock date and time for the quiz. |
results |
A list of options controlling when quiz results are visible to students. See |
answer |
A list of options controlling when correct answers are visible to students. See |
score |
Scoring policy for multiple attempts. Allowed values: " |
access_code |
Password required to access the quiz. Set to |
ip_filter |
Restrict access to computers in a specified IP range. Filters can be a comma-separated list of addresses, or address/mask. Examples: |
A list of options to be passed to create_quiz().
Options for showing quiz results or answers
opt_show(last_attempt = FALSE, one_time = FALSE, at = NULL) opt_hide(at = NULL) opt_shuffle()opt_show(last_attempt = FALSE, one_time = FALSE, at = NULL) opt_hide(at = NULL) opt_shuffle()
last_attempt |
logical. Whether to show results/answers only after the last attempt is submitted. Only valid if the number of attempts is greater than 1. Defaults to |
one_time |
logical. Whether to show results/answers only immediately after submission. |
at |
POSIXct. Date and time to control when results/answers become visible or hidden. If |
A list of options to be passed to the results or answer parameters of attempt_options().
These functions set and retrieve the Canvas course ID, URL, and token from environment variables. This allows for easy configuration of API calls to the Canvas API without hardcoding sensitive information in the code.
set_canvas_course_id(course_id = Sys.getenv("CANVASQUIZ_COURSE_ID")) get_canvas_course_id() set_canvas_url(url = Sys.getenv("CANVASQUIZ_URL")) get_canvas_url() set_canvas_token(token = Sys.getenv("CANVASQUIZ_TOKEN")) get_canvas_token()set_canvas_course_id(course_id = Sys.getenv("CANVASQUIZ_COURSE_ID")) get_canvas_course_id() set_canvas_url(url = Sys.getenv("CANVASQUIZ_URL")) get_canvas_url() set_canvas_token(token = Sys.getenv("CANVASQUIZ_TOKEN")) get_canvas_token()
course_id |
The Canvas course ID to use for API calls. |
url |
The base URL for the Canvas instance (e.g., "https:// canvas.instructure.com"). |
token |
The API token for authenticating with the Canvas API. |
Count the number of quiz submissions
count_submissions( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )count_submissions( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
quiz_id |
The ID of the quiz to count submissions for. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
This function creates a quiz question directly into Canvas. You can create a variety of question types, including multiple choice, short answer, numerical answer, matching, essay, file upload, and text-only questions.
create_question( text = NULL, answers = NULL, points = 1, quiz_id = last_quiz_id(), quiz_group_id = NULL, position = NULL, title = NULL, correct_comments = NULL, incorrect_comments = NULL, neutral_comments = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )create_question( text = NULL, answers = NULL, points = 1, quiz_id = last_quiz_id(), quiz_group_id = NULL, position = NULL, title = NULL, correct_comments = NULL, incorrect_comments = NULL, neutral_comments = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
text |
Character. The text of the question. |
answers |
A list of answer objects. |
points |
The maximum amount of points received for answering this question correctly. |
quiz_id |
The id of the quiz to add the question to. |
quiz_group_id |
The id of the quiz group to add the question to. |
position |
An integer specifying the order in which the question will be displayed in the quiz. Doesn't seem to work. |
title |
The name of the question. |
correct_comments |
Comment to display if the student answers the question correctly. |
incorrect_comments |
Comment to display if the student answers incorrectly. |
neutral_comments |
Comment to display regardless of how the student answered. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
The question comments is correctly entered, however, Canvas doesn't seem to display them initially. Manually editing the quiz and saving it again seems to fix the issue and then the comments are displayed as expected.
A list representing the quiz question.
Create a quiz with a number of customizable parameters.
create_quiz( title, description = NULL, quiz_type = c("practice_quiz", "assignment", "graded_survey", "survey"), one_question_at_a_time = c("no", "yes", "yes_but_cant_go_back"), attempts = attempt_options(), publish = FALSE, visible = c("everyone", "none"), assignment_group_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )create_quiz( title, description = NULL, quiz_type = c("practice_quiz", "assignment", "graded_survey", "survey"), one_question_at_a_time = c("no", "yes", "yes_but_cant_go_back"), attempts = attempt_options(), publish = FALSE, visible = c("everyone", "none"), assignment_group_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
title |
The quiz title (required). |
description |
A description of the quiz. |
quiz_type |
The type of quiz. Allowed values: " |
one_question_at_a_time |
Whether to show one question at a time. Allowed values: " |
attempts |
A list of options controlling quiz attempts, as created by the |
publish |
Whether to publish the quiz immediately. Defaults to |
visible |
Who this quiz is visible to. Allowed values: " |
assignment_group_id |
integer. The assignment group ID to put the assignment in. Defaults to the top assignment group in the course. Only valid if |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
The quiz id.
Use with caution! This function will delete all quizzes in the course after asking for confirmation. It will not delete quiz question banks.
delete_all_quizzes( course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )delete_all_quizzes( course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
Delete a quiz
delete_quiz( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )delete_quiz( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
quiz_id |
The id of the quiz to retrieve questions from. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
Delete a quiz question
delete_quiz_question( quiz_id, question_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )delete_quiz_question( quiz_id, question_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
quiz_id |
The id of the quiz to retrieve questions from. |
question_id |
The id of the question to delete. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
Create a dropdown answer for a fill-in-multiple-blanks question
dropdown(correct, choices, id = NULL)dropdown(correct, choices, id = NULL)
correct |
Character vector of correct answer(s). Should be one element for single-answer multiple choice questions and can be multiple elements for multiple-answer multiple choice questions. |
choices |
Character vector of answer choices. |
blank_id |
The ID of the blank this dropdown corresponds to. |
Create a fill-in-the-blank answer for a fill-in-multiple-blanks question
fill_in_the_blank(correct, id = NULL)fill_in_the_blank(correct, id = NULL)
correct |
The correct answer text for this blank. |
id |
The ID of the blank this answer corresponds to. |
Get the ID of the most recently created quiz in a course
last_quiz_id() last_question_id()last_quiz_id() last_question_id()
The ID of the most recently created quiz in the specified course.
List attempted questions for a quiz
list_attempted_questions( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )list_attempted_questions( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
Other submissions:
list_submissions(),
submission_info(),
submission_overview(),
submission_questions()
List files in a folder or course
list_files( folder_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )list_files( folder_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
folder_id |
The ID of the folder to list files from. If NULL, lists files in the course. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
List the folder in a course
list_folder( course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN"), tz = Sys.timezone() )list_folder( course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN"), tz = Sys.timezone() )
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
List pages in a course
list_pages( course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )list_pages( course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
List quiz questions in a course
list_questions( quiz_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") ) list_question_groups( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )list_questions( quiz_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") ) list_question_groups( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
quiz_id |
The id of the quiz to retrieve questions from. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
A data frame of quiz questions with their details.
Currently only a maximum of 100 quizzes will be returned.
list_quizzes( course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )list_quizzes( course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
A data frame of quizzes with their details.
List quiz submissions
list_submissions( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN"), n = count_submissions(quiz_id, course_id, url, token), tz = Sys.timezone() )list_submissions( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN"), n = count_submissions(quiz_id, course_id, url, token), tz = Sys.timezone() )
quiz_id |
The ID of the quiz to retrieve statistics for. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
n |
The maximum number of quiz submissions to retrieve. |
tz |
The timezone to use for the started_at and finished_at columns. Defaults to the system timezone. |
Other submissions:
list_attempted_questions(),
submission_info(),
submission_overview(),
submission_questions()
Convert Markdown to HTML
md(text)md(text)
text |
A character string containing Markdown text. |
Get quiz questions
quiz_questions( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )quiz_questions( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
quiz_id |
The id of the quiz to retrieve questions from. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
A list of quiz questions.
Quiz results with user information
quiz_results( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN"), n = count_submissions(quiz_id, course_id, url, token), tz = Sys.timezone() )quiz_results( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN"), n = count_submissions(quiz_id, course_id, url, token), tz = Sys.timezone() )
quiz_id |
The ID of the quiz to retrieve statistics for. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
n |
The maximum number of quiz submissions to retrieve. |
tz |
The timezone to use for the started_at and finished_at columns. Defaults to the system timezone. |
Quiz results summary
quiz_results_summary( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN"), n = count_submissions(quiz_id, course_id, url, token), tz = Sys.timezone() )quiz_results_summary( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN"), n = count_submissions(quiz_id, course_id, url, token), tz = Sys.timezone() )
quiz_id |
The ID of the quiz to retrieve statistics for. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
n |
The maximum number of quiz submissions to retrieve. |
tz |
The timezone to use for the started_at and finished_at columns. Defaults to the system timezone. |
Get quiz statistics
quiz_statistics( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )quiz_statistics( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
quiz_id |
The ID of the quiz to retrieve statistics for. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
Get quiz submissions with question-level answers
quiz_submissions( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN"), n = count_submissions(quiz_id, course_id, url, token) )quiz_submissions( quiz_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN"), n = count_submissions(quiz_id, course_id, url, token) )
quiz_id |
The ID of the quiz to retrieve statistics for. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
n |
The maximum number of quiz submissions to retrieve. |
If you leave the answer as NULL, it will not filter the submissions.
regrade_question( question_id, quiz_id, answer = NULL, fudge_points = NULL, score = NULL, comment = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )regrade_question( question_id, quiz_id, answer = NULL, fudge_points = NULL, score = NULL, comment = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
question_id |
The ID of the question to regrade. |
answer |
The answer to regrade. Can be numeric or character or one of the answer functions. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
Get quiz submission details
submission_info( submission_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )submission_info( submission_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
submission_id |
The ID of the quiz submission to retrieve details for. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
A data frame with submission id, quiz id, question name, question type, question text, whether the question was flagged, whether the question was correct, assessment question id, quiz group id, and the answers provided.
Other submissions:
list_attempted_questions(),
list_submissions(),
submission_overview(),
submission_questions()
Get quiz submission overview
submission_overview( submission_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )submission_overview( submission_id, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
submission_id |
The ID of the quiz submission to retrieve details for. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
A data frame with the name of the user, quiz title, score, attempt number, quiz id, and submission id.
Other submissions:
list_attempted_questions(),
list_submissions(),
submission_info(),
submission_questions()
List attempted questions for a quiz
submission_questions( submission_id, url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )submission_questions( submission_id, url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
submission_id |
The ID of the quiz submission to retrieve details for. |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
Other submissions:
list_attempted_questions(),
list_submissions(),
submission_info(),
submission_overview()
Update a quiz submission
submission_update( submission_id, fudge_points = NULL, question_id = NULL, score = NULL, comment = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )submission_update( submission_id, fudge_points = NULL, question_id = NULL, score = NULL, comment = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
submission_id |
The ID of the quiz submission to retrieve details for. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
Generate an HTML link to download a file in a Canvas course This function creates an HTML link that allows users to download a file stored in a Canvas course. The link will point to the download URL for the specified file.
tag_file(file_id, text = "Download") upload_tag_file( file_path, text = "Download", folder_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )tag_file(file_id, text = "Download") upload_tag_file( file_path, text = "Download", folder_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
file_id |
The file ID of the file in Canvas. |
text |
The text to display for the download link (default is "Download"). |
A character string containing the HTML link to download the specified file.
This function creates an HTML <img> tag that can be used to display an image file stored in a Canvas course. The image will be displayed at 50% width.
tag_img( file_id, width = "100%", class = "", course_id = Sys.getenv("CANVASQUIZ_COURSE_ID") ) upload_tag_img( file_path, width = "100%", class = "", folder_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )tag_img( file_id, width = "100%", class = "", course_id = Sys.getenv("CANVASQUIZ_COURSE_ID") ) upload_tag_img( file_path, width = "100%", class = "", folder_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
file_id |
The file ID of the image in Canvas. |
width |
The width of the image (default is "100%"). |
class |
Optional CSS class to apply to the |
course_id |
The ID of the Canvas course where the file is stored (default is taken from the environment variable |
A character string containing the HTML <img> tag for the specified image file.
Update a quiz question
update_question( question_id, quiz_id, text = NULL, answers = NULL, points = NULL, position = NULL, title = NULL, correct_comments = NULL, incorrect_comments = NULL, neutral_comments = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )update_question( question_id, quiz_id, text = NULL, answers = NULL, points = NULL, position = NULL, title = NULL, correct_comments = NULL, incorrect_comments = NULL, neutral_comments = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
quiz_id |
The id of the quiz to add the question to. |
text |
Character. The text of the question. |
answers |
A list of answer objects. |
points |
The maximum amount of points received for answering this question correctly. |
position |
An integer specifying the order in which the question will be displayed in the quiz. Doesn't seem to work. |
title |
The name of the question. |
correct_comments |
Comment to display if the student answers the question correctly. |
incorrect_comments |
Comment to display if the student answers incorrectly. |
neutral_comments |
Comment to display regardless of how the student answered. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |
Upload a file to a folder
upload_file( file, folder_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )upload_file( file, folder_id = NULL, course_id = Sys.getenv("CANVASQUIZ_COURSE_ID"), url = Sys.getenv("CANVASQUIZ_URL"), token = Sys.getenv("CANVASQUIZ_TOKEN") )
file |
The path to the file to upload. |
folder_id |
The ID of the folder to upload the file to. |
course_id |
The course id. Defaults to the value of the |
url |
The canvas url. Defaults to the value of the |
token |
The canvas token. Defaults to the value of the |