Contents
On this page

Link Question to Passage - Plugixa Exam

PUT /plugixa-exam/v1/passages/link/{question}

Link a question to a passage, or unlink it.

Not reachable with an API token: since 1.4.1 a token request to this route answers 403 plugixa_exam_token_route. Call it as a signed-in WordPress user (from a script, with an Application Password) who holds the questions:edit permission.

Needs Plugixa Exam Pro, with the Passages app on in Plugixa Exam -> App Manager.

Note. A question has at most one passage. Linking it replaces any passage it had, and sending 0 or no passage_id at all unlinks it.

Request

PUT https://your-site.example/wp-json/plugixa-exam/v1/passages/link/48

Path parameters

Name Type Description
question integer The question’s id

Request body

Content type: application/json

Field Type Required Description
passage_id integer No The passage to link. 0, or leaving it out, unlinks the question.
{
  "passage_id": 7
}

Responses

200 OK. data holds the passage the question is now linked to.

{
  "success": true,
  "data": {
    "passage_id": 7
  }
}
Field Type Meaning
data.passage_id integer The linked passage’s id, or 0 after an unlink

Errors

Status Code When
404 plugixa_exam_not_found No question with that id, or the question is in the trash.
404 plugixa_exam_passage_missing passage_id is not 0 and no live passage has that id.

Plus the errors every endpoint can return.

Examples

curl -s -X PUT "https://your-site.example/wp-json/plugixa-exam/v1/passages/link/48" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"passage_id":7}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-exam/v1/passages/link/48');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'PUT',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Basic ' . base64_encode(getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD')),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS     => json_encode([
        'passage_id' => 7,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-exam/v1/passages/link/48', {
  method: 'PUT',
  headers: {
    'Authorization': 'Basic ' + btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ passage_id: 7 }),
});
const { data } = await response.json();

Quick Links

Share