Contents
On this page

Replace Exam Prerequisites - Plugixa Exam

PUT /plugixa-exam/v1/exams/{id}/prerequisites

Replace every prerequisite of an exam with the list you send.

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 exams:edit permission. Needs Plugixa Exam Pro with the Prerequisites app on in Plugixa Exam -> App Manager; with it off, this route answers 404.

Note. This is a full replacement: a prerequisite you leave out is removed, and an empty or missing rules removes them all. A user who may only edit their own exams can change only the exams they created.

Request

PUT https://your-site.example/wp-json/plugixa-exam/v1/exams/7/prerequisites

Path parameters

Name Type Description
id integer The exam’s id

Request body

Content type: application/json

Field Type Required Description
rules object[] No The prerequisites, in order. Missing or empty clears them all.
rules[].required_exam_id integer Yes The exam that must come first. A rule without it, or with 0, is skipped.
rules[].requirement string No passed (the default), attempted or score. Any other value is read as passed.
rules[].min_percent number No The score needed, 0 to 100. Only kept for score.

If the same required_exam_id appears twice, the last one wins. If any rule is refused, nothing is saved: the stored prerequisites stay as they were.

{
  "rules": [
    { "required_exam_id": 5, "requirement": "passed" },
    { "required_exam_id": 6, "requirement": "score", "min_percent": 70 }
  ]
}

Responses

200 OK. data is the saved list of prerequisites.

The same shape as Get Exam Prerequisites, strings included. The rules get new ids on every save.

{
  "success": true,
  "data": [
    {
      "id": "5",
      "exam_id": "7",
      "required_exam_id": "5",
      "requirement": "passed",
      "min_percent": null,
      "ordering": "0",
      "created_at": "2026-11-12 10:20:00",
      "modified_at": "2026-11-12 10:20:00",
      "created_by": "1",
      "modified_by": "1",
      "required_title": "Algebra Basics",
      "dangling": false
    },
    {
      "id": "6",
      "exam_id": "7",
      "required_exam_id": "6",
      "requirement": "score",
      "min_percent": "70.00",
      "ordering": "1",
      "created_at": "2026-11-12 10:20:00",
      "modified_at": "2026-11-12 10:20:00",
      "created_by": "1",
      "modified_by": "1",
      "required_title": "Fractions Quiz",
      "dangling": false
    }
  ]
}
Field Type Meaning
data[].required_exam_id string The exam that must come first
data[].requirement string passed, attempted or score
data[].min_percent string|null The score needed, for score only
data[].required_title string|null The required exam’s title
data[].dangling boolean true when the required exam no longer exists

Errors

Status Code When
404 plugixa_exam_not_found No exam has this id, or the exam is in the trash.
400 plugixa_exam_invalid_prerequisites A required exam does not exist, the exam requires itself, or a rule would create a loop in which neither exam could be started. The message lists every reason.
403 plugixa_exam_forbidden The user may only edit their own exams, and did not create this one.

Plus the errors every endpoint can return.

Examples

curl -s -X PUT "https://your-site.example/wp-json/plugixa-exam/v1/exams/7/prerequisites" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"rules":[{"required_exam_id":5,"requirement":"passed"},{"required_exam_id":6,"requirement":"score","min_percent":70}]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-exam/v1/exams/7/prerequisites');
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([
        'rules' => [
            ['required_exam_id' => 5, 'requirement' => 'passed'],
            ['required_exam_id' => 6, 'requirement' => 'score', 'min_percent' => 70],
        ],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-exam/v1/exams/7/prerequisites', {
  method: 'PUT',
  headers: {
    'Authorization': 'Basic ' + btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    rules: [
      { required_exam_id: 5, requirement: 'passed' },
      { required_exam_id: 6, requirement: 'score', min_percent: 70 },
    ],
  }),
});
const { data } = await response.json();

Quick Links

Share