# Assessment Question Banks

{% hint style="warning" %}
**Welcome to Our New API Docs!** This is the new home for all things API (previously at [Canvas LMS REST API Documentation](https://api.instructure.com)).
{% endhint %}

## Assessment Question Banks API

**An AssessmentQuestionBank object looks like:**

```js
{
  // The ID of the assessment question bank.
  "id": 1,
  // The ID of the context (course or account) the question bank belongs to.
  "context_id": 2,
  // The type of context (Course or Account).
  "context_type": "Course",
  // The title of the question bank.
  "title": "Chapter 1 Questions",
  // The workflow state of the question bank.
  "workflow_state": "active",
  // The number of questions in the bank.
  "assessment_question_count": 10,
  // The combined context type and ID.
  "context_code": "course_2",
  // The date and time the question bank was created.
  "created_at": "2013-01-01T00:00:00Z",
  // The date and time the question bank was last updated.
  "updated_at": "2013-01-01T00:00:00Z"
}
```

**An AssessmentQuestion object looks like:**

```js
{
  // The ID of the assessment question.
  "id": 1,
  // The order of the question.
  "position": 1,
  // The ID of the question bank this question belongs to.
  "assessment_question_bank_id": 3,
  // The date and time when the assessment question was created.
  "created_at": "2013-01-23T23:59:00-07:00",
  // The name of the question.
  "question_name": "Prime Number Identification",
  // The type of the question.
  "question_type": "multiple_choice_question",
  // The text of the question.
  "question_text": "Which of the following is NOT a prime number?",
  // The maximum amount of points possible received for getting this question
  // correct.
  "points_possible": 5,
  // The comments to display if the student answers the question correctly.
  "correct_comments": "That's correct!",
  // The comments to display if the student answers incorrectly.
  "incorrect_comments": "Unfortunately, that IS a prime number.",
  // The comments to display regardless of how the student answered.
  "neutral_comments": "Goldbach's conjecture proposes that every even integer greater than 2 can be expressed as the sum of two prime numbers.",
  // The HTML version of the comments to display if the student answers the
  // question correctly.
  "correct_comments_html": "<p>That's correct!</p>",
  // The HTML version of the comments to display if the student answers
  // incorrectly.
  "incorrect_comments_html": "<p>Unfortunately, that IS a prime number.</p>",
  // The HTML version of the comments to display regardless of how the student
  // answered.
  "neutral_comments_html": "<p>Goldbach's conjecture proposes that every even integer greater than 2 can be expressed as the sum of two prime numbers.</p>",
  // An array of available answers. Each answer contains id, text, html, comments,
  // comments_html, and weight properties.
  "answers": null,
  // Variables for calculated questions. Null for other question types.
  "variables": null,
  // Formulas for calculated questions. Null for other question types.
  "formulas": null,
  // The tolerance for numerical answers. Null for non-numerical question types.
  "answer_tolerance": null,
  // The number of decimal places for formula results. Null for non-calculated
  // question types.
  "formula_decimal_places": null,
  // Matching pairs for matching questions. Null for other question types.
  "matches": null,
  // Incorrect match options for matching questions. Null for other question
  // types.
  "matching_answer_incorrect_matches": null
}
```

### [List question banks](#method.assessment_question_banks.index) <a href="#method.assessment_question_banks.index" id="method.assessment_question_banks.index"></a>

[AssessmentQuestionBanksController#index](https://github.com/instructure/canvas-lms/blob/master/app/controllers/assessment_question_banks_controller.rb)

**`GET /api/v1/question_banks`**

**Scope:** `url:GET|/api/v1/question_banks`

Returns the paginated list of question banks for a given context.

**Request Parameters:**

| Parameter                | Type               | Description                                                                                                                       |
| ------------------------ | ------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| `context_type`           | Required `string`  | <p>The type of context. Must be either “Course” or “Account”.</p><p>Allowed values: <code>Course</code>, <code>Account</code></p> |
| `context_id`             | Required `integer` | The id of the context.                                                                                                            |
| `include_question_count` | `boolean`          | Whether to include the number of questions in each bank.                                                                          |

**Example Request:**

```bash
curl 'https://<canvas>/api/v1/question_banks?context_type=Course&context_id=1' \
     -H 'Authorization: Bearer <token>'
```

Returns a list of [AssessmentQuestionBank](#assessmentquestionbank) objects.

### [Get a single question bank](#method.assessment_question_banks.show) <a href="#method.assessment_question_banks.show" id="method.assessment_question_banks.show"></a>

[AssessmentQuestionBanksController#show](https://github.com/instructure/canvas-lms/blob/master/app/controllers/assessment_question_banks_controller.rb)

**`GET /api/v1/question_banks/:id`**

**Scope:** `url:GET|/api/v1/question_banks/:id`

Returns the question bank with the given id

**Request Parameters:**

| Parameter                | Type               | Description                                             |
| ------------------------ | ------------------ | ------------------------------------------------------- |
| `id`                     | Required `integer` | The question bank unique identifier.                    |
| `include_question_count` | `boolean`          | Whether to include the number of questions in the bank. |

Returns an [AssessmentQuestionBank](#assessmentquestionbank) object.

### [List assessment questions for a question bank](#method.assessment_question_banks.questions) <a href="#method.assessment_question_banks.questions" id="method.assessment_question_banks.questions"></a>

[AssessmentQuestionBanksController#questions](https://github.com/instructure/canvas-lms/blob/master/app/controllers/assessment_question_banks_controller.rb)

**`GET /api/v1/question_banks/:id/questions`**

**Scope:** `url:GET|/api/v1/question_banks/:id/questions`

Returns the paginated list of assessment questions in this bank.

**Request Parameters:**

| Parameter | Type               | Description                          |
| --------- | ------------------ | ------------------------------------ |
| `id`      | Required `integer` | The question bank unique identifier. |

**Example Request:**

```bash
curl 'https://<canvas>/api/v1/question_banks/:id/questions' \
     -H 'Authorization: Bearer <token>'
```

Returns a list of [AssessmentQuestion](#assessmentquestion) objects.

***

This documentation is generated directly from the Canvas LMS source code, available [on Github](https://github.com/instructure/canvas-lms).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developerdocs.instructure.com/services/canvas/resources/assessment_question_banks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
