# Criteria

## Add a criterion to a rubric

`rubrics.criteria.create(strrubric_id, CriterionCreateParams**kwargs)  -> RubricCriteriaResponse`

**post** `/v5/rubrics/{rubric_id}/criteria`

Add a single criterion to an existing rubric.

Creates a new criterion at version 1 under the given rubric. Criteria are
versioned independently of the rubric they belong to. The request is rejected
if the target rubric is archived.

### Parameters

- `rubric_id: str`

- `title: str`

  The Criteria text

- `annotations: Optional[Dict[str, object]]`

  Free-form metadata for the Criteria

- `weight: Optional[float]`

  Weight multiplier for scoring

### Returns

- `class RubricCriteriaResponse: …`

  - `id: str`

  - `created_at: datetime`

  - `rubric_id: str`

  - `title: str`

  - `version: int`

  - `annotations: Optional[Dict[str, object]]`

  - `object: Optional[Literal["rubric_criteria"]]`

    - `"rubric_criteria"`

  - `weight: Optional[float]`

### Example

```python
import os
from scale_gp_beta import SGPClient

client = SGPClient(
    api_key=os.environ.get("SGP_API_KEY"),  # This is the default and can be omitted
)
rubric_criteria_response = client.rubrics.criteria.create(
    rubric_id="rubric_id",
    title="x",
)
print(rubric_criteria_response.id)
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "rubric_id": "rubric_id",
  "title": "title",
  "version": 0,
  "annotations": {
    "foo": "bar"
  },
  "object": "rubric_criteria",
  "weight": 0
}
```

## Update a criterion

`rubrics.criteria.update(strrubric_criteria_id, CriterionUpdateParams**kwargs)  -> RubricCriteriaResponse`

**patch** `/v5/rubrics/{rubric_id}/criteria/{rubric_criteria_id}`

Apply a partial update to a criterion, creating a new version.

Updates are append-only: rather than overwriting the criterion in place, each
update inserts a new immutable version with an incremented version number, so
every prior state stays available through the versions endpoint. Fields not
supplied are carried forward from the current version. The request is rejected
if the criterion does not belong to the rubric named in the path.

### Parameters

- `rubric_id: str`

- `rubric_criteria_id: str`

- `annotations: Optional[Dict[str, object]]`

  Free-form metadata for the Criteria

- `title: Optional[str]`

  The Criteria text

- `weight: Optional[float]`

  Weight multiplier for scoring

### Returns

- `class RubricCriteriaResponse: …`

  - `id: str`

  - `created_at: datetime`

  - `rubric_id: str`

  - `title: str`

  - `version: int`

  - `annotations: Optional[Dict[str, object]]`

  - `object: Optional[Literal["rubric_criteria"]]`

    - `"rubric_criteria"`

  - `weight: Optional[float]`

### Example

```python
import os
from scale_gp_beta import SGPClient

client = SGPClient(
    api_key=os.environ.get("SGP_API_KEY"),  # This is the default and can be omitted
)
rubric_criteria_response = client.rubrics.criteria.update(
    rubric_criteria_id="rubric_criteria_id",
    rubric_id="rubric_id",
)
print(rubric_criteria_response.id)
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "rubric_id": "rubric_id",
  "title": "title",
  "version": 0,
  "annotations": {
    "foo": "bar"
  },
  "object": "rubric_criteria",
  "weight": 0
}
```

## List criterion versions

`rubrics.criteria.list_versions(strrubric_criteria_id, CriterionListVersionsParams**kwargs)  -> CriterionListVersionsResponse`

**get** `/v5/rubrics/{rubric_id}/criteria/{rubric_criteria_id}/versions`

List the full version history of a single criterion, paginated.

Because criterion updates are append-only, this returns one entry per version,
exposing every prior state of the criterion, ordered by version descending
(newest first) by default. The request is rejected if the criterion does not
belong to the rubric named in the path.

### Parameters

- `rubric_id: str`

- `rubric_criteria_id: str`

- `ending_before: Optional[str]`

- `limit: Optional[int]`

- `sort_by: Optional[str]`

- `sort_order: Optional[SortOrder]`

  - `"asc"`

  - `"desc"`

- `starting_after: Optional[str]`

### Returns

- `class CriterionListVersionsResponse: …`

  - `has_more: bool`

    Whether there are more items left to be fetched.

  - `items: List[RubricCriteriaResponse]`

    - `id: str`

    - `created_at: datetime`

    - `rubric_id: str`

    - `title: str`

    - `version: int`

    - `annotations: Optional[Dict[str, object]]`

    - `object: Optional[Literal["rubric_criteria"]]`

      - `"rubric_criteria"`

    - `weight: Optional[float]`

  - `total: int`

    The total of items that match the query. This is greater than or equal to the number of items returned.

  - `limit: Optional[int]`

    The maximum number of items to return.

  - `object: Optional[Literal["list"]]`

    - `"list"`

### Example

```python
import os
from scale_gp_beta import SGPClient

client = SGPClient(
    api_key=os.environ.get("SGP_API_KEY"),  # This is the default and can be omitted
)
response = client.rubrics.criteria.list_versions(
    rubric_criteria_id="rubric_criteria_id",
    rubric_id="rubric_id",
)
print(response.has_more)
```

#### Response

```json
{
  "has_more": true,
  "items": [
    {
      "id": "id",
      "created_at": "2019-12-27T18:11:19.117Z",
      "rubric_id": "rubric_id",
      "title": "title",
      "version": 0,
      "annotations": {
        "foo": "bar"
      },
      "object": "rubric_criteria",
      "weight": 0
    }
  ],
  "total": 0,
  "limit": 0,
  "object": "list"
}
```

## Domain Types

### Rubric Criteria Input

- `class RubricCriteriaInput: …`

  - `title: str`

    The Criteria text

  - `annotations: Optional[Dict[str, object]]`

    Free-form metadata for the Criteria

  - `weight: Optional[float]`

    Weight multiplier for scoring

### Rubric Criteria Response

- `class RubricCriteriaResponse: …`

  - `id: str`

  - `created_at: datetime`

  - `rubric_id: str`

  - `title: str`

  - `version: int`

  - `annotations: Optional[Dict[str, object]]`

  - `object: Optional[Literal["rubric_criteria"]]`

    - `"rubric_criteria"`

  - `weight: Optional[float]`

### Rubric Criteria Summary Response

- `class RubricCriteriaSummaryResponse: …`

  Slim criteria projection for list endpoints (title + weight only).

  - `title: str`

  - `weight: Optional[float]`

### Criterion List Versions Response

- `class CriterionListVersionsResponse: …`

  - `has_more: bool`

    Whether there are more items left to be fetched.

  - `items: List[RubricCriteriaResponse]`

    - `id: str`

    - `created_at: datetime`

    - `rubric_id: str`

    - `title: str`

    - `version: int`

    - `annotations: Optional[Dict[str, object]]`

    - `object: Optional[Literal["rubric_criteria"]]`

      - `"rubric_criteria"`

    - `weight: Optional[float]`

  - `total: int`

    The total of items that match the query. This is greater than or equal to the number of items returned.

  - `limit: Optional[int]`

    The maximum number of items to return.

  - `object: Optional[Literal["list"]]`

    - `"list"`
