# `Ltix.GradeService.LineItem`
[🔗](https://github.com/DecoyLex/ltix/blob/main/lib/ltix/grade_service/line_item.ex#L1)

A line item (gradebook column) in the platform's gradebook.

Line items hold results for a specific activity and set of users.
Each has a label, maximum score, and optional bindings to resource
links or tool resources.

## Examples

    {:ok, item} = Ltix.GradeService.LineItem.from_json(%{
      "id" => "https://lms.example.com/lineitems/1",
      "label" => "Chapter 5 Test",
      "scoreMaximum" => 60,
      "tag" => "grade"
    })

    item.label
    #=> "Chapter 5 Test"

    item.score_maximum
    #=> 60

# `t`

```elixir
@type t() :: %Ltix.GradeService.LineItem{
  end_date_time: String.t() | nil,
  extensions: %{optional(String.t()) =&gt; term()},
  grades_released: boolean() | nil,
  id: String.t() | nil,
  label: String.t() | nil,
  resource_id: String.t() | nil,
  resource_link_id: String.t() | nil,
  score_maximum: number() | nil,
  start_date_time: String.t() | nil,
  tag: String.t() | nil
}
```

# `from_json`

```elixir
@spec from_json(map()) :: {:ok, t()}
```

Parse a line item from a decoded JSON map.

Accepts any map and extracts known fields. Unrecognized keys are
captured in `extensions` for lossless round-trips.

## Examples

    iex> {:ok, item} = Ltix.GradeService.LineItem.from_json(%{"label" => "Quiz 1", "scoreMaximum" => 100})
    iex> {item.label, item.score_maximum}
    {"Quiz 1", 100}

# `to_json`

```elixir
@spec to_json(t()) :: {:ok, map()} | {:error, Exception.t()}
```

Serialize a line item to a JSON-compatible map.

Validates that `label` is present and non-blank, and that
`score_maximum` is a positive number. Returns `{:ok, map}` or
`{:error, exception}`.

## Examples

    iex> item = %Ltix.GradeService.LineItem{label: "Quiz 1", score_maximum: 100}
    iex> {:ok, json} = Ltix.GradeService.LineItem.to_json(item)
    iex> {json["label"], json["scoreMaximum"]}
    {"Quiz 1", 100}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
