# /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"
}
```
