{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/calculate-co-nz/json-schema/calculate-co-nz-ncea-rank-score-response-schema.json",
  "title": "NceaRankScoreResponse",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/calculate-co-nz-openapi.json#/components/schemas/NceaRankScoreResponse",
  "properties": {
    "result": {
      "$ref": "#/$defs/NceaRankScoreResult",
      "description": "Rank score and indicative GPA."
    },
    "disclaimer": {
      "type": "string",
      "title": "Disclaimer",
      "description": "Scope and limits of this calculation."
    }
  },
  "type": "object",
  "required": [
    "result",
    "disclaimer"
  ],
  "$defs": {
    "NceaRankScoreResult": {
      "properties": {
        "excellence_credits": {
          "type": "integer",
          "title": "Excellence Credits",
          "description": "Excellence credits entered, across all subjects."
        },
        "merit_credits": {
          "type": "integer",
          "title": "Merit Credits",
          "description": "Merit credits entered, across all subjects."
        },
        "achieved_credits": {
          "type": "integer",
          "title": "Achieved Credits",
          "description": "Achieved credits entered, across all subjects."
        },
        "not_achieved_credits": {
          "type": "integer",
          "title": "Not Achieved Credits",
          "description": "Not Achieved credits as given."
        },
        "total_credits": {
          "type": "integer",
          "title": "Total Credits",
          "description": "Everything entered, including Not Achieved."
        },
        "rank_score": {
          "type": "integer",
          "title": "Rank Score",
          "description": "The rank score, out of 320, by the method Auckland, Massey (Preferential Entry Score) and Otago (entry score) publish. Each university that uses one calculates its own; NZQA does not issue one. An upper bound when `rank_score_is_upper_bound` is true."
        },
        "rank_score_max": {
          "type": "integer",
          "title": "Rank Score Max",
          "description": "320, being 80 credits at 4 points."
        },
        "credits_counted": {
          "type": "integer",
          "title": "Credits Counted",
          "description": "How many credits counted (80 at most)."
        },
        "credits_ignored": {
          "type": "integer",
          "title": "Credits Ignored",
          "description": "Achieving credits entered that did not count, for any reason: the four credits_* fields below add up to it."
        },
        "method": {
          "type": "string",
          "enum": [
            "per_subject",
            "totals"
          ],
          "title": "Method",
          "description": "'per_subject' when `subjects` was given, else 'totals'."
        },
        "rank_score_is_upper_bound": {
          "type": "boolean",
          "title": "Rank Score Is Upper Bound",
          "description": "True when totals were given: the 24-credit subject cap, the five-subject limit and subject approval could not be applied, so the real score may be lower."
        },
        "subjects_counted": {
          "items": {
            "$ref": "#/$defs/NceaSubjectCounted"
          },
          "type": "array",
          "title": "Subjects Counted",
          "description": "The (up to) five subjects used, and what each contributed. Empty for totals."
        },
        "subjects_not_counted": {
          "items": {
            "$ref": "#/$defs/NceaSubjectNotCounted"
          },
          "type": "array",
          "title": "Subjects Not Counted",
          "description": "Subjects with credits that were left out, and why."
        },
        "credits_not_approved": {
          "type": "integer",
          "title": "Credits Not Approved",
          "description": "Credits in subjects not marked approved."
        },
        "credits_over_subject_cap": {
          "type": "integer",
          "title": "Credits Over Subject Cap",
          "description": "Credits beyond the 24 a subject can count."
        },
        "credits_outside_best_five": {
          "type": "integer",
          "title": "Credits Outside Best Five",
          "description": "Credits in subjects outside the best five."
        },
        "credits_outside_best_80": {
          "type": "integer",
          "title": "Credits Outside Best 80",
          "description": "Credits in the best five subjects beyond the best 80."
        },
        "rank_score_working": {
          "type": "string",
          "title": "Rank Score Working",
          "description": "The rank score calculation written out."
        },
        "indicative_gpa_4_point": {
          "type": "number",
          "title": "Indicative Gpa 4 Point",
          "description": "An UNOFFICIAL, indicative 4-point GPA: Excellence 4, Merit 3, Achieved 2, Not Achieved 0, credit-weighted across EVERY credit entered, not only the best 80. Not NZQA's grade point average estimate for overseas applications."
        },
        "gpa_is_unofficial": {
          "type": "boolean",
          "title": "Gpa Is Unofficial",
          "description": "Always true. This is not NZQA's grade point average estimate."
        },
        "next_step": {
          "type": "string",
          "title": "Next Step",
          "description": "What would actually raise the rank score for this student."
        },
        "excludes": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Excludes",
          "description": "What this does not cover."
        }
      },
      "type": "object",
      "required": [
        "excellence_credits",
        "merit_credits",
        "achieved_credits",
        "not_achieved_credits",
        "total_credits",
        "rank_score",
        "rank_score_max",
        "credits_counted",
        "credits_ignored",
        "method",
        "rank_score_is_upper_bound",
        "subjects_counted",
        "subjects_not_counted",
        "credits_not_approved",
        "credits_over_subject_cap",
        "credits_outside_best_five",
        "credits_outside_best_80",
        "rank_score_working",
        "indicative_gpa_4_point",
        "gpa_is_unofficial",
        "next_step",
        "excludes"
      ],
      "title": "NceaRankScoreResult"
    },
    "NceaSubjectCounted": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name",
          "description": "The subject."
        },
        "excellence_counted": {
          "type": "integer",
          "title": "Excellence Counted",
          "description": "Excellence credits from it inside the best 80."
        },
        "merit_counted": {
          "type": "integer",
          "title": "Merit Counted",
          "description": "Merit credits from it inside the best 80."
        },
        "achieved_counted": {
          "type": "integer",
          "title": "Achieved Counted",
          "description": "Achieved credits from it inside the best 80."
        },
        "credits_counted": {
          "type": "integer",
          "title": "Credits Counted",
          "description": "Its credits inside the best 80 (24 at most)."
        },
        "credits_entered": {
          "type": "integer",
          "title": "Credits Entered",
          "description": "Its achieving credits as entered."
        },
        "points": {
          "type": "integer",
          "title": "Points",
          "description": "Its contribution to the rank score."
        }
      },
      "type": "object",
      "required": [
        "name",
        "excellence_counted",
        "merit_counted",
        "achieved_counted",
        "credits_counted",
        "credits_entered",
        "points"
      ],
      "title": "NceaSubjectCounted"
    },
    "NceaSubjectNotCounted": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name",
          "description": "The subject."
        },
        "credits": {
          "type": "integer",
          "title": "Credits",
          "description": "Its achieving credits as entered."
        },
        "reason": {
          "type": "string",
          "title": "Reason",
          "description": "'not an approved subject' or 'outside the best five subjects'."
        }
      },
      "type": "object",
      "required": [
        "name",
        "credits",
        "reason"
      ],
      "title": "NceaSubjectNotCounted"
    }
  }
}