.course. quiz

Source:
Functions for interacting with quizzes within courses

Methods

(async) create(opts, configopt) → {Promise.<CanvasQuiz>}

Source:
Author:
  • Gabe Abrams
Creates a new quiz in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
title string Title of the new quiz
courseId number <optional>
default course id Canvas course Id to create the quiz in
description string <optional>
null HTML description of the quiz
type string <optional>
null Quiz type. Allowed values: [ 'practice_quiz', 'assignment', 'graded_survey', 'survey']
dueAt date <optional>
null Date the quiz is due
lockAt date <optional>
null Date the quiz is lock
unlockAt date <optional>
null Date the quiz is unlock
published boolean <optional>
If true, quiz is published
allowedAttempts number <optional>
1 Number of times a student is allowed to take the quiz. Set to1 for unlimited attempts
scoringPolicy string <optional>
keep_highest Only valid if allowedAttempts > 1. Allowed values: ['keep_highest', 'keep_latest']
oneQuestionAtATime boolean <optional>
If true, shows quiz to student one question at a time
cantGoBack boolean <optional>
If true, shows quiz to student one question at a time
accessCode string <optional>
If defined, restricts access to the quiz only to those with this access code
ipFilter string <optional>
If defined, restricts access to the quiz to computers in a specified IP range. Filters can be a comma-separated list of addresses, or an address followed by a mask
assignmentGroupId number <optional>
top assignment group The assignment group to put the quiz into. Only valid if type is "assignment" or "graded_survey"
timeLimitMins number <optional>
null Time limit for the quiz in minutes
shuffleAnswers boolean <optional>
If true, quiz answers for multiple choice questions will be randomized for each student
hideResults string <optional>
not hidden Allowed values: ['always', 'until_after_last_attempt'], determines whether the student can see their own submission and other results
hideCorrectAnswers boolean <optional>
Only valid if hideResults is not defined. If true, hides correct answers from students when results are viewed
showCorrectAnswersAfterLastAttempt boolean <optional>
Only valid if hideCorrectAnswers is not true and allowedAttemptes > 1. If true, hides correct answers from students when quiz results are viewed until they submit the last attempt for the quiz
showCorrectAnswersAt date <optional>
null Only valid if hideCorrectAnswers is not true. If set, correct answers will only be visible after this date
hideCorrectAnswersAt date <optional>
null Only valid if hideCorrectAnswers is not true. If set, correct answers will stop being visible after this date has passed
oneTimeResults boolean <optional>
Whether students should be prevented from viewing their quiz results past the first time (right after they turn in the quiz)
onlyVisibleToOverrides boolean <optional>
If true, the quiz is only visible to students with overrides
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasQuiz>

(async) createEssayQuestion(opts, configopt) → {Promise.<CanvasQuizQuestion>}

Source:
Author:
  • Gabe Abrams
