Quizzes API

A Quiz object looks like:

{
  // the ID of the quiz
  id: 5,

  // the title of the quiz
  title: "Hamlet Act 3 Quiz",

  // the HTTP/HTTPS URL to the quiz
  html_url: "http://canvas.example.edu/courses/1/quizzes/2",

  // a url suitable for loading the quiz in a mobile webview.  it will
  // persiste the headless session and, for quizzes in public courses, will
  // force the user to login
  mobile_url: "http://canvas.example.edu/courses/1/quizzes/2?persist_healdess=1&force_user=1",

  // the description of the quiz
  description: "This is a quiz on Act 3 of Hamlet",

  // type of quiz
  // possible values: "practice_quiz", "assignment", "graded_survey", "survey"
  quiz_type: "assignment",

  // the ID of the quiz's assignment group:
  assignment_group_id: 3,

  // quiz time limit in minutes
  time_limit: 5,

  // shuffle answers for students?
  shuffle_answers: false,

  // let students see their quiz responses?
  // possible values: null, "always", "until_after_last_attempt"
  hide_results: "always",

  // show which answers were correct when results are shown?
  // only valid if hide_results=null
  show_correct_answers: true,

  // which quiz score to keep (only if allowed_attempts != 1)
  // possible values: "keep_highest", "keep_latest"
  scoring_policy: "keep_highest",

  // how many times a student can take the quiz
  // -1 = unlimited attempts
  allowed_attempts: 3,

  // show one question at a time?
  one_question_at_a_time: false,

  // the number of questions in the quiz
  question_count: 12,

  // The total point value given to the quiz
  points_possible: 20,

  // lock questions after answering?
  // only valid if one_question_at_a_time=true
  cant_go_back: false,

  // access code to restrict quiz access
  access_code: "2beornot2be",

  // IP address or range that quiz access is limited to
  ip_filter: "123.123.123.123",

  // when the quiz is due
  due_at: "2013-01-23T23:59:00-07:00",

  // when to lock the quiz
  lock_at: null,

  // when to unlock the quiz
  unlock_at: "2013-01-21T23:59:00-07:00",

  // whether the quiz has a published or unpublished draft state.
  published: true,

  // Whether or not this is locked for the user.
  locked_for_user: false,

  // (Optional) Information for the user about the lock. Present when locked_for_user is true.
  lock_info: {
    // Asset string for the object causing the lock
    asset_string: "quiz_5",

    // (Optional) Time at which this was/will be unlocked.
    unlock_at: "2013-01-01T00:00:00-06:00",

    // (Optional) Time at which this was/will be locked.
    lock_at: "2013-02-01T00:00:00-06:00",

    // (Optional) Context module causing the lock.
    context_module: { ... }
  },

  // (Optional) An explanation of why this is locked for the user. Present when locked_for_user is true.
  lock_explanation: "This quiz is locked until September 1 at 12:00am"
}
  

List quizzes in a course QuizzesApiController#index

GET /api/v1/courses/:course_id/quizzes

Returns the list of Quizzes in this course.

Request Parameters:

  • search_term

    (optional) The partial title of the quizzes to match and return.

Example Request:

curl https://<canvas>/api/v1/courses/<course_id>/quizzes \ 
     -H 'Authorization: Bearer <token>'
Returns a list of Quizzes

Get a single quiz QuizzesApiController#show

GET /api/v1/courses/:course_id/quizzes/:id

Returns the quiz with the given id.

Returns a Quiz

Create a quiz QuizzesApiController#create

POST /api/v1/courses/:course_id/quizzes

Create a new quiz for this course.

Request Parameters:

  • quiz[title]
    String

    The quiz title.

  • quiz[description]
    String

    A description of the quiz.

  • quiz[quiz_type]
    "practice_quiz"|"assignment"|"graded_survey"|"survey"

    The type of quiz.

  • quiz[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 the quiz is graded, i.e. if quiz_type is "assignment" or "graded_survey"

  • quiz[time_limit]
    Integer

    Time limit to take this quiz, in minutes. Set to null for no time limit. Defaults to null.

  • quiz[shuffle_answers]
    Boolean

    If true, quiz answers for multiple choice questions will be randomized for each student. Defaults to false.

  • quiz[hide_results]
    null|"always"|"until_after_last_attempt"

    Dictates whether or not quiz results are hidden from students. If null, students can see their results after any attempt. If "always", students can never see their results. If "until_after_last_attempt", students can only see results after their last attempt. (Only valid if allowed_attempts > 1) Defaults to null.

  • quiz[show_correct_answers]
    Boolean

    Only valid if hide_results=null If false, hides correct answers from students when quiz results are viewed. Defaults to true.

  • quiz[allowed_attempts]
    Integer

    Number of times a student is allowed to take a quiz. Set to -1 for unlimited attempts. Defaults to 1.

  • quiz[scoring_policy]
    "keep_highest"|"keep_latest"

    Required and only valid if allowed_attempts > 1. Scoring policy for a quiz that students can take multiple times. Defaults to "keep_highest".

  • quiz[one_question_at_a_time]
    Boolean

    If true, shows quiz to student one question at a time. Defaults to false.

  • quiz[cant_go_back]
    Boolean

    Only valid if one_question_at_a_time=true If true, questions are locked after answering. Defaults to false.

  • quiz[access_code]
    Optional,String

    Restricts access to the quiz with a password. For no access code restriction, set to null. Defaults to null.

  • quiz[ip_filter]
    Optional,String

    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

    Examples:

    "192.168.217.1"
    "192.168.217.1/24"
    "192.168.217.1/255.255.255.0"

    For no IP filter restriction, set to null. Defaults to null.

  • quiz[due_at]
    Timestamp

    The day/time the quiz is due. Accepts times in ISO 8601 format, e.g. 2011-10-21T18:48Z.

  • quiz[lock_at]
    Timestamp

    The day/time the quiz is locked for students. Accepts times in ISO 8601 format, e.g. 2011-10-21T18:48Z.

  • quiz[unlock_at]
    Timestamp

    The day/time the quiz is unlocked for students. Accepts times in ISO 8601 format, e.g. 2011-10-21T18:48Z.

  • quiz[published]
    Boolean

    Whether the quiz should have a draft state of published or unpublished. NOTE: If students have started taking the quiz, or there are any submissions for the quiz, you may not unpublish a quiz and will recieve an error.

Returns a Quiz

Edit a quiz QuizzesApiController#update

PUT /api/v1/courses/:course_id/quizzes/:id

Modify an existing quiz. See the documentation for quiz creation.

Additional arguments:

Request Parameters:

  • quiz[notify_of_update]
    Boolean

    If true, notifies users that the quiz has changed. Defaults to true

Returns a Quiz

Delete a quiz QuizzesApiController#destroy

DELETE /api/v1/courses/:course_id/quizzes/:id