# /check-answer

**Note**: This endpoint does not save the grade. It only checks the answer and returns written feedback.

**Input Parameters**

| Parameter    | Type                 | Description                                                                                                                                                                                                              |
| ------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| questionId   | `String`             | ID for the question. (Fetched from `get-quiz`)                                                                                                                                                                           |
| studentInput | `String` or `Number` | <p>The answer submitted by the student.<br><br><code>String</code> for <strong>free form</strong> questions.</p><p><br><code>Number</code> for <strong>index</strong> of <strong>multiple choice</strong> questions.</p> |

**Example Request**

```javascript
// Example to check an answer
fetch("https://api.arlinear.com/functions/v1/check-answer", {
  method: "POST",
  headers: {
    Authorization: "<Your API Key>",
  },
  body: JSON.stringify({
    questionId: "b03ab02d-95fe-4a29-94a2-3554b1fd4e07",
    studentInput: "mitochondria is the powerhouse of the cell", // or 0 (index of choice) for multiple choice questions (see note below)
  }),
});

/*
  --- for studentInput ---
  
      for short answer questions: pass in a string for student input (i.e "the mitochondria is the powerhouse of the cell")
      
      for multiple choice questions: pass in mc 'choices' index for student input (i.e. 0, 1, 2, 3, etc...)
      
      Example: 
      if you want to use the first option as an answer, pass in "0" as the studentInput
      "choices": [
            {
                "value": " 11",
                "isCorrect": true,
                "type": "choice"
            },
            {
                "value": " 14",
                "isCorrect": false,
                "type": "choice"
            },
            {
                "value": " 9",
                "isCorrect": false,
                "type": "choice"
            }
        ]
*/
```

**Return Value**

* `score`: Points scored in the question.
* `scoreOutOf`: Maximum possible points.
* `percentage`: Percentage score.
* `feedback`: Feedback on the answer.

```json
{
  "score": 1,
  "scoreOutOf": 1,
  "percentage": 100,
  "feedback": "Correct answer"
}
```


---

# 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://arlinear.gitbook.io/documentation/api/check-answer.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.