Creates a new essay question and adds it to a quiz in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
quizId number Canvas quiz Id (not the quiz's assignment Id)
name string Name of the question
text string The text of the question, as displayed to the quiz taker
pointsPossible number Maximum number of points
courseId number <optional>
default course id Canvas course Id to query
position number <optional>
last Optional. Position of the question with respect to the other questions in the quiz
correctComment string <optional>
Comment to display if the student answers correctly
incorrectComment string <optional>
Comment to display if the student answers incorrectly
neutralComment string <optional>
Comment to display regardless of how the student answers
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasQuizQuestion>

(async) createMultipleChoiceQuestion(opts, configopt) → {Promise.<CanvasQuizQuestion>}

Source:
Author:
  • Gabe Abrams
Creates a new multiple choice question and adds it to a quiz in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
quizId number Canvas quiz Id (not the quiz's assignment Id)
name string Name of the question
text string The text of the question, as displayed to the quiz taker
pointsPossible number Maximum number of points
answers Array Array of answers: [{ text, isCorrect, comment }]
courseId number <optional>
default course id Canvas course Id to query
position number <optional>
last Optional. Position of the question with respect to the other questions in the quiz
correctComment string <optional>
Comment to display if the student answers correctly
incorrectComment string <optional>
Comment to display if the student answers incorrectly
neutralComment string <optional>
Comment to display regardless of how the student answers
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasQuizQuestion>

(async) createShortAnswerQuestion(opts, configopt) → {Promise.<CanvasQuizQuestion>}

Source:
Author:
  • Gabe Abrams
Creates a new short answer question and adds it to a quiz in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
quizId number Canvas quiz Id (not the quiz's assignment Id)
name string Name of the question
text string The text of the question, as displayed to the quiz taker
pointsPossible number Maximum number of points
courseId number <optional>
default course id Canvas course Id to query
position number <optional>
last Optional. Position of the question with respect to the other questions in the quiz
correctComment string <optional>
Comment to display if the student answers correctly
incorrectComment string <optional>
Comment to display if the student answers incorrectly
neutralComment string <optional>
Comment to display regardless of how the student answers
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasQuizQuestion>

(async) createSubmission(opts, configopt) → {Promise.<CanvasQuizSubmission>}

Source:
Author:
  • Gabe Abrams
Creates a new submission to a specific quiz in a course on behalf of the current user
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
quizId number Canvas quiz Id (not the quiz's assignment Id)
answers Array.<object> List of answers to quiz questions: [{id: , answer: },...] where the answer object is explained here: https://canvas.instructure.com/doc/api/quiz_submission_questions.html#Question+Answer+Formats-appendix
courseId number <optional>
default course id Canvas course Id
accessCode string <optional>
Access code for the quiz if it is locked
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasQuizSubmission>

(async) delete(opts, configopt) → {Promise.<CanvasQuiz>}

Source:
Author:
  • Gabe Abrams
Deletes a quiz from a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
quizId number Canvas quiz Id (not the quiz's assignment Id)
courseId number <optional>
default course id Canvas course Id to query
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasQuiz>

(async) get(opts, configopt) → {Promise.<CanvasQuiz>}

Source:
Author:
  • Gabe Abrams
Get info on a specific quiz in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
quizId number Canvas quiz Id (not the quiz's assignment Id)
courseId number <optional>
default course id Canvas course Id to query
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasQuiz>

(async) getSubmission(opts, configopt) → {Promise.<CanvasQuizSubmission>}

Source:
Author:
  • Gabe Abrams
Gets info on a specific submission to a quiz in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
quizId number Canvas quiz Id (not the quiz's assignment Id)
submissionId number Canvas quiz submission Id
courseId number <optional>
default course id Canvas course Id to query
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasQuizSubmission>

(async) list(optsopt, configopt) → {Promise.<Array.<CanvasQuiz>>}

Source:
Author:
  • Gabe Abrams
Lists the quizzes in a course
Parameters:
Name Type Attributes Description
opts object <optional>
object containing all arguments
Properties
Name Type Attributes Default Description
courseId number <optional>
default course id Canvas course Id to query
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<Array.<CanvasQuiz>>

(async) listQuestions(opts, configopt) → {Promise.<Array.<CanvasQuizQuestion>>}

Source:
Author:
  • Gabe Abrams
Lists the questions in a specific quiz in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
quizId number Canvas quiz Id (not the quiz's assignment Id)
courseId number <optional>
default course id Canvas course Id to query
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<Array.<CanvasQuizQuestion>>

(async) listSubmissions(opts, configopt) → {Promise.<Array.<CanvasQuizSubmission>>}

Source:
Author:
  • Gabe Abrams
Lists the submissions to a quiz in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
quizId number Canvas quiz Id (not the quiz's assignment Id)
courseId number <optional>
default course id Canvas course Id to query
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<Array.<CanvasQuizSubmission>>

(async) update(opts, configopt) → {Promise.<CanvasQuiz>}

Source:
Author:
  • Gabe Abrams
Updates a specific quiz in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
quizId number Canvas course Id to create the quiz in
courseId number <optional>
default course id Canvas course Id to create the quiz in
suppressNotification boolean <optional>
If true, does not notify users that the quiz has been updated
title string <optional>
current value New title of the quiz
description string <optional>
current value New HTML description of the quiz
type string <optional>
current value Quiz type. Allowed values: [ 'practice_quiz', 'assignment', 'graded_survey', 'survey']
dueAt date <optional>
current value Date the quiz is due
lockAt date <optional>
current value Date the quiz is lock
unlockAt date <optional>
current value Date the quiz is unlock
published boolean <optional>
current value If true, quiz is published
allowedAttempts number <optional>
current value Number of times a student is allowed to take the quiz. Set to1 for unlimited attempts
scoringPolicy string <optional>
current value Only valid if allowedAttempts > 1. Allowed values: ['keep_highest', 'keep_latest']
oneQuestionAtATime boolean <optional>
current value If true, shows quiz to student one question at a time. Must be a boolean
cantGoBack boolean <optional>
current value If true, shows quiz to student one question at a time. Must be a boolean
accessCode string <optional>
current value If defined, restricts access to the quiz only to those with this access code
ipFilter string <optional>
current value If defined, restricts access to the quiz to computers in a specified IP range. Filters can be a comma-separated list of addresses, or an address followed by a mask
assignmentGroupId number <optional>
current value The assignment group to put the quiz into. Only valid if type is "assignment" or "graded_survey"
timeLimitMins number <optional>
current value Time limit for the quiz in minutes
shuffleAnswers boolean <optional>
current value If true, quiz answers for multiple choice questions will be randomized for each student
hideResults string <optional>
current value Allowed values: ['always', 'until_after_last_attempt'], determines whether the student can see their own submission and other results
hideCorrectAnswers boolean <optional>
current value Only valid if hideResults is not defined. If true, hides correct answers from students when results are viewed
showCorrectAnswersAfterLastAttempt boolean <optional>
current value Only valid if hideCorrectAnswers is not true and allowedAttemptes > 1. If true, hides correct answers from students when quiz results are viewed until they submit the last attempt for the quiz. Must be a boolean
showCorrectAnswersAt date <optional>
current value Only valid if hideCorrectAnswers is not true. If set, correct answers will only be visible after this date
hideCorrectAnswersAt date <optional>
current value Only valid if hideCorrectAnswers is not true. If set, correct answers will stop being visible after this date has passed
oneTimeResults boolean <optional>
current value Whether students should be prevented from viewing their quiz results past the first time (right after they turn in the quiz)
onlyVisibleToOverrides boolean <optional>
current value If true, the quiz is only visible to students with overrides
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasQuiz>

(async) updateQuestionGrades(opts, configopt) → {Promise.<CanvasQuizSubmission>}

Source:
Author:
  • Gabe Abrams
Updates the question grades for a specific submission to a quiz in a course
Parameters:
Name Type Attributes Description
opts object object containing all arguments
Properties
Name Type Attributes Default Description
quizId number Canvas quiz Id (not the quiz's assignment Id)
submissionId number Canvas submission Id for a quiz
courseId number <optional>
default course id Canvas course Id to query
fudgePoints number <optional>
current value The amount of positive/negative fudge points to apply to this submission
questions object <optional>
A map questionId => { score, comment } of the question score/comment updates
attempt number <optional>
most recent The attempt to update grades for. If excluded, we pull the user's submission to get the attempt number
config APIConfig <optional>
custom configuration for this specific endpoint call (overwrites defaults that were included when api was initialized)
Returns:
Type
Promise.<CanvasQuizSubmission>